Skip to content

Commit 4a273f5

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

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

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

Lines changed: 28 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,28 @@ void testOnlySingleContinuation() throws Exception {
501505
assertFalse(page.hasNextPage(), "More items available when it shouldn't");
502506
}
503507
}
508+
509+
public static class MembersOnlyTests implements InitYoutubeTest {
510+
511+
@Test
512+
void testOnlyMembersOnlyVideos() throws Exception {
513+
final YoutubePlaylistExtractor extractor = (YoutubePlaylistExtractor) YouTube
514+
.getPlaylistExtractor(
515+
// auto-generated playlist with only membersOnly videos
516+
"https://www.youtube.com/playlist?list=UUMOQuLXlFNAeDJMSmuzHU5axw");
517+
extractor.fetchPage();
518+
519+
final List<StreamInfoItem> allItems = extractor.getInitialPage().getItems()
520+
.stream()
521+
.filter(StreamInfoItem.class::isInstance)
522+
.map(StreamInfoItem.class::cast)
523+
.collect(Collectors.toUnmodifiableList());
524+
final List<StreamInfoItem> membershipVideos = allItems.stream()
525+
.filter(item -> !item.requiresMembership())
526+
.collect(Collectors.toUnmodifiableList());
527+
528+
assertFalse(allItems.isEmpty());
529+
assertTrue(membershipVideos.isEmpty());
530+
}
531+
}
504532
}

0 commit comments

Comments
 (0)