From f7f727d19c998753da7c47e4e4cc2bee0c5b8d2a Mon Sep 17 00:00:00 2001 From: TobiGr Date: Sun, 6 Jun 2021 11:24:22 +0200 Subject: [PATCH] Add constant NO_LIKE_COUNT to CommentsInfoItem --- .../newpipe/extractor/comments/CommentsInfoItem.java | 5 +++++ .../extractor/comments/CommentsInfoItemExtractor.java | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java index f32710603..822069b39 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java @@ -22,6 +22,7 @@ public class CommentsInfoItem extends InfoItem { private boolean pinned; private int streamPosition; + public static final int NO_LIKE_COUNT = -1; public static final int NO_STREAM_POSITION = -1; public CommentsInfoItem(int serviceId, String url, String name) { @@ -85,6 +86,10 @@ public class CommentsInfoItem extends InfoItem { this.uploadDate = uploadDate; } + /** + * @return the comment's like count + * or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is unavailable + */ public int getLikeCount() { return likeCount; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java index fb1af7ab0..4d70bf87d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java @@ -12,15 +12,20 @@ import javax.annotation.Nullable; public interface CommentsInfoItemExtractor extends InfoItemExtractor { /** - * Return the like count of the comment, or -1 if it's unavailable + * Return the like count of the comment, + * or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is unavailable. + * *
+ * * NOTE: Currently only implemented for YT {@link YoutubeCommentsInfoItemExtractor#getLikeCount()} * with limitations (only approximate like count is returned) * * @see StreamExtractor#getLikeCount() + * @return the comment's like count + * or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is unavailable */ default int getLikeCount() throws ParsingException { - return -1; + return CommentsInfoItem.NO_LIKE_COUNT; } /**