From e81b0e28856ac7f3fd5db979c55b14832dc34894 Mon Sep 17 00:00:00 2001
From: litetex <40789489+litetex@users.noreply.github.com>
Date: Thu, 27 May 2021 19:48:31 +0200
Subject: [PATCH] Tweaked code
---
.../extractor/comments/CommentsInfoItem.java | 10 +++++-----
.../comments/CommentsInfoItemExtractor.java | 12 +++++++-----
.../comments/CommentsInfoItemsCollector.java | 2 +-
.../YoutubeCommentsInfoItemExtractor.java | 13 +++++++------
.../bandcamp/BandcampCommentsExtractorTest.java | 2 +-
.../peertube/PeertubeCommentsExtractorTest.java | 2 +-
.../youtube/YoutubeCommentsExtractorTest.java | 4 ++--
7 files changed, 24 insertions(+), 21 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 fd66b0053..d27909276 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
@@ -17,7 +17,7 @@ public class CommentsInfoItem extends InfoItem {
@Nullable
private DateWrapper uploadDate;
private int likeCount;
- private String textualVoteCount;
+ private String textualLikeCount;
private boolean heartedByUploader;
private boolean pinned;
@@ -90,12 +90,12 @@ public class CommentsInfoItem extends InfoItem {
this.likeCount = likeCount;
}
- public String getTextualVoteCount() {
- return textualVoteCount;
+ public String getTextualLikeCount() {
+ return textualLikeCount;
}
- public void setTextualVoteCount(String textualVoteCount) {
- this.textualVoteCount = textualVoteCount;
+ public void setTextualLikeCount(String textualLikeCount) {
+ this.textualLikeCount = textualLikeCount;
}
public void setHeartedByUploader(boolean isHeartedByUploader) {
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 1daef214d..8d844d4fe 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,9 +12,10 @@ import javax.annotation.Nullable;
public interface CommentsInfoItemExtractor extends InfoItemExtractor {
/**
- * Return the (approximate) like count of the comment, or -1 if it's unavailable
+ * Return the like count of the comment, or -1 if it's unavailable
+ *
* NOTE: Currently only implemented for YT {@link YoutubeCommentsInfoItemExtractor#getLikeCount()}
- * with limitations
+ * with limitations (only approximate like count is returned)
*
* @see StreamExtractor#getLikeCount()
*/
@@ -23,10 +24,11 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
}
/**
- * The formatted text (e.g. 420, 4K, 4.2M) of the votes
- * May be language dependent
+ * The unmodified like count given by the service
+ *
+ * It may be language dependent
*/
- default String getTextualVoteCount() throws ParsingException {
+ default String getTextualLikeCount() throws ParsingException {
return Utils.EMPTY_STRING;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
index d87ea0a11..97d394e10 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
@@ -65,7 +65,7 @@ public class CommentsInfoItemsCollector extends InfoItemsCollector
*
*
- * Consider using {@link #getTextualVoteCount()}
+ * Consider using {@link #getTextualLikeCount()}
*/
@Override
public int getLikeCount() throws ParsingException {
+ json.getInt("");
// This may return a language dependent version, e.g. in German: 3,3 Mio
- String voteCount = getTextualVoteCount();
+ final String textualLikeCount = getTextualLikeCount();
try {
- if (Utils.isBlank(voteCount)) {
+ if (Utils.isBlank(textualLikeCount)) {
return 0;
}
- return (int) Utils.mixedNumberWordToLong(voteCount);
+ return (int) Utils.mixedNumberWordToLong(textualLikeCount);
} catch (Exception e) {
- throw new ParsingException("Unexpected error while converting vote count to like count", e);
+ throw new ParsingException("Unexpected error while converting textual like count to like count", e);
}
}
@Override
- public String getTextualVoteCount() throws ParsingException {
+ public String getTextualLikeCount() throws ParsingException {
/*
* Example results as of 2021-05-20:
* Language = English
diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java
index 37d2aa967..6f2676ad1 100644
--- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java
+++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java
@@ -47,7 +47,7 @@ public class BandcampCommentsExtractorTest {
assertFalse(Utils.isBlank(c.getThumbnailUrl()));
assertFalse(Utils.isBlank(c.getUrl()));
assertEquals(-1, c.getLikeCount());
- assertTrue(Utils.isBlank(c.getTextualVoteCount()));
+ assertTrue(Utils.isBlank(c.getTextualLikeCount()));
}
}
}
diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java
index 87fe6a500..32742a761 100644
--- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java
+++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java
@@ -76,7 +76,7 @@ public class PeertubeCommentsExtractorTest {
assertFalse(Utils.isBlank(c.getThumbnailUrl()));
assertFalse(Utils.isBlank(c.getUrl()));
assertEquals(-1, c.getLikeCount());
- assertTrue(Utils.isBlank(c.getTextualVoteCount()));
+ assertTrue(Utils.isBlank(c.getTextualLikeCount()));
}
}
diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java
index 3f73be418..22819c7f5 100644
--- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java
+++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java
@@ -270,7 +270,7 @@ public class YoutubeCommentsExtractorTest {
assertTrue("First comment isn't pinned", pinnedComment.isPinned());
assertTrue("The first pinned comment has no likes", pinnedComment.getLikeCount() > 0);
- assertTrue("The first pinned comment has no vote count", !Utils.isBlank(pinnedComment.getTextualVoteCount()));
+ assertTrue("The first pinned comment has no vote count", !Utils.isBlank(pinnedComment.getTextualLikeCount()));
}
}
@@ -303,7 +303,7 @@ public class YoutubeCommentsExtractorTest {
CommentsInfoItem pinnedComment = comments.getItems().get(0);
assertTrue("First comment isn't pinned", pinnedComment.isPinned());
- assertTrue("The first pinned comment has no vote count", !Utils.isBlank(pinnedComment.getTextualVoteCount()));
+ assertTrue("The first pinned comment has no vote count", !Utils.isBlank(pinnedComment.getTextualLikeCount()));
}
}
}