2017-08-08 08:42:28 +02:00
|
|
|
|
package org.schabi.newpipe.extractor.services.soundcloud;
|
|
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
|
import org.junit.BeforeClass;
|
2018-03-04 21:26:13 +01:00
|
|
|
|
import org.junit.Ignore;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.schabi.newpipe.Downloader;
|
2018-03-04 21:26:13 +01:00
|
|
|
|
import org.schabi.newpipe.extractor.ListExtractor;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2018-03-04 21:26:13 +01:00
|
|
|
|
import org.schabi.newpipe.extractor.ServiceList;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
2018-03-04 21:26:13 +01:00
|
|
|
|
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
2018-03-11 21:54:41 +01:00
|
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
2018-09-15 21:47:53 +02:00
|
|
|
|
import org.schabi.newpipe.extractor.utils.Localization;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2017-08-08 17:01:50 +02:00
|
|
|
|
import static org.junit.Assert.*;
|
2018-01-04 17:21:03 +01:00
|
|
|
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
2017-08-08 17:01:50 +02:00
|
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
2018-03-04 22:22:27 +01:00
|
|
|
|
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
|
2017-08-08 17:01:50 +02:00
|
|
|
|
|
2017-08-08 08:42:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* Test for {@link PlaylistExtractor}
|
|
|
|
|
*/
|
|
|
|
|
public class SoundcloudPlaylistExtractorTest {
|
2018-03-04 21:26:13 +01:00
|
|
|
|
public static class LuvTape implements BasePlaylistExtractorTest {
|
|
|
|
|
private static SoundcloudPlaylistExtractor extractor;
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@BeforeClass
|
|
|
|
|
public static void setUp() throws Exception {
|
2018-09-15 21:47:53 +02:00
|
|
|
|
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
2018-03-04 21:26:13 +01:00
|
|
|
|
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
|
|
|
|
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123");
|
|
|
|
|
extractor.fetchPage();
|
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Extractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@Test
|
|
|
|
|
public void testServiceId() {
|
|
|
|
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@Test
|
|
|
|
|
public void testName() {
|
|
|
|
|
assertEquals("THE PERFECT LUV TAPE®️", extractor.getName());
|
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@Test
|
|
|
|
|
public void testId() {
|
|
|
|
|
assertEquals("246349810", extractor.getId());
|
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
|
public void testUrl() throws Exception {
|
|
|
|
|
assertEquals("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r", extractor.getUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
|
public void testOriginalUrl() throws Exception {
|
2018-03-04 21:26:13 +01:00
|
|
|
|
assertEquals("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123", extractor.getOriginalUrl());
|
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// ListExtractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-08 08:42:28 +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, SoundCloud.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testMoreRelatedItems() {
|
|
|
|
|
try {
|
2018-03-04 22:22:27 +01:00
|
|
|
|
defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
} catch (Throwable ignored) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fail("This playlist doesn't have more items, it should throw an error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// PlaylistExtractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-08 08:42:28 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@Test
|
|
|
|
|
public void testThumbnailUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Ignore
|
|
|
|
|
@Test
|
|
|
|
|
public void testBannerUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getBannerUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderUrl() {
|
|
|
|
|
final String uploaderUrl = extractor.getUploaderUrl();
|
|
|
|
|
assertIsSecureUrl(uploaderUrl);
|
|
|
|
|
assertTrue(uploaderUrl, uploaderUrl.contains("liluzivert"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderName() {
|
|
|
|
|
assertTrue(extractor.getUploaderName().contains("LIL UZI VERT"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderAvatarUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testStreamCount() {
|
|
|
|
|
assertTrue("Error in the streams count", extractor.getStreamCount() >= 10);
|
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
public static class RandomHouseDanceMusic implements BasePlaylistExtractorTest {
|
|
|
|
|
private static SoundcloudPlaylistExtractor extractor;
|
|
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
|
public static void setUp() throws Exception {
|
2018-09-15 21:47:53 +02:00
|
|
|
|
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
2018-03-04 21:26:13 +01:00
|
|
|
|
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
2018-05-06 14:08:50 +02:00
|
|
|
|
.getPlaylistExtractor("https://soundcloud.com/hunter-leader/sets/house-electro-dance-music-2");
|
2018-03-04 21:26:13 +01:00
|
|
|
|
extractor.fetchPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Extractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testServiceId() {
|
|
|
|
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testName() {
|
2018-05-06 14:08:50 +02:00
|
|
|
|
assertEquals("House, Electro , Dance Music 2", extractor.getName());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testId() {
|
2018-05-06 14:08:50 +02:00
|
|
|
|
assertEquals("310980722", extractor.getId());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
|
public void testUrl() throws Exception {
|
|
|
|
|
assertEquals("https://soundcloud.com/hunter-leader/sets/house-electro-dance-music-2", extractor.getUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
|
public void testOriginalUrl() throws Exception {
|
|
|
|
|
assertEquals("https://soundcloud.com/hunter-leader/sets/house-electro-dance-music-2", extractor.getOriginalUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// ListExtractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testRelatedItems() throws Exception {
|
2018-03-04 22:22:27 +01:00
|
|
|
|
defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
2018-03-04 22:22:27 +01:00
|
|
|
|
defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// PlaylistExtractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testThumbnailUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Ignore
|
|
|
|
|
@Test
|
|
|
|
|
public void testBannerUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getBannerUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderUrl() {
|
|
|
|
|
final String uploaderUrl = extractor.getUploaderUrl();
|
|
|
|
|
assertIsSecureUrl(uploaderUrl);
|
2018-05-06 14:08:50 +02:00
|
|
|
|
assertTrue(uploaderUrl, uploaderUrl.contains("hunter-leader"));
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderName() {
|
2018-05-06 14:08:50 +02:00
|
|
|
|
assertEquals("Gosu", extractor.getUploaderName());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderAvatarUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testStreamCount() {
|
|
|
|
|
assertTrue("Error in the streams count", extractor.getStreamCount() >= 10);
|
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|
2017-08-12 22:19:56 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
public static class EDMxxx implements BasePlaylistExtractorTest {
|
|
|
|
|
private static SoundcloudPlaylistExtractor extractor;
|
|
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
|
public static void setUp() throws Exception {
|
2018-09-15 21:47:53 +02:00
|
|
|
|
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
2018-03-04 21:26:13 +01:00
|
|
|
|
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
|
|
|
|
.getPlaylistExtractor("https://soundcloud.com/user350509423/sets/edm-xxx");
|
|
|
|
|
extractor.fetchPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Additional Testing
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetPageInNewExtractor() throws Exception {
|
2018-05-06 14:08:50 +02:00
|
|
|
|
final PlaylistExtractor newExtractor = SoundCloud.getPlaylistExtractor(extractor.getUrl());
|
2018-03-04 22:22:27 +01:00
|
|
|
|
defaultTestGetPageInNewExtractor(extractor, newExtractor, SoundCloud.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Extractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testServiceId() {
|
|
|
|
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testName() {
|
|
|
|
|
assertEquals("EDM xXx", extractor.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testId() {
|
|
|
|
|
assertEquals("136000376", extractor.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
|
public void testUrl() throws Exception {
|
|
|
|
|
assertEquals("https://soundcloud.com/user350509423/sets/edm-xxx", extractor.getUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
|
public void testOriginalUrl() throws Exception {
|
2018-03-04 21:26:13 +01:00
|
|
|
|
assertEquals("https://soundcloud.com/user350509423/sets/edm-xxx", extractor.getOriginalUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// ListExtractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testRelatedItems() throws Exception {
|
2018-03-04 22:22:27 +01:00
|
|
|
|
defaultTestRelatedItems(extractor, SoundCloud.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.SoundCloud.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(SoundCloud.getServiceId(), currentPage.getItems(), currentPage.getErrors());
|
2018-03-04 21:26:13 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// PlaylistExtractor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testThumbnailUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getThumbnailUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Ignore
|
|
|
|
|
@Test
|
|
|
|
|
public void testBannerUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getBannerUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderUrl() {
|
|
|
|
|
final String uploaderUrl = extractor.getUploaderUrl();
|
|
|
|
|
assertIsSecureUrl(uploaderUrl);
|
|
|
|
|
assertTrue(uploaderUrl, uploaderUrl.contains("user350509423"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderName() {
|
|
|
|
|
assertEquals("user350509423", extractor.getUploaderName());
|
|
|
|
|
}
|
2017-08-12 22:19:56 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@Test
|
|
|
|
|
public void testUploaderAvatarUrl() {
|
|
|
|
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
|
|
|
|
}
|
2017-08-12 22:19:56 +02:00
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
|
@Test
|
|
|
|
|
public void testStreamCount() {
|
|
|
|
|
assertTrue("Error in the streams count", extractor.getStreamCount() >= 3900);
|
|
|
|
|
}
|
2017-08-12 22:19:56 +02:00
|
|
|
|
}
|
2017-08-08 08:42:28 +02:00
|
|
|
|
}
|