mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-28 16:00:33 +05:30
Improve PeertubeCommentsInfoItemExtractor constructor
This commit is contained in:
parent
aff3e795f8
commit
d358ba1c41
@ -54,7 +54,7 @@ public class PeertubeCommentsExtractor extends CommentsExtractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isReply() throws ParsingException {
|
private boolean isReply() throws ParsingException {
|
||||||
if (isReply == null) {
|
if (isReply == null) {
|
||||||
if (getOriginalUrl().contains("/videos/watch/")) {
|
if (getOriginalUrl().contains("/videos/watch/")) {
|
||||||
isReply = false;
|
isReply = false;
|
||||||
@ -73,7 +73,8 @@ public class PeertubeCommentsExtractor extends CommentsExtractor {
|
|||||||
if (c instanceof JsonObject) {
|
if (c instanceof JsonObject) {
|
||||||
final JsonObject item = (JsonObject) c;
|
final JsonObject item = (JsonObject) c;
|
||||||
if (!item.getBoolean(IS_DELETED)) {
|
if (!item.getBoolean(IS_DELETED)) {
|
||||||
collector.commit(new PeertubeCommentsInfoItemExtractor(item, null, this));
|
collector.commit(new PeertubeCommentsInfoItemExtractor(
|
||||||
|
item, null, getUrl(), getBaseUrl(), isReply()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +90,8 @@ public class PeertubeCommentsExtractor extends CommentsExtractor {
|
|||||||
final JsonObject item = content.getObject("comment");
|
final JsonObject item = content.getObject("comment");
|
||||||
final JsonArray children = content.getArray(CHILDREN);
|
final JsonArray children = content.getArray(CHILDREN);
|
||||||
if (!item.getBoolean(IS_DELETED)) {
|
if (!item.getBoolean(IS_DELETED)) {
|
||||||
collector.commit(new PeertubeCommentsInfoItemExtractor(item, children, this));
|
collector.commit(new PeertubeCommentsInfoItemExtractor(
|
||||||
|
item, children, getUrl(), getBaseUrl(), isReply()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,20 +31,20 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
|
|||||||
private final String url;
|
private final String url;
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final String baseUrl;
|
private final String baseUrl;
|
||||||
@Nonnull
|
private final boolean isReply;
|
||||||
private final PeertubeCommentsExtractor superCommentExtractor;
|
|
||||||
|
|
||||||
private Integer replyCount;
|
private Integer replyCount;
|
||||||
|
|
||||||
public PeertubeCommentsInfoItemExtractor(@Nonnull final JsonObject item,
|
public PeertubeCommentsInfoItemExtractor(@Nonnull final JsonObject item,
|
||||||
@Nullable final JsonArray children,
|
@Nullable final JsonArray children,
|
||||||
@Nonnull final PeertubeCommentsExtractor extractor)
|
@Nonnull final String url,
|
||||||
throws ParsingException {
|
@Nonnull final String baseUrl,
|
||||||
|
final boolean isReply) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.children = children;
|
this.children = children;
|
||||||
this.url = extractor.getUrl();
|
this.url = url;
|
||||||
this.baseUrl = extractor.getBaseUrl();
|
this.baseUrl = baseUrl;
|
||||||
this.superCommentExtractor = extractor;
|
this.isReply = isReply;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -130,7 +130,7 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
|
|||||||
}
|
}
|
||||||
final String threadId = JsonUtils.getNumber(item, "threadId").toString();
|
final String threadId = JsonUtils.getNumber(item, "threadId").toString();
|
||||||
final String repliesUrl = url + "/" + threadId;
|
final String repliesUrl = url + "/" + threadId;
|
||||||
if (superCommentExtractor.isReply() && children != null && !children.isEmpty()) {
|
if (isReply && children != null && !children.isEmpty()) {
|
||||||
// Nested replies are already included in the original thread's request.
|
// Nested replies are already included in the original thread's request.
|
||||||
// Wrap the replies into a JsonObject, because the original thread's request body
|
// Wrap the replies into a JsonObject, because the original thread's request body
|
||||||
// is also structured like a JsonObject.
|
// is also structured like a JsonObject.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user