Merge pull request #1014 from TeamNewPipe/fix/yt-comments

[YouTube] Fix getting next comments pages
This commit is contained in:
Tobi 2023-01-27 11:14:55 +01:00 committed by GitHub
commit c589a2c1a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;