Fix comment reply continuations.
This commit is contained in:
parent
666b45958e
commit
e8e9e6cd00
2 changed files with 9 additions and 12 deletions
|
@ -112,12 +112,6 @@ public class CommentsInfoItemsCollector extends InfoItemsCollector<CommentsInfoI
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CommentsInfoItem> getCommentsInfoItemList() {
|
public List<CommentsInfoItem> getCommentsInfoItemList() {
|
||||||
List<CommentsInfoItem> siiList = new ArrayList<>();
|
return new ArrayList<>(super.getItems());
|
||||||
for (InfoItem ii : super.getItems()) {
|
|
||||||
if (ii instanceof CommentsInfoItem) {
|
|
||||||
siiList.add((CommentsInfoItem) ii);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return siiList;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||||
|
|
||||||
if (itemSectionRenderer.isPresent()) {
|
if (itemSectionRenderer.isPresent()) {
|
||||||
token = JsonUtils.getString(((JsonObject) itemSectionRenderer.get())
|
token = JsonUtils.getString(((JsonObject) itemSectionRenderer.get())
|
||||||
.getObject("itemSectionRenderer").getArray("contents").getObject(0),
|
.getObject("itemSectionRenderer").getArray("contents").getObject(0),
|
||||||
"continuationItemRenderer.continuationEndpoint.continuationCommand.token");
|
"continuationItemRenderer.continuationEndpoint.continuationCommand.token");
|
||||||
} else {
|
} else {
|
||||||
token = null;
|
token = null;
|
||||||
|
@ -140,10 +140,13 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final JsonObject continuationItemRenderer = jsonArray.getObject(jsonArray.size() - 1).getObject("continuationItemRenderer");
|
||||||
|
|
||||||
|
final String jsonPath = continuationItemRenderer.has("button") ? "button.buttonRenderer.command.continuationCommand.token" : "continuationEndpoint.continuationCommand.token";
|
||||||
|
|
||||||
final String continuation;
|
final String continuation;
|
||||||
try {
|
try {
|
||||||
continuation = JsonUtils.getString(jsonArray.getObject(jsonArray.size() - 1),
|
continuation = JsonUtils.getString(continuationItemRenderer, jsonPath);
|
||||||
"continuationItemRenderer.continuationEndpoint.continuationCommand.token");
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +170,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||||
|
|
||||||
final Localization localization = getExtractorLocalization();
|
final Localization localization = getExtractorLocalization();
|
||||||
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(localization,
|
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(localization,
|
||||||
getExtractorContentCountry())
|
getExtractorContentCountry())
|
||||||
.value("continuation", page.getId())
|
.value("continuation", page.getId())
|
||||||
.done())
|
.done())
|
||||||
.getBytes(UTF_8);
|
.getBytes(UTF_8);
|
||||||
|
@ -236,7 +239,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||||
throws IOException, ExtractionException {
|
throws IOException, ExtractionException {
|
||||||
final Localization localization = getExtractorLocalization();
|
final Localization localization = getExtractorLocalization();
|
||||||
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(localization,
|
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(localization,
|
||||||
getExtractorContentCountry())
|
getExtractorContentCountry())
|
||||||
.value("videoId", getId())
|
.value("videoId", getId())
|
||||||
.done())
|
.done())
|
||||||
.getBytes(UTF_8);
|
.getBytes(UTF_8);
|
||||||
|
|
Loading…
Reference in a new issue