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 06ce84c44..965a55753 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,6 +17,7 @@ public class CommentsInfoItem extends InfoItem { private DateWrapper uploadDate; private int likeCount; private boolean heartedByUploader; + private boolean pinned; public CommentsInfoItem(int serviceId, String url, String name) { super(InfoType.COMMENT, serviceId, url, name); @@ -94,4 +95,12 @@ public class CommentsInfoItem extends InfoItem { public boolean getHeartedByUploader() { return this.heartedByUploader; } + + public boolean getPinned() { + return pinned; + } + + public void setPinned(boolean pinned) { + this.pinned = pinned; + } } 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 ff56204f2..ae93ac892 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 @@ -11,6 +11,7 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor { /** * Return the like count of the comment, or -1 if it's unavailable + * * @see StreamExtractor#getLikeCount() */ int getLikeCount() throws ParsingException; @@ -22,12 +23,14 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor { /** * The upload date given by the service, unmodified + * * @see StreamExtractor#getTextualUploadDate() */ String getTextualUploadDate() throws ParsingException; /** * The upload date wrapped with DateWrapper class + * * @see StreamExtractor#getUploadDate() */ @Nullable @@ -45,4 +48,9 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor { * Whether the comment has been hearted by the uploader */ boolean getHeartedByUploader() throws ParsingException; + + /** + * Whether the comment is pinned + */ + boolean getPinned() throws ParsingException; } 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 3323f00b8..c84c2fa7f 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 @@ -76,6 +76,12 @@ public class CommentsInfoItemsCollector extends InfoItemsCollector comments = extractor.getInitialPage(); + + DefaultTests.defaultTestListOfItems(YouTube, comments.getItems(), comments.getErrors()); + + for (CommentsInfoItem c : comments.getItems()) { + assertFalse(Utils.isBlank(c.getUploaderUrl())); + assertFalse(Utils.isBlank(c.getUploaderName())); + assertFalse(Utils.isBlank(c.getUploaderAvatarUrl())); + assertFalse(Utils.isBlank(c.getCommentId())); + assertFalse(Utils.isBlank(c.getName())); + assertFalse(Utils.isBlank(c.getTextualUploadDate())); + assertNotNull(c.getUploadDate()); + assertFalse(Utils.isBlank(c.getThumbnailUrl())); + assertFalse(Utils.isBlank(c.getUrl())); + assertFalse(c.getLikeCount() < 0); + assertFalse(Utils.isBlank(c.getCommentText())); + } + + assertTrue("First comment isn't pinned", comments.getItems().get(0).getPinned()); + } + } }