Skip to content

Commit 4a2a1d2

Browse files
committed
[YouTube] add test for membersOnly playlist
1 parent f651be4 commit 4a2a1d2

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
2828
import org.schabi.newpipe.extractor.utils.Utils;
2929

30+
import java.io.IOException;
31+
import java.util.List;
32+
import java.util.stream.Collectors;
33+
3034
/**
3135
* Test for {@link YoutubePlaylistExtractor}
3236
*/
@@ -501,4 +505,34 @@ void testOnlySingleContinuation() throws Exception {
501505
assertFalse(page.hasNextPage(), "More items available when it shouldn't");
502506
}
503507
}
508+
509+
public static class MembersOnlyTests {
510+
511+
@BeforeAll
512+
public static void setUp() {
513+
YoutubeTestsUtils.ensureStateless();
514+
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "membersOnlyVideos"));
515+
}
516+
517+
@Test
518+
void testOnlyMembersOnlyVideos() throws Exception {
519+
final YoutubePlaylistExtractor extractor = (YoutubePlaylistExtractor) YouTube
520+
.getPlaylistExtractor(
521+
// auto-generated playlist with only membersOnly videos
522+
"https://www.youtube.com/playlist?list=UUMOQuLXlFNAeDJMSmuzHU5axw");
523+
extractor.fetchPage();
524+
525+
final List<StreamInfoItem> allItems = extractor.getInitialPage().getItems()
526+
.stream()
527+
.filter(StreamInfoItem.class::isInstance)
528+
.map(StreamInfoItem.class::cast)
529+
.collect(Collectors.toUnmodifiableList());
530+
final List<StreamInfoItem> membershipVideos = allItems.stream()
531+
.filter(item -> !item.requiresMembership())
532+
.collect(Collectors.toUnmodifiableList());
533+
534+
assertFalse(allItems.isEmpty());
535+
assertTrue(membershipVideos.isEmpty());
536+
}
537+
}
504538
}

0 commit comments

Comments
 (0)