From f50b7275affa7c3186bdefeb98075babcf09ce04 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 24 Jan 2023 22:39:08 +0100 Subject: [PATCH] [YouTube] Fix getting next comments pages --- .../youtube/extractors/YoutubeCommentsExtractor.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java index 4581afcb..385ee6eb 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsExtractor.java @@ -179,7 +179,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor { .getBytes(StandardCharsets.UTF_8); // @formatter:on - final var jsonObject = getJsonPostResponse("next", body, localization); + final JsonObject jsonObject = getJsonPostResponse("next", body, localization); return extractComments(jsonObject); } @@ -188,15 +188,16 @@ public class YoutubeCommentsExtractor extends CommentsExtractor { throws ExtractionException { final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector( getServiceId()); - collectCommentsFrom(collector); + collectCommentsFrom(collector, jsonObject); return new InfoItemsPage<>(collector, getNextPage(jsonObject)); } - private void collectCommentsFrom(final CommentsInfoItemsCollector collector) + private void collectCommentsFrom(final CommentsInfoItemsCollector collector, + final JsonObject jsonObject) throws ParsingException { final JsonArray onResponseReceivedEndpoints = - ajaxJson.getArray("onResponseReceivedEndpoints"); + jsonObject.getArray("onResponseReceivedEndpoints"); // Prevent ArrayIndexOutOfBoundsException if (onResponseReceivedEndpoints.isEmpty()) { return;