removed commentsInfo from streamInfo

This commit is contained in:
Ritvik Saraf
2018-09-22 23:36:41 +05:30
parent 7ed0da0493
commit 0e86475891
3 changed files with 26 additions and 95 deletions

View File

@@ -6,6 +6,7 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import java.io.IOException;
import java.util.List;
import org.jsoup.helper.StringUtil;
import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.Downloader;
@@ -15,7 +16,6 @@ import org.schabi.newpipe.extractor.comments.CommentsInfo;
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeCommentsExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfo;
public class YoutubeCommentsExtractorTest {
@@ -41,32 +41,19 @@ public class YoutubeCommentsExtractorTest {
assertTrue(result);
}
@Test
public void testGetCommentsFromStreamInfo() throws IOException, ExtractionException {
boolean result = false;
StreamInfo streamInfo = StreamInfo.getInfo("https://www.youtube.com/watch?v=rrgFN3AxGfs");
result = findInComments(streamInfo.getCommentsInfo().getComments(), "i should really be in the top comment.lol");
while (streamInfo.getCommentsInfo().hasMoreComments() && !result) {
CommentsInfo.loadMoreComments(streamInfo.getCommentsInfo());
result = findInComments(streamInfo.getCommentsInfo().getComments(), "i should really be in the top comment.lol");
}
assertTrue(result);
}
@Test
public void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException {
boolean result = false;
CommentsInfo commentsInfo = CommentsInfo.getInfo("https://www.youtube.com/watch?v=rrgFN3AxGfs");
assertTrue("what the fuck am i doing with my life.wmv".equals(commentsInfo.getName()));
result = findInComments(commentsInfo.getComments(), "i should really be in the top comment.lol");
result = findInComments(commentsInfo.getRelatedItems(), "i should really be in the top comment.lol");
while (commentsInfo.hasMoreComments() && !result) {
CommentsInfo.loadMoreComments(commentsInfo);
result = findInComments(commentsInfo.getComments(), "i should really be in the top comment.lol");
String nextPage = commentsInfo.getNextPageUrl();
while (!StringUtil.isBlank(nextPage) && !result) {
InfoItemsPage<CommentsInfoItem> moreItems = CommentsInfo.getMoreItems(YouTube, commentsInfo, nextPage);
result = findInComments(moreItems.getItems(), "i should really be in the top comment.lol");
nextPage = moreItems.getNextPageUrl();
}
assertTrue(result);