From 4b4c7e869a22d22fc7a52ad76cf2ed36c8667a17 Mon Sep 17 00:00:00 2001 From: xz-dev Date: Tue, 27 Sep 2022 03:22:52 +0800 Subject: [PATCH] Use UNKNOWN_REPLY_COUNT everywhere --- .../youtube/extractors/YoutubeCommentsInfoItemExtractor.java | 3 ++- .../services/youtube/YoutubeCommentsExtractorTest.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsInfoItemExtractor.java index 9c3db6f02..83006efa5 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeCommentsInfoItemExtractor.java @@ -1,5 +1,6 @@ package org.schabi.newpipe.extractor.services.youtube.extractors; +import static org.schabi.newpipe.extractor.comments.CommentsInfoItem.UNKNOWN_REPLY_COUNT; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject; import com.grack.nanojson.JsonArray; @@ -253,7 +254,7 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract try { return JsonUtils.getNumber(json, "comment.commentRenderer.replyCount").intValue(); } catch (final Exception e) { - return -1; + return UNKNOWN_REPLY_COUNT; } } 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 1a3bc211c..7bb812555 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 @@ -5,7 +5,9 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertGreater; import static org.schabi.newpipe.extractor.ServiceList.YouTube; +import static org.schabi.newpipe.extractor.comments.CommentsInfoItem.UNKNOWN_REPLY_COUNT; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -338,9 +340,8 @@ public class YoutubeCommentsExtractorTest { CommentsInfoItem firstComment = comments.getItems().get(0); - assertNotEquals(-1, firstComment.getReplyCount(), "First reply comment can't get count"); + assertNotEquals(UNKNOWN_REPLY_COUNT, firstComment.getReplyCount(), "First reply comment can't get count"); assertGreater(300, firstComment.getReplyCount(), "First reply comment count is smaller than the expected 300 comments"); - } } }