Use UNKNOWN_REPLY_COUNT everywhere

This commit is contained in:
xz-dev 2022-09-27 03:22:52 +08:00
parent 659d6aef4a
commit 4b4c7e869a
No known key found for this signature in database
GPG Key ID: A20912F811313E36
2 changed files with 5 additions and 3 deletions

View File

@ -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;
}
}

View File

@ -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");
}
}
}