[YouTube] add test for membersOnly playlist

pull/1280/head
FineFindus 2025-03-08 14:52:38 +01:00
rodzic 601c1c8bd1
commit 2d88c34e00
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 64873EE210FF8E6B
1 zmienionych plików z 32 dodań i 0 usunięć

Wyświetl plik

@ -30,6 +30,8 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.utils.Utils;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
/**
* Test for {@link YoutubePlaylistExtractor}
@ -576,4 +578,34 @@ public class YoutubePlaylistExtractorTest {
assertFalse(page.hasNextPage(), "More items available when it shouldn't");
}
}
public static class MembersOnlyTests {
@BeforeAll
public static void setUp() {
YoutubeTestsUtils.ensureStateless();
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "membersOnlyVideos"));
}
@Test
void testOnlyMembersOnlyVideos() throws Exception {
final YoutubePlaylistExtractor extractor = (YoutubePlaylistExtractor) YouTube
.getPlaylistExtractor(
// auto-generated playlist with only membersOnly videos
"https://www.youtube.com/playlist?list=UUMOQuLXlFNAeDJMSmuzHU5axw");
extractor.fetchPage();
final List<StreamInfoItem> allItems = extractor.getInitialPage().getItems()
.stream()
.filter(StreamInfoItem.class::isInstance)
.map(StreamInfoItem.class::cast)
.collect(Collectors.toUnmodifiableList());
final List<StreamInfoItem> membershipVideos = allItems.stream()
.filter(item -> !item.requiresMembership())
.collect(Collectors.toUnmodifiableList());
assertFalse(allItems.isEmpty());
assertTrue(membershipVideos.isEmpty());
}
}
}