From adacbfe285c0ff764b24ce9fec4f7a97a6e2a464 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 3 Aug 2023 15:40:46 +0200 Subject: [PATCH] feat: support for meta info of videos --- .../me/kavin/piped/utils/CollectionUtils.java | 7 ++++++- .../java/me/kavin/piped/utils/obj/MetaInfo.java | 17 +++++++++++++++++ .../java/me/kavin/piped/utils/obj/Streams.java | 6 +++++- testing/api-test.sh | 3 +++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/kavin/piped/utils/obj/MetaInfo.java diff --git a/src/main/java/me/kavin/piped/utils/CollectionUtils.java b/src/main/java/me/kavin/piped/utils/CollectionUtils.java index b04fa1d..365048f 100644 --- a/src/main/java/me/kavin/piped/utils/CollectionUtils.java +++ b/src/main/java/me/kavin/piped/utils/CollectionUtils.java @@ -64,13 +64,18 @@ public class CollectionUtils { final List relatedStreams = collectRelatedItems(info.getRelatedItems()); + final List metaInfo = new ObjectArrayList<>(); + info.getMetaInfo().forEach(metaInfoItem -> { + metaInfo.add(new MetaInfo(metaInfoItem.getTitle(), metaInfoItem.getContent().getContent(), metaInfoItem.getUrls(), metaInfoItem.getUrlTexts())); + }); + return new Streams(info.getName(), info.getDescription().getContent(), info.getTextualUploadDate(), info.getUploaderName(), substringYouTube(info.getUploaderUrl()), rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(), info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.getUploaderSubscriberCount(), info.isUploaderVerified(), audioStreams, videoStreams, relatedStreams, subtitles, livestream, rewriteVideoURL(info.getHlsUrl()), rewriteVideoURL(info.getDashMpdUrl()), null, info.getCategory(), info.getLicence(), - info.getPrivacy().name().toLowerCase(), info.getTags(), chapters, previewFrames); + info.getPrivacy().name().toLowerCase(), info.getTags(), metaInfo, chapters, previewFrames); } public static List collectRelatedItems(List items) { diff --git a/src/main/java/me/kavin/piped/utils/obj/MetaInfo.java b/src/main/java/me/kavin/piped/utils/obj/MetaInfo.java new file mode 100644 index 0000000..b0915d6 --- /dev/null +++ b/src/main/java/me/kavin/piped/utils/obj/MetaInfo.java @@ -0,0 +1,17 @@ +package me.kavin.piped.utils.obj; + +import java.util.List; +import java.net.URL; + +public class MetaInfo { + public String title, description; + public List urls; + public List urlTexts; + + public MetaInfo(String title, String description, List urls, List urlTexts) { + this.title = title; + this.description = description; + this.urls = urls; + this.urlTexts = urlTexts; + } +} diff --git a/src/main/java/me/kavin/piped/utils/obj/Streams.java b/src/main/java/me/kavin/piped/utils/obj/Streams.java index f521b98..478a37b 100644 --- a/src/main/java/me/kavin/piped/utils/obj/Streams.java +++ b/src/main/java/me/kavin/piped/utils/obj/Streams.java @@ -13,6 +13,8 @@ public class Streams { public List tags; + public List metaInfo; + public boolean uploaderVerified; public long duration, views, likes, dislikes, uploaderSubscriberCount; @@ -35,7 +37,8 @@ public class Streams { String uploaderAvatar, String thumbnailUrl, long duration, long views, long likes, long dislikes, long uploaderSubscriberCount, boolean uploaderVerified, List audioStreams, List videoStreams, List relatedStreams, List subtitles, boolean livestream, String hls, String dash, - String lbryId, String category, String license, String visibility, List tags, List chapters, List previewFrames) { + String lbryId, String category, String license, String visibility, List tags, List metaInfo, + List chapters, List previewFrames) { this.title = title; this.description = description; this.uploadDate = uploadDate; @@ -62,6 +65,7 @@ public class Streams { this.category = category; this.license = license; this.tags = tags; + this.metaInfo = metaInfo; this.visibility = visibility; } } diff --git a/testing/api-test.sh b/testing/api-test.sh index b0aee74..df3b9be 100755 --- a/testing/api-test.sh +++ b/testing/api-test.sh @@ -39,6 +39,9 @@ curl "${CURLOPTS[@]}" $HOST/clips/Ugkx71jS31nwsms_Cc65oi7yXF1mILflhhrO || exit 1 # Streams curl "${CURLOPTS[@]}" $HOST/streams/BtN-goy9VOY || exit 1 +# Streams with meta info +curl "${CURLOPTS[@]}" $HOST/streams/cJ9to6EmElQ || exit 1 + # Comments curl "${CURLOPTS[@]}" $HOST/comments/BtN-goy9VOY || exit 1