|
27 | 27 | import org.schabi.newpipe.extractor.stream.StreamInfoItem; |
28 | 28 | import org.schabi.newpipe.extractor.utils.Utils; |
29 | 29 |
|
| 30 | +import java.io.IOException; |
| 31 | +import java.util.List; |
| 32 | +import java.util.stream.Collectors; |
| 33 | + |
30 | 34 | /** |
31 | 35 | * Test for {@link YoutubePlaylistExtractor} |
32 | 36 | */ |
@@ -501,4 +505,34 @@ void testOnlySingleContinuation() throws Exception { |
501 | 505 | assertFalse(page.hasNextPage(), "More items available when it shouldn't"); |
502 | 506 | } |
503 | 507 | } |
| 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 | + } |
504 | 538 | } |
0 commit comments