Merge pull request #489 from TeamPiped/preview-frames

Add support to extract preview frames.
This commit is contained in:
Kavin 2022-12-15 17:33:50 +00:00 committed by GitHub
commit e414148918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 5 deletions

View File

@ -22,6 +22,11 @@ public class CollectionUtils {
info.getStreamSegments().forEach(segment -> chapters.add(new ChapterSegment(segment.getTitle(), rewriteURL(segment.getPreviewUrl()), info.getStreamSegments().forEach(segment -> chapters.add(new ChapterSegment(segment.getTitle(), rewriteURL(segment.getPreviewUrl()),
segment.getStartTimeSeconds()))); segment.getStartTimeSeconds())));
final List<PreviewFrames> previewFrames = new ObjectArrayList<>();
info.getPreviewFrames().forEach(frame -> new PreviewFrames(frame.getUrls(), frame.getFrameWidth(), frame.getFrameHeight(),
frame.getTotalCount(), frame.getDurationPerFrame(), frame.getFramesPerPageX(), frame.getFramesPerPageY()));
info.getSubtitles() info.getSubtitles()
.forEach(subtitle -> subtitles.add(new Subtitle(rewriteURL(subtitle.getContent()), .forEach(subtitle -> subtitles.add(new Subtitle(rewriteURL(subtitle.getContent()),
subtitle.getFormat().getMimeType(), subtitle.getDisplayLanguageName(), subtitle.getFormat().getMimeType(), subtitle.getDisplayLanguageName(),
@ -51,14 +56,12 @@ public class CollectionUtils {
final List<ContentItem> relatedStreams = collectRelatedItems(info.getRelatedItems()); final List<ContentItem> relatedStreams = collectRelatedItems(info.getRelatedItems());
final Streams streams = new Streams(info.getName(), info.getDescription().getContent(), return new Streams(info.getName(), info.getDescription().getContent(),
info.getTextualUploadDate(), info.getUploaderName(), substringYouTube(info.getUploaderUrl()), info.getTextualUploadDate(), info.getUploaderName(), substringYouTube(info.getUploaderUrl()),
rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(), rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(),
info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.getUploaderSubscriberCount(), info.isUploaderVerified(), info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.getUploaderSubscriberCount(), info.isUploaderVerified(),
audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteVideoURL(info.getHlsUrl()), audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteVideoURL(info.getHlsUrl()),
rewriteVideoURL(info.getDashMpdUrl()), null, chapters); rewriteVideoURL(info.getDashMpdUrl()), null, chapters, previewFrames);
return streams;
} }
public static List<ContentItem> collectRelatedItems(List<? extends InfoItem> items) { public static List<ContentItem> collectRelatedItems(List<? extends InfoItem> items) {

View File

@ -0,0 +1,20 @@
package me.kavin.piped.utils.obj;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
public class PreviewFrames {
public List<String> urls;
public int frameWidth;
public int frameHeight;
public int totalCount;
public int durationPerFrame;
public int framesPerPageX;
public int framesPerPageY;
}

View File

@ -27,11 +27,13 @@ public class Streams {
public List<ChapterSegment> chapters; public List<ChapterSegment> chapters;
public List<PreviewFrames> previewFrames;
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, long uploaderSubscriberCount, String uploaderAvatar, String thumbnailUrl, long duration, long views, long likes, long dislikes, long uploaderSubscriberCount,
boolean uploaderVerified, List<PipedStream> audioStreams, List<PipedStream> videoStreams, boolean uploaderVerified, List<PipedStream> audioStreams, List<PipedStream> videoStreams,
List<ContentItem> relatedStreams, List<Subtitle> subtitles, boolean livestream, String hls, String dash, List<ContentItem> relatedStreams, List<Subtitle> subtitles, boolean livestream, String hls, String dash,
String lbryId, List<ChapterSegment> chapters) { String lbryId, List<ChapterSegment> chapters, List<PreviewFrames> previewFrames) {
this.title = title; this.title = title;
this.description = description; this.description = description;
this.uploadDate = uploadDate; this.uploadDate = uploadDate;
@ -54,5 +56,6 @@ public class Streams {
this.dash = dash; this.dash = dash;
this.lbryId = lbryId; this.lbryId = lbryId;
this.chapters = chapters; this.chapters = chapters;
this.previewFrames = previewFrames;
} }
} }