From 8e9547ef8d947027a3cc6afa0c0f0c01504afb98 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Tue, 30 Mar 2021 14:52:36 +0530 Subject: [PATCH] Fix channel continuation. --- .../java/me/kavin/piped/utils/ResponseHelper.java | 13 +++++++++---- .../java/me/kavin/piped/utils/obj/StreamsPage.java | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index b472cce..ff8c410 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -188,21 +188,26 @@ public class ResponseHelper { public static final byte[] channelPageResponse(String channelId, String url, String id) throws IOException, ExtractionException, InterruptedException { - InfoItemsPage page = ChannelInfo.getMoreItems(Constants.YOUTUBE_SERVICE, + InfoItemsPage info = ChannelInfo.getMoreItems(Constants.YOUTUBE_SERVICE, "https://youtube.com/channel/" + channelId, new Page(url, id)); final List relatedStreams = new ObjectArrayList<>(); - page.getItems().forEach(o -> { + info.getItems().forEach(o -> { 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())); }); - String nextpage = page.hasNextPage() ? page.getNextPage().getUrl() : null; + String nextpage = null, next_id = null; + if (info.hasNextPage()) { + Page page = info.getNextPage(); + nextpage = page.getUrl(); + id = info.getNextPage().getId(); + } - final StreamsPage streamspage = new StreamsPage(nextpage, relatedStreams); + final StreamsPage streamspage = new StreamsPage(nextpage, next_id, relatedStreams); return Constants.mapper.writeValueAsBytes(streamspage); diff --git a/src/main/java/me/kavin/piped/utils/obj/StreamsPage.java b/src/main/java/me/kavin/piped/utils/obj/StreamsPage.java index e6d729c..96fee19 100644 --- a/src/main/java/me/kavin/piped/utils/obj/StreamsPage.java +++ b/src/main/java/me/kavin/piped/utils/obj/StreamsPage.java @@ -4,11 +4,12 @@ import java.util.List; public class StreamsPage { - public String nextpage; + public String nextpage, nextid; public List relatedStreams; - public StreamsPage(String nextpage, List relatedStreams) { + public StreamsPage(String nextpage, String nextid, List relatedStreams) { this.nextpage = nextpage; + this.nextid = nextid; this.relatedStreams = relatedStreams; } }