2017-08-06 22:20:15 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.youtube;
|
|
|
|
|
2022-02-07 21:23:38 +01:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems;
|
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor;
|
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestListOfItems;
|
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems;
|
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
|
|
import org.junit.jupiter.api.Disabled;
|
|
|
|
import org.junit.jupiter.api.Test;
|
2021-01-17 18:55:37 +01:00
|
|
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
2021-12-27 21:08:08 +01:00
|
|
|
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
2017-08-12 22:19:56 +02:00
|
|
|
import org.schabi.newpipe.extractor.ListExtractor;
|
2017-08-06 22:20:15 +02:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2020-03-01 01:52:25 +01:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
2018-05-06 14:08:50 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
2018-03-04 21:26:13 +01:00
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
2022-02-17 18:01:30 +01:00
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
|
2018-03-04 21:26:13 +01:00
|
|
|
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
2018-05-08 21:19:03 +02:00
|
|
|
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor;
|
2018-03-11 21:54:41 +01:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
2018-03-04 21:26:13 +01:00
|
|
|
|
2021-01-17 18:55:37 +01:00
|
|
|
import java.io.IOException;
|
2017-08-06 22:20:15 +02:00
|
|
|
|
|
|
|
/**
|
2017-11-25 03:13:26 +01:00
|
|
|
* Test for {@link YoutubePlaylistExtractor}
|
2017-08-06 22:20:15 +02:00
|
|
|
*/
|
|
|
|
public class YoutubePlaylistExtractorTest {
|
2020-03-01 01:52:25 +01:00
|
|
|
|
2021-01-17 18:55:37 +01:00
|
|
|
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/playlist/";
|
|
|
|
|
2020-03-01 01:52:25 +01:00
|
|
|
public static class NotAvailable {
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2021-01-17 18:55:37 +01:00
|
|
|
public static void setUp() throws IOException {
|
2022-02-07 21:23:38 +01:00
|
|
|
YoutubeTestsUtils.ensureStateless();
|
2022-03-16 17:22:42 +01:00
|
|
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "notAvailable"));
|
2020-03-01 01:52:25 +01:00
|
|
|
}
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@Test
|
|
|
|
void nonExistentFetch() throws Exception {
|
2020-03-01 01:52:25 +01:00
|
|
|
final PlaylistExtractor extractor =
|
|
|
|
YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=PL11111111111111111111111111111111");
|
2021-12-27 21:08:08 +01:00
|
|
|
assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
|
2020-03-01 01:52:25 +01:00
|
|
|
}
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@Test
|
|
|
|
void invalidId() throws Exception {
|
2020-03-01 01:52:25 +01:00
|
|
|
final PlaylistExtractor extractor =
|
|
|
|
YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=INVALID_ID");
|
2021-12-27 21:08:08 +01:00
|
|
|
assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
|
2020-03-01 01:52:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
public static class TimelessPopHits implements BasePlaylistExtractorTest {
|
|
|
|
private static YoutubePlaylistExtractor extractor;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2018-03-04 21:26:13 +01:00
|
|
|
public static void setUp() throws Exception {
|
2022-02-07 21:23:38 +01:00
|
|
|
YoutubeTestsUtils.ensureStateless();
|
2022-03-16 17:22:42 +01:00
|
|
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "TimelessPopHits"));
|
2018-03-04 21:26:13 +01:00
|
|
|
extractor = (YoutubePlaylistExtractor) YouTube
|
|
|
|
.getPlaylistExtractor("http://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
|
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
2017-11-25 03:13:26 +01:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
2021-12-27 21:08:08 +01:00
|
|
|
assertTrue(extractor.getName().startsWith("Pop Music Playlist"));
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
|
|
|
assertEquals("PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj", extractor.getId());
|
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
public void testUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/playlist?list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj", extractor.getUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2018-03-04 21:26:13 +01:00
|
|
|
assertEquals("http://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj", extractor.getOriginalUrl());
|
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestRelatedItems(extractor);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestMoreItems(extractor);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// PlaylistExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testThumbnailUrl() throws Exception {
|
|
|
|
final String thumbnailUrl = extractor.getThumbnailUrl();
|
|
|
|
assertIsSecureUrl(thumbnailUrl);
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", thumbnailUrl);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@Disabled
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
2022-03-12 19:11:53 +01:00
|
|
|
public void testBannerUrl() throws ParsingException {
|
2018-03-04 21:26:13 +01:00
|
|
|
final String bannerUrl = extractor.getBannerUrl();
|
|
|
|
assertIsSecureUrl(bannerUrl);
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", bannerUrl);
|
2017-11-25 03:13:26 +01:00
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testUploaderUrl() throws Exception {
|
2020-02-29 22:57:25 +01:00
|
|
|
assertEquals("https://www.youtube.com/channel/UCs72iRpTEuwV3y6pdWYLgiw", extractor.getUploaderUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testUploaderName() throws Exception {
|
|
|
|
final String uploaderName = extractor.getUploaderName();
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("Just Hits", uploaderName);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testUploaderAvatarUrl() throws Exception {
|
|
|
|
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-12-29 01:12:55 +01:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testStreamCount() throws Exception {
|
2022-01-04 17:28:31 +01:00
|
|
|
ExtractorAsserts.assertGreater(100, extractor.getStreamCount());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2021-01-22 01:44:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testUploaderVerified() throws Exception {
|
|
|
|
assertFalse(extractor.isUploaderVerified());
|
|
|
|
}
|
2022-02-17 18:01:30 +01:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void getPlaylistType() throws ParsingException {
|
|
|
|
assertEquals(PlaylistInfo.PlaylistType.NORMAL, extractor.getPlaylistType());
|
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
}
|
|
|
|
|
2018-09-07 21:40:36 +02:00
|
|
|
public static class HugePlaylist implements BasePlaylistExtractorTest {
|
2018-03-04 21:26:13 +01:00
|
|
|
private static YoutubePlaylistExtractor extractor;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2018-03-04 21:26:13 +01:00
|
|
|
public static void setUp() throws Exception {
|
2022-02-07 21:23:38 +01:00
|
|
|
YoutubeTestsUtils.ensureStateless();
|
2022-03-16 17:22:42 +01:00
|
|
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "huge"));
|
2018-03-04 21:26:13 +01:00
|
|
|
extractor = (YoutubePlaylistExtractor) YouTube
|
2018-08-28 14:33:05 +02:00
|
|
|
.getPlaylistExtractor("https://www.youtube.com/watch?v=8SbUC-UaAxE&list=PLWwAypAcFRgKAIIFqBr9oy-ZYZnixa_Fj");
|
2018-03-04 21:26:13 +01:00
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Additional Testing
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetPageInNewExtractor() throws Exception {
|
2018-05-06 14:08:50 +02:00
|
|
|
final PlaylistExtractor newExtractor = YouTube.getPlaylistExtractor(extractor.getUrl());
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestGetPageInNewExtractor(extractor, newExtractor);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
2018-08-28 14:33:05 +02:00
|
|
|
final String name = extractor.getName();
|
|
|
|
assertEquals("I Wanna Rock Super Gigantic Playlist 1: Hardrock, AOR, Metal and more !!! 5000 music videos !!!", name);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
2018-08-28 14:33:05 +02:00
|
|
|
assertEquals("PLWwAypAcFRgKAIIFqBr9oy-ZYZnixa_Fj", extractor.getId());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
public void testUrl() throws ParsingException {
|
2018-08-28 14:33:05 +02:00
|
|
|
assertEquals("https://www.youtube.com/playlist?list=PLWwAypAcFRgKAIIFqBr9oy-ZYZnixa_Fj", extractor.getUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
public void testOriginalUrl() throws ParsingException {
|
2018-08-28 14:33:05 +02:00
|
|
|
assertEquals("https://www.youtube.com/watch?v=8SbUC-UaAxE&list=PLWwAypAcFRgKAIIFqBr9oy-ZYZnixa_Fj", extractor.getOriginalUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestRelatedItems(extractor);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
2020-02-27 04:08:23 +01:00
|
|
|
ListExtractor.InfoItemsPage<StreamInfoItem> currentPage = defaultTestMoreItems(extractor);
|
2018-08-28 14:33:05 +02:00
|
|
|
|
2019-08-16 21:17:03 +02:00
|
|
|
// test for 2 more levels
|
2018-03-04 21:26:13 +01:00
|
|
|
for (int i = 0; i < 2; i++) {
|
2020-04-15 14:09:46 +02:00
|
|
|
currentPage = extractor.getPage(currentPage.getNextPage());
|
2020-02-27 04:08:23 +01:00
|
|
|
defaultTestListOfItems(YouTube, currentPage.getItems(), currentPage.getErrors());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// PlaylistExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testThumbnailUrl() throws Exception {
|
|
|
|
final String thumbnailUrl = extractor.getThumbnailUrl();
|
|
|
|
assertIsSecureUrl(thumbnailUrl);
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", thumbnailUrl);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@Disabled
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
2022-03-12 19:11:53 +01:00
|
|
|
public void testBannerUrl() throws ParsingException {
|
2018-03-04 21:26:13 +01:00
|
|
|
final String bannerUrl = extractor.getBannerUrl();
|
|
|
|
assertIsSecureUrl(bannerUrl);
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", bannerUrl);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderUrl() throws Exception {
|
2019-08-16 21:17:03 +02:00
|
|
|
assertEquals("https://www.youtube.com/channel/UCHSPWoY1J5fbDVbcnyeqwdw", extractor.getUploaderUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderName() throws Exception {
|
2018-10-25 15:46:47 +02:00
|
|
|
assertEquals("Tomas Nilsson TOMPA571", extractor.getUploaderName());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderAvatarUrl() throws Exception {
|
|
|
|
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testStreamCount() throws Exception {
|
2022-01-04 17:28:31 +01:00
|
|
|
ExtractorAsserts.assertGreater(100, extractor.getStreamCount());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2021-01-22 01:44:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testUploaderVerified() throws Exception {
|
|
|
|
assertTrue(extractor.isUploaderVerified());
|
|
|
|
}
|
2022-02-17 18:01:30 +01:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void getPlaylistType() throws ParsingException {
|
|
|
|
assertEquals(PlaylistInfo.PlaylistType.NORMAL, extractor.getPlaylistType());
|
|
|
|
}
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2020-05-13 17:26:07 +02:00
|
|
|
|
|
|
|
public static class LearningPlaylist implements BasePlaylistExtractorTest {
|
|
|
|
private static YoutubePlaylistExtractor extractor;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2020-05-13 17:26:07 +02:00
|
|
|
public static void setUp() throws Exception {
|
2022-02-07 21:23:38 +01:00
|
|
|
YoutubeTestsUtils.ensureStateless();
|
2022-03-16 17:22:42 +01:00
|
|
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "learning"));
|
2020-05-13 17:26:07 +02:00
|
|
|
extractor = (YoutubePlaylistExtractor) YouTube
|
|
|
|
.getPlaylistExtractor("https://www.youtube.com/playlist?list=PL8dPuuaLjXtOAKed_MxxWBNaPno5h3Zs8");
|
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
2021-12-27 21:08:08 +01:00
|
|
|
assertTrue(extractor.getName().startsWith("Anatomy & Physiology"));
|
2020-05-13 17:26:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
|
|
|
assertEquals("PL8dPuuaLjXtOAKed_MxxWBNaPno5h3Zs8", extractor.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/playlist?list=PL8dPuuaLjXtOAKed_MxxWBNaPno5h3Zs8", extractor.getUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/playlist?list=PL8dPuuaLjXtOAKed_MxxWBNaPno5h3Zs8", extractor.getOriginalUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
|
|
|
defaultTestRelatedItems(extractor);
|
|
|
|
}
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@Disabled
|
2020-05-13 17:26:07 +02:00
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
|
|
|
defaultTestMoreItems(extractor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// PlaylistExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testThumbnailUrl() throws Exception {
|
|
|
|
final String thumbnailUrl = extractor.getThumbnailUrl();
|
|
|
|
assertIsSecureUrl(thumbnailUrl);
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", thumbnailUrl);
|
2020-05-13 17:26:07 +02:00
|
|
|
}
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@Disabled
|
2020-05-13 17:26:07 +02:00
|
|
|
@Test
|
2022-03-12 19:11:53 +01:00
|
|
|
public void testBannerUrl() throws ParsingException {
|
2020-05-13 17:26:07 +02:00
|
|
|
final String bannerUrl = extractor.getBannerUrl();
|
|
|
|
assertIsSecureUrl(bannerUrl);
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", bannerUrl);
|
2020-05-13 17:26:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderUrl() throws Exception {
|
|
|
|
assertEquals("https://www.youtube.com/channel/UCX6b17PVsYBQ0ip5gyeme-Q", extractor.getUploaderUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderName() throws Exception {
|
|
|
|
final String uploaderName = extractor.getUploaderName();
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("CrashCourse", uploaderName);
|
2020-05-13 17:26:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderAvatarUrl() throws Exception {
|
|
|
|
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
|
2021-12-27 21:08:08 +01:00
|
|
|
ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
|
2020-05-13 17:26:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testStreamCount() throws Exception {
|
2022-10-29 17:38:54 +02:00
|
|
|
ExtractorAsserts.assertGreater(40, extractor.getStreamCount());
|
2020-05-13 17:26:07 +02:00
|
|
|
}
|
2021-01-22 01:44:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testUploaderVerified() throws Exception {
|
|
|
|
assertTrue(extractor.isUploaderVerified());
|
|
|
|
}
|
2022-02-17 18:01:30 +01:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void getPlaylistType() throws ParsingException {
|
|
|
|
assertEquals(PlaylistInfo.PlaylistType.NORMAL, extractor.getPlaylistType());
|
|
|
|
}
|
2020-05-13 17:26:07 +02:00
|
|
|
}
|
2020-11-18 19:03:12 +01:00
|
|
|
|
|
|
|
public static class ContinuationsTests {
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2021-01-17 18:55:37 +01:00
|
|
|
public static void setUp() throws IOException {
|
2022-02-07 21:23:38 +01:00
|
|
|
YoutubeTestsUtils.ensureStateless();
|
2022-03-16 17:22:42 +01:00
|
|
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "continuations"));
|
2020-11-18 19:03:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testNoContinuations() throws Exception {
|
|
|
|
final YoutubePlaylistExtractor extractor = (YoutubePlaylistExtractor) YouTube
|
2021-01-22 01:44:58 +01:00
|
|
|
.getPlaylistExtractor(
|
|
|
|
"https://www.youtube.com/playlist?list=PLXJg25X-OulsVsnvZ7RVtSDW-id9_RzAO");
|
2020-11-18 19:03:12 +01:00
|
|
|
extractor.fetchPage();
|
|
|
|
|
|
|
|
assertNoMoreItems(extractor);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOnlySingleContinuation() throws Exception {
|
|
|
|
final YoutubePlaylistExtractor extractor = (YoutubePlaylistExtractor) YouTube
|
2021-01-22 01:44:58 +01:00
|
|
|
.getPlaylistExtractor(
|
2021-03-03 19:46:14 +01:00
|
|
|
"https://www.youtube.com/playlist?list=PLoumn5BIsUDeGF1vy5Nylf_RJKn5aL_nr");
|
2020-11-18 19:03:12 +01:00
|
|
|
extractor.fetchPage();
|
|
|
|
|
|
|
|
final ListExtractor.InfoItemsPage<StreamInfoItem> page = defaultTestMoreItems(
|
2021-01-22 01:44:58 +01:00
|
|
|
extractor);
|
2021-12-27 21:08:08 +01:00
|
|
|
assertFalse(page.hasNextPage(), "More items available when it shouldn't");
|
2020-11-18 19:03:12 +01:00
|
|
|
}
|
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
}
|