Skip to content

Commit

Permalink
feat: support for meta info of videos
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Aug 3, 2023
1 parent 36edf34 commit adacbfe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main/java/me/kavin/piped/utils/CollectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@ public static Streams collectStreamInfo(StreamInfo info) {

final List<ContentItem> relatedStreams = collectRelatedItems(info.getRelatedItems());

final List<MetaInfo> 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<ContentItem> collectRelatedItems(List<? extends InfoItem> items) {
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/me/kavin/piped/utils/obj/MetaInfo.java
Original file line number Diff line number Diff line change
@@ -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<URL> urls;
public List<String> urlTexts;

public MetaInfo(String title, String description, List<URL> urls, List<String> urlTexts) {
this.title = title;
this.description = description;
this.urls = urls;
this.urlTexts = urlTexts;
}
}
6 changes: 5 additions & 1 deletion src/main/java/me/kavin/piped/utils/obj/Streams.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class Streams {

public List<String> tags;

public List<MetaInfo> metaInfo;

public boolean uploaderVerified;

public long duration, views, likes, dislikes, uploaderSubscriberCount;
Expand All @@ -35,7 +37,8 @@ public Streams(String title, String description, String uploadDate, String uploa
String uploaderAvatar, String thumbnailUrl, long duration, long views, long likes, long dislikes, long uploaderSubscriberCount,
boolean uploaderVerified, List<PipedStream> audioStreams, List<PipedStream> videoStreams,
List<ContentItem> relatedStreams, List<Subtitle> subtitles, boolean livestream, String hls, String dash,
String lbryId, String category, String license, String visibility, List<String> tags, List<ChapterSegment> chapters, List<PreviewFrames> previewFrames) {
String lbryId, String category, String license, String visibility, List<String> tags, List<MetaInfo> metaInfo,
List<ChapterSegment> chapters, List<PreviewFrames> previewFrames) {
this.title = title;
this.description = description;
this.uploadDate = uploadDate;
Expand All @@ -62,6 +65,7 @@ public Streams(String title, String description, String uploadDate, String uploa
this.category = category;
this.license = license;
this.tags = tags;
this.metaInfo = metaInfo;
this.visibility = visibility;
}
}
3 changes: 3 additions & 0 deletions testing/api-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit adacbfe

Please sign in to comment.