mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Implement chapter segment support.
Closes https://github.com/TeamPiped/Piped/issues/600
This commit is contained in:
parent
5feec94220
commit
98127b8c0e
3 changed files with 16 additions and 7 deletions
|
@ -136,10 +136,15 @@ public class ResponseHelper {
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<Subtitle> subtitles = new ObjectArrayList<>();
|
final List<Subtitle> subtitles = new ObjectArrayList<>();
|
||||||
|
final List<ChapterSegment> chapters = new ObjectArrayList<>();
|
||||||
|
|
||||||
final StreamInfo info = futureStream.get();
|
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()
|
info.getSubtitles()
|
||||||
.forEach(subtitle -> subtitles.add(new Subtitle(rewriteURL(subtitle.getUrl()),
|
.forEach(subtitle -> subtitles.add(new Subtitle(rewriteURL(subtitle.getUrl()),
|
||||||
subtitle.getFormat().getMimeType(), subtitle.getDisplayLanguageName(),
|
subtitle.getFormat().getMimeType(), subtitle.getDisplayLanguageName(),
|
||||||
|
@ -184,8 +189,8 @@ public class ResponseHelper {
|
||||||
|
|
||||||
List<ChapterSegment> segments = new ObjectArrayList<>();
|
List<ChapterSegment> segments = new ObjectArrayList<>();
|
||||||
|
|
||||||
info.getStreamSegments().forEach(
|
info.getStreamSegments().forEach(segment -> segments
|
||||||
segment -> segments.add(new ChapterSegment(segment.getTitle(), segment.getStartTimeSeconds())));
|
.add(new ChapterSegment(segment.getTitle(), segment.getPreviewUrl(), segment.getStartTimeSeconds())));
|
||||||
|
|
||||||
long time = info.getUploadDate() != null ? info.getUploadDate().offsetDateTime().toInstant().toEpochMilli()
|
long time = info.getUploadDate() != null ? info.getUploadDate().offsetDateTime().toInstant().toEpochMilli()
|
||||||
: System.currentTimeMillis();
|
: System.currentTimeMillis();
|
||||||
|
@ -198,7 +203,7 @@ public class ResponseHelper {
|
||||||
rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(),
|
rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(),
|
||||||
info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.isUploaderVerified(),
|
info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.isUploaderVerified(),
|
||||||
audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteURL(info.getHlsUrl()),
|
audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteURL(info.getHlsUrl()),
|
||||||
rewriteURL(info.getDashMpdUrl()), futureLbryId.get());
|
rewriteURL(info.getDashMpdUrl()), futureLbryId.get(), chapters);
|
||||||
|
|
||||||
return Constants.mapper.writeValueAsBytes(streams);
|
return Constants.mapper.writeValueAsBytes(streams);
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,12 @@ package me.kavin.piped.utils.obj;
|
||||||
|
|
||||||
public class ChapterSegment {
|
public class ChapterSegment {
|
||||||
|
|
||||||
public String title;
|
public String title, image;
|
||||||
public int start;
|
public int start;
|
||||||
|
|
||||||
public ChapterSegment(String title, int start) {
|
public ChapterSegment(String title, String image, int start) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
this.image = image;
|
||||||
this.start = start;
|
this.start = start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,13 @@ public class Streams {
|
||||||
|
|
||||||
public final String proxyUrl = Constants.PROXY_PART;
|
public final String proxyUrl = Constants.PROXY_PART;
|
||||||
|
|
||||||
|
public List<ChapterSegment> chapters;
|
||||||
|
|
||||||
public Streams(String title, String description, String uploadDate, String uploader, String uploaderUrl,
|
public Streams(String title, String description, String uploadDate, String uploader, String uploaderUrl,
|
||||||
String uploaderAvatar, String thumbnailUrl, long duration, long views, long likes, long dislikes,
|
String uploaderAvatar, String thumbnailUrl, long duration, long views, long likes, long dislikes,
|
||||||
boolean uploaderVerified, List<PipedStream> audioStreams, List<PipedStream> videoStreams,
|
boolean uploaderVerified, List<PipedStream> audioStreams, List<PipedStream> videoStreams,
|
||||||
List<StreamItem> relatedStreams, List<Subtitle> subtitles, boolean livestream, String hls, String dash,
|
List<StreamItem> relatedStreams, List<Subtitle> subtitles, boolean livestream, String hls, String dash,
|
||||||
String lbryId) {
|
String lbryId, List<ChapterSegment> chapters) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.uploadDate = uploadDate;
|
this.uploadDate = uploadDate;
|
||||||
|
@ -48,5 +50,6 @@ public class Streams {
|
||||||
this.hls = hls;
|
this.hls = hls;
|
||||||
this.dash = dash;
|
this.dash = dash;
|
||||||
this.lbryId = lbryId;
|
this.lbryId = lbryId;
|
||||||
|
this.chapters = chapters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue