From b2c9ffa789d777801bc1ac91e736eecc67d84c8d Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Fri, 3 Sep 2021 22:01:26 +0530 Subject: [PATCH] Update NewPipeExtractor and extract more info. --- build.gradle | 2 +- .../me/kavin/piped/utils/ResponseHelper.java | 23 ++++++++++++------- .../me/kavin/piped/utils/obj/StreamItem.java | 5 ++-- .../me/kavin/piped/utils/obj/Streams.java | 8 +++++-- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 78cd5a5..78d59e6 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ dependencies { implementation 'it.unimi.dsi:fastutil-core:8.5.4' implementation 'commons-codec:commons-codec:1.15' implementation 'org.bouncycastle:bcprov-jdk15on:1.69' - implementation 'com.github.TeamNewPipe:NewPipeExtractor:d8179dc35ae036bfd6e450a7050e998e0f1b041f' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:f0aa46b008f2256b3e86a2182d53854fce1f8cb7' implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751' implementation 'com.fasterxml.jackson.core:jackson-core:2.12.5' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.12.5' diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index fe9b24a..863ee3f 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -176,7 +176,8 @@ public class ResponseHelper { StreamInfoItem item = (StreamInfoItem) o; relatedStreams.add(new StreamItem(item.getUrl().substring(23), item.getName(), rewriteURL(item.getThumbnailUrl()), item.getUploaderName(), item.getUploaderUrl().substring(23), - item.getTextualUploadDate(), item.getDuration(), item.getViewCount(), item.isUploaderVerified())); + rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), item.getDuration(), + item.getViewCount(), item.isUploaderVerified())); }); List segments = new ObjectArrayList<>(); @@ -193,8 +194,9 @@ public class ResponseHelper { final Streams streams = new Streams(info.getName(), info.getDescription().getContent(), info.getTextualUploadDate(), info.getUploaderName(), info.getUploaderUrl().substring(23), rewriteURL(info.getUploaderAvatarUrl()), rewriteURL(info.getThumbnailUrl()), info.getDuration(), - info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), audioStreams, videoStreams, - relatedStreams, subtitles, livestream, hls, info.getDashMpdUrl(), futureLbryId.get()); + info.getViewCount(), info.getLikeCount(), info.getDislikeCount(), info.isUploaderVerified(), + audioStreams, videoStreams, relatedStreams, subtitles, livestream, hls, info.getDashMpdUrl(), + futureLbryId.get()); return Constants.mapper.writeValueAsBytes(streams); @@ -210,7 +212,8 @@ public class ResponseHelper { StreamInfoItem item = o; relatedStreams.add(new StreamItem(item.getUrl().substring(23), item.getName(), rewriteURL(item.getThumbnailUrl()), item.getUploaderName(), item.getUploaderUrl().substring(23), - item.getTextualUploadDate(), item.getDuration(), item.getViewCount(), item.isUploaderVerified())); + rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), item.getDuration(), + item.getViewCount(), item.isUploaderVerified())); }); Multithreading.runAsync(() -> { @@ -269,7 +272,8 @@ public class ResponseHelper { StreamInfoItem item = o; relatedStreams.add(new StreamItem(item.getUrl().substring(23), item.getName(), rewriteURL(item.getThumbnailUrl()), item.getUploaderName(), item.getUploaderUrl().substring(23), - item.getTextualUploadDate(), item.getDuration(), item.getViewCount(), item.isUploaderVerified())); + rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), item.getDuration(), + item.getViewCount(), item.isUploaderVerified())); }); String nextpage = null; @@ -302,7 +306,8 @@ public class ResponseHelper { StreamInfoItem item = o; relatedStreams.add(new StreamItem(item.getUrl().substring(23), item.getName(), rewriteURL(item.getThumbnailUrl()), item.getUploaderName(), item.getUploaderUrl().substring(23), - item.getTextualUploadDate(), item.getDuration(), item.getViewCount(), item.isUploaderVerified())); + rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), item.getDuration(), + item.getViewCount(), item.isUploaderVerified())); }); return Constants.mapper.writeValueAsBytes(relatedStreams); @@ -319,7 +324,8 @@ public class ResponseHelper { StreamInfoItem item = o; relatedStreams.add(new StreamItem(item.getUrl().substring(23), item.getName(), rewriteURL(item.getThumbnailUrl()), item.getUploaderName(), item.getUploaderUrl().substring(23), - item.getTextualUploadDate(), item.getDuration(), item.getViewCount(), item.isUploaderVerified())); + rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), item.getDuration(), + item.getViewCount(), item.isUploaderVerified())); }); String nextpage = null; @@ -352,7 +358,8 @@ public class ResponseHelper { StreamInfoItem item = o; relatedStreams.add(new StreamItem(item.getUrl().substring(23), item.getName(), rewriteURL(item.getThumbnailUrl()), item.getUploaderName(), item.getUploaderUrl().substring(23), - item.getTextualUploadDate(), item.getDuration(), item.getViewCount(), item.isUploaderVerified())); + rewriteURL(item.getUploaderAvatarUrl()), item.getTextualUploadDate(), item.getDuration(), + item.getViewCount(), item.isUploaderVerified())); }); String nextpage = null; diff --git a/src/main/java/me/kavin/piped/utils/obj/StreamItem.java b/src/main/java/me/kavin/piped/utils/obj/StreamItem.java index 2ac2795..889aae6 100644 --- a/src/main/java/me/kavin/piped/utils/obj/StreamItem.java +++ b/src/main/java/me/kavin/piped/utils/obj/StreamItem.java @@ -2,17 +2,18 @@ package me.kavin.piped.utils.obj; public class StreamItem { - public String url, title, thumbnail, uploaderName, uploaderUrl, uploadedDate; + public String url, title, thumbnail, uploaderName, uploaderUrl, uploaderAvatarUrl, uploadedDate; public long duration, views; public boolean uploaderVerified; public StreamItem(String url, String title, String thumbnail, String uploaderName, String uploaderUrl, - String uploadedDate, long duration, long views, boolean uploaderVerified) { + String uploaderAvatarUrl, String uploadedDate, long duration, long views, boolean uploaderVerified) { this.url = url; this.title = title; this.thumbnail = thumbnail; this.uploaderName = uploaderName; this.uploaderUrl = uploaderUrl; + this.uploaderAvatarUrl = uploaderAvatarUrl; this.uploadedDate = uploadedDate; this.duration = duration; this.views = views; 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 aa614b3..b8fca4d 100644 --- a/src/main/java/me/kavin/piped/utils/obj/Streams.java +++ b/src/main/java/me/kavin/piped/utils/obj/Streams.java @@ -9,6 +9,8 @@ public class Streams { public String title, description, uploadDate, uploader, uploaderUrl, uploaderAvatar, thumbnailUrl, hls, dash, lbryId; + public boolean uploaderVerified; + public long duration, views, likes, dislikes; public List audioStreams, videoStreams; @@ -23,8 +25,9 @@ public class Streams { public Streams(String title, String description, String uploadDate, String uploader, String uploaderUrl, String uploaderAvatar, String thumbnailUrl, long duration, long views, long likes, long dislikes, - List audioStreams, List videoStreams, List relatedStreams, - List subtitles, boolean livestream, String hls, String dash, String lbryId) { + boolean uploaderVerified, List audioStreams, List videoStreams, + List relatedStreams, List subtitles, boolean livestream, String hls, String dash, + String lbryId) { this.title = title; this.description = description; this.uploadDate = uploadDate; @@ -36,6 +39,7 @@ public class Streams { this.views = views; this.likes = likes; this.dislikes = dislikes; + this.uploaderVerified = uploaderVerified; this.audioStreams = audioStreams; this.videoStreams = videoStreams; this.relatedStreams = relatedStreams;