File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727import org .schabi .newpipe .extractor .stream .StreamInfoItem ;
2828import 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}
You can’t perform that action at this time.
0 commit comments