Skip to content

Commit 4385cc1

Browse files
committed
Add comment replies.
1 parent 8ca5e5e commit 4385cc1

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.schabi.newpipe.extractor.comments;
22

33
import org.schabi.newpipe.extractor.InfoItemExtractor;
4+
import org.schabi.newpipe.extractor.Page;
45
import org.schabi.newpipe.extractor.exceptions.ParsingException;
56
import org.schabi.newpipe.extractor.localization.DateWrapper;
67
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeCommentsInfoItemExtractor;
@@ -107,4 +108,13 @@ default boolean isUploaderVerified() throws ParsingException {
107108
default int getStreamPosition() throws ParsingException {
108109
return CommentsInfoItem.NO_STREAM_POSITION;
109110
}
111+
112+
/**
113+
* The continuation page which is used to get comment replies from.
114+
* @return the continuation Page for the replies
115+
*/
116+
@Nullable
117+
default Page getReplies() throws ParsingException {
118+
return null;
119+
}
110120
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsInfoItemExtractor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.grack.nanojson.JsonArray;
44
import com.grack.nanojson.JsonObject;
55

6+
import org.schabi.newpipe.extractor.Page;
67
import org.schabi.newpipe.extractor.comments.CommentsInfoItemExtractor;
78
import org.schabi.newpipe.extractor.exceptions.ParsingException;
89
import org.schabi.newpipe.extractor.localization.DateWrapper;
@@ -230,4 +231,14 @@ public String getUploaderUrl() throws ParsingException {
230231
return EMPTY_STRING;
231232
}
232233
}
234+
235+
@Override
236+
public Page getReplies() throws ParsingException {
237+
try {
238+
final String id = JsonUtils.getString(JsonUtils.getArray(json, "replies.commentRepliesRenderer.contents").getObject(0), "continuationItemRenderer.continuationEndpoint.continuationCommand.token");
239+
return new Page(url, id);
240+
} catch (final Exception e) {
241+
return null;
242+
}
243+
}
233244
}

0 commit comments

Comments
 (0)