[YouTube] Fix getting next comments pages

This commit is contained in:
TobiGr 2023-01-24 22:39:08 +01:00
parent ff94e9f30b
commit f50b7275af
1 changed files with 5 additions and 4 deletions

View File

@ -179,7 +179,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
.getBytes(StandardCharsets.UTF_8); .getBytes(StandardCharsets.UTF_8);
// @formatter:on // @formatter:on
final var jsonObject = getJsonPostResponse("next", body, localization); final JsonObject jsonObject = getJsonPostResponse("next", body, localization);
return extractComments(jsonObject); return extractComments(jsonObject);
} }
@ -188,15 +188,16 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
throws ExtractionException { throws ExtractionException {
final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector( final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector(
getServiceId()); getServiceId());
collectCommentsFrom(collector); collectCommentsFrom(collector, jsonObject);
return new InfoItemsPage<>(collector, getNextPage(jsonObject)); return new InfoItemsPage<>(collector, getNextPage(jsonObject));
} }
private void collectCommentsFrom(final CommentsInfoItemsCollector collector) private void collectCommentsFrom(final CommentsInfoItemsCollector collector,
final JsonObject jsonObject)
throws ParsingException { throws ParsingException {
final JsonArray onResponseReceivedEndpoints = final JsonArray onResponseReceivedEndpoints =
ajaxJson.getArray("onResponseReceivedEndpoints"); jsonObject.getArray("onResponseReceivedEndpoints");
// Prevent ArrayIndexOutOfBoundsException // Prevent ArrayIndexOutOfBoundsException
if (onResponseReceivedEndpoints.isEmpty()) { if (onResponseReceivedEndpoints.isEmpty()) {
return; return;