2017-08-06 22:20:15 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.youtube;
|
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
import org.junit.BeforeClass;
|
2018-03-14 03:43:07 +01:00
|
|
|
import org.junit.Ignore;
|
2017-08-06 22:20:15 +02:00
|
|
|
import org.junit.Test;
|
|
|
|
import org.schabi.newpipe.Downloader;
|
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;
|
2018-03-04 21:26:13 +01:00
|
|
|
import org.schabi.newpipe.extractor.ServiceList;
|
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;
|
|
|
|
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
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
2017-08-07 18:12:51 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
2018-03-04 22:22:27 +01:00
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
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 {
|
2018-03-04 21:26:13 +01:00
|
|
|
public static class TimelessPopHits implements BasePlaylistExtractorTest {
|
|
|
|
private static YoutubePlaylistExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(Downloader.getInstance());
|
|
|
|
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 {
|
|
|
|
String name = extractor.getName();
|
2018-05-13 21:28:51 +02:00
|
|
|
assertTrue(name, name.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 {
|
2018-03-04 22:22:27 +01:00
|
|
|
defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
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 {
|
2018-03-04 22:22:27 +01:00
|
|
|
defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
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);
|
|
|
|
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt"));
|
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-03-14 03:43:07 +01:00
|
|
|
@Ignore
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testBannerUrl() throws Exception {
|
|
|
|
final String bannerUrl = extractor.getBannerUrl();
|
|
|
|
assertIsSecureUrl(bannerUrl);
|
|
|
|
assertTrue(bannerUrl, bannerUrl.contains("yt"));
|
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 {
|
|
|
|
assertTrue(extractor.getUploaderUrl().contains("youtube.com"));
|
|
|
|
}
|
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();
|
|
|
|
assertTrue(uploaderName, uploaderName.contains("Just Hits"));
|
|
|
|
}
|
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();
|
|
|
|
assertTrue(uploaderAvatarUrl, uploaderAvatarUrl.contains("yt"));
|
|
|
|
}
|
2017-12-29 01:12:55 +01:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testStreamCount() throws Exception {
|
|
|
|
assertTrue("Error in the streams count", extractor.getStreamCount() > 100);
|
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
}
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
public static class ImportantVideos implements BasePlaylistExtractorTest {
|
|
|
|
private static YoutubePlaylistExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(Downloader.getInstance());
|
|
|
|
extractor = (YoutubePlaylistExtractor) YouTube
|
2018-07-08 14:43:33 +02:00
|
|
|
.getPlaylistExtractor("https://www.youtube.com/watch?v=lH1caqoAGe0&list=PL45xb3ujEhqUexNt53jb9WT2mS-uUaUrn");
|
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());
|
2018-03-04 22:22:27 +01:00
|
|
|
defaultTestGetPageInNewExtractor(extractor, newExtractor, YouTube.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
|
|
|
String name = extractor.getName();
|
|
|
|
assertTrue(name, name.contains("Important videos"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
|
|
|
assertEquals("PLOy0j9AvlVZPto6IkjKfpu0Scx--7PGTC", extractor.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
public void testUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/playlist?list=PLOy0j9AvlVZPto6IkjKfpu0Scx--7PGTC", 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-03-04 21:26:13 +01:00
|
|
|
assertEquals("https://www.youtube.com/playlist?list=PLOy0j9AvlVZPto6IkjKfpu0Scx--7PGTC", extractor.getOriginalUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
2018-03-04 22:22:27 +01:00
|
|
|
defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
2018-03-11 21:54:41 +01:00
|
|
|
ListExtractor.InfoItemsPage<StreamInfoItem> currentPage = defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
// Test for 2 more levels
|
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
|
currentPage = extractor.getPage(currentPage.getNextPageUrl());
|
2018-03-11 21:54:41 +01:00
|
|
|
defaultTestListOfItems(YouTube.getServiceId(), 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);
|
|
|
|
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt"));
|
|
|
|
}
|
|
|
|
|
2018-03-14 03:43:07 +01:00
|
|
|
@Ignore
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testBannerUrl() throws Exception {
|
|
|
|
final String bannerUrl = extractor.getBannerUrl();
|
|
|
|
assertIsSecureUrl(bannerUrl);
|
|
|
|
assertTrue(bannerUrl, bannerUrl.contains("yt"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderUrl() throws Exception {
|
|
|
|
assertTrue(extractor.getUploaderUrl().contains("youtube.com"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderName() throws Exception {
|
|
|
|
assertEquals("Crazy Horse", extractor.getUploaderName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUploaderAvatarUrl() throws Exception {
|
|
|
|
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
|
|
|
|
assertTrue(uploaderAvatarUrl, uploaderAvatarUrl.contains("yt"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testStreamCount() throws Exception {
|
|
|
|
assertTrue("Error in the streams count", extractor.getStreamCount() > 100);
|
|
|
|
}
|
|
|
|
}
|
2017-08-06 22:20:15 +02:00
|
|
|
}
|