Implement chapter segment support.

Closes https://github.com/TeamPiped/Piped/issues/600
This commit is contained in:
FireMaskterK 2021-11-04 19:21:26 +00:00
parent 5feec94220
commit 98127b8c0e
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
3 changed files with 16 additions and 7 deletions

View file

@ -136,10 +136,15 @@ public class ResponseHelper {
});
final List<Subtitle> subtitles = new ObjectArrayList<>();
final List<ChapterSegment> chapters = new ObjectArrayList<>();
final StreamInfo info = futureStream.get();
// System.out.println(Constants.mapper.writeValueAsString(info.getStreamSegments()));
info.getStreamSegments().forEach(segment -> {
chapters.add(
new ChapterSegment(segment.getTitle(), segment.getPreviewUrl(), segment.getStartTimeSeconds()));
});
info.getSubtitles()
.forEach(subtitle -> subtitles.add(new Subtitle(rewriteURL(subtitle.getUrl()),
subtitle.getFormat().getMimeType(), subtitle.getDisplayLanguageName(),
@ -184,8 +189,8 @@ public class ResponseHelper {
List<ChapterSegment> segments = new ObjectArrayList<>();
info.getStreamSegments().forEach(
segment -> segments.add(new ChapterSegment(segment.getTitle(), segment.getStartTimeSeconds())));
info.getStreamSegments().forEach(segment -> segments
.add(new ChapterSegment(segment.getTitle(), segment.getPreviewUrl(), segment.getStartTimeSeconds())));
long time = info.getUploadDate() != null ? info.getUploadDate().offsetDateTime().toInstant().toEpochMilli()
: System.currentTimeMillis();
@ -198,7 +203,7 @@ public class ResponseHelper {
rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(),
info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.isUploaderVerified(),
audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteURL(info.getHlsUrl()),
rewriteURL(info.getDashMpdUrl()), futureLbryId.get());
rewriteURL(info.getDashMpdUrl()), futureLbryId.get(), chapters);
return Constants.mapper.writeValueAsBytes(streams);

View file

@ -2,11 +2,12 @@ package me.kavin.piped.utils.obj;
public class ChapterSegment {
public String title;
public String title, image;
public int start;
public ChapterSegment(String title, int start) {
public ChapterSegment(String title, String image, int start) {
this.title = title;
this.image = image;
this.start = start;
}
}

View file

@ -23,11 +23,13 @@ public class Streams {
public final String proxyUrl = Constants.PROXY_PART;
public List<ChapterSegment> chapters;
public Streams(String title, String description, String uploadDate, String uploader, String uploaderUrl,
String uploaderAvatar, String thumbnailUrl, long duration, long views, long likes, long dislikes,
boolean uploaderVerified, List<PipedStream> audioStreams, List<PipedStream> videoStreams,
List<StreamItem> relatedStreams, List<Subtitle> subtitles, boolean livestream, String hls, String dash,
String lbryId) {
String lbryId, List<ChapterSegment> chapters) {
this.title = title;
this.description = description;
this.uploadDate = uploadDate;
@ -48,5 +50,6 @@ public class Streams {
this.hls = hls;
this.dash = dash;
this.lbryId = lbryId;
this.chapters = chapters;
}
}