From 1c73f852b9ef785b50b1126063f0ff5a6ce09628 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sat, 29 Oct 2022 23:30:47 +0100 Subject: [PATCH] Implement support for uploaderUrl and uploaderVerified for playlists. --- build.gradle | 2 +- .../me/kavin/piped/utils/CollectionUtils.java | 35 ++++++++++++------- .../kavin/piped/utils/obj/PlaylistItem.java | 8 ++++- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 695a72d..1bf8f54 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ dependencies { implementation 'it.unimi.dsi:fastutil-core:8.5.9' implementation 'commons-codec:commons-codec:1.15' implementation 'org.bouncycastle:bcprov-jdk15on:1.70' - implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:da15ba74793254079123fee984154b2697d4a992' + implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:389ec4bd58b8b18ea0296cb63e156c524cfc3fe0' implementation 'com.github.FireMasterK:nanojson:5df3e81e87b791d01f132f376e4b7d4a1780f346' implementation 'com.fasterxml.jackson.core:jackson-core:2.13.4' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.4' diff --git a/src/main/java/me/kavin/piped/utils/CollectionUtils.java b/src/main/java/me/kavin/piped/utils/CollectionUtils.java index 1537706..bdaf1e3 100644 --- a/src/main/java/me/kavin/piped/utils/CollectionUtils.java +++ b/src/main/java/me/kavin/piped/utils/CollectionUtils.java @@ -21,14 +21,16 @@ public class CollectionUtils { .stream() .parallel() .map(item -> { - if (item instanceof StreamInfoItem) + if (item instanceof StreamInfoItem) { return collectRelatedStream(item); - else if (item instanceof PlaylistInfoItem) + } else if (item instanceof PlaylistInfoItem) { return collectRelatedPlaylist(item); - else if (item instanceof ChannelInfoItem) + } else if (item instanceof ChannelInfoItem) { return collectRelatedChannel(item); - else - throw new RuntimeException("Unknown item type: " + item.getClass().getName()); + } else { + throw new RuntimeException( + "Unknown item type: " + item.getClass().getName()); + } }).toList(); } @@ -36,25 +38,34 @@ public class CollectionUtils { StreamInfoItem item = (StreamInfoItem) o; - return new StreamItem(substringYouTube(item.getUrl()), item.getName(), rewriteURL(item.getThumbnailUrl()), + return new StreamItem(substringYouTube(item.getUrl()), item.getName(), + rewriteURL(item.getThumbnailUrl()), item.getUploaderName(), substringYouTube(item.getUploaderUrl()), - rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), item.getShortDescription(), item.getDuration(), - item.getViewCount(), item.getUploadDate() != null ? item.getUploadDate().offsetDateTime().toInstant().toEpochMilli() : -1, item.isUploaderVerified(), item.isShortFormContent()); + rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), + item.getShortDescription(), item.getDuration(), + item.getViewCount(), item.getUploadDate() != null ? + item.getUploadDate().offsetDateTime().toInstant().toEpochMilli() : -1, + item.isUploaderVerified(), item.isShortFormContent()); } private static PlaylistItem collectRelatedPlaylist(Object o) { PlaylistInfoItem item = (PlaylistInfoItem) o; - return new PlaylistItem(substringYouTube(item.getUrl()), item.getName(), rewriteURL(item.getThumbnailUrl()), - item.getUploaderName(), item.getPlaylistType().name(), item.getStreamCount()); + return new PlaylistItem(substringYouTube(item.getUrl()), item.getName(), + rewriteURL(item.getThumbnailUrl()), + item.getUploaderName(), substringYouTube(item.getUploaderUrl()), + item.isUploaderVerified(), + item.getPlaylistType().name(), item.getStreamCount()); } private static ChannelItem collectRelatedChannel(Object o) { ChannelInfoItem item = (ChannelInfoItem) o; - return new ChannelItem(substringYouTube(item.getUrl()), item.getName(), rewriteURL(item.getThumbnailUrl()), - item.getDescription(), item.getSubscriberCount(), item.getStreamCount(), item.isVerified()); + return new ChannelItem(substringYouTube(item.getUrl()), item.getName(), + rewriteURL(item.getThumbnailUrl()), + item.getDescription(), item.getSubscriberCount(), item.getStreamCount(), + item.isVerified()); } } diff --git a/src/main/java/me/kavin/piped/utils/obj/PlaylistItem.java b/src/main/java/me/kavin/piped/utils/obj/PlaylistItem.java index 9e8f024..31b6a16 100644 --- a/src/main/java/me/kavin/piped/utils/obj/PlaylistItem.java +++ b/src/main/java/me/kavin/piped/utils/obj/PlaylistItem.java @@ -7,16 +7,22 @@ public class PlaylistItem extends ContentItem { public String name; public String thumbnail; public String uploaderName; + public String uploaderUrl; + public boolean uploaderVerified; public String playlistType; public long videos; - public PlaylistItem(String url, String name, String thumbnail, String uploaderName, String playlistType, long videos) { + public PlaylistItem(String url, String name, String thumbnail, String uploaderName, + String uploaderUrl, boolean uploaderVerified, String playlistType, + long videos) { super(url); this.name = name; this.thumbnail = thumbnail; this.uploaderName = uploaderName; + this.uploaderUrl = uploaderUrl; + this.uploaderVerified = uploaderVerified; this.playlistType = playlistType; this.videos = videos; }