Improve Channel and Playlist tests
This commit is contained in:
parent
11216f361f
commit
d9cf1fd631
10 changed files with 1144 additions and 307 deletions
|
@ -201,7 +201,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("could not get next streams' url", e);
|
throw new ParsingException("Could not get next page url", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
package org.schabi.newpipe.extractor;
|
package org.schabi.newpipe.extractor;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class ExtractorAsserts {
|
public class ExtractorAsserts {
|
||||||
public static void assertEmptyErrors(String message, List<Throwable> errors) {
|
public static void assertEmptyErrors(String message, List<Throwable> errors) {
|
||||||
if(!errors.isEmpty()) {
|
if (!errors.isEmpty()) {
|
||||||
for (Throwable throwable : errors) {
|
StringBuilder messageBuilder = new StringBuilder(message);
|
||||||
message += "\n * " + throwable.getMessage();
|
for (Throwable e : errors) {
|
||||||
|
messageBuilder.append("\n * ").append(e.getMessage());
|
||||||
}
|
}
|
||||||
throw new AssertionError(message, errors.get(0));
|
messageBuilder.append(" ");
|
||||||
|
throw new AssertionError(messageBuilder.toString(), errors.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +25,7 @@ public class ExtractorAsserts {
|
||||||
try {
|
try {
|
||||||
return new URL(url);
|
return new URL(url);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new AssertionError("Invalid url: " + url, e);
|
throw new AssertionError("Invalid url: " + "\"" + url + "\"", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,4 +37,23 @@ public class ExtractorAsserts {
|
||||||
URL url = urlFromString(urlToCheck);
|
URL url = urlFromString(urlToCheck);
|
||||||
assertEquals("Protocol of URL is not secure", "https", url.getProtocol());
|
assertEquals("Protocol of URL is not secure", "https", url.getProtocol());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void assertNotEmpty(String stringToCheck) {
|
||||||
|
assertNotEmpty(null, stringToCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void assertNotEmpty(@Nullable String message, String stringToCheck) {
|
||||||
|
assertNotNull(message, stringToCheck);
|
||||||
|
assertFalse(message, stringToCheck.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void assertEmpty(String stringToCheck) {
|
||||||
|
assertEmpty(null, stringToCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void assertEmpty(@Nullable String message, String stringToCheck) {
|
||||||
|
if (stringToCheck != null) {
|
||||||
|
assertTrue(message, stringToCheck.isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.schabi.newpipe.extractor.services;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public interface BaseChannelExtractorTest extends BaseListExtractorTest {
|
||||||
|
void testDescription() throws Exception;
|
||||||
|
void testAvatarUrl() throws Exception;
|
||||||
|
void testBannerUrl() throws Exception;
|
||||||
|
void testFeedUrl() throws Exception;
|
||||||
|
void testSubscriberCount() throws Exception;
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.schabi.newpipe.extractor.services;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public interface BaseExtractorTest {
|
||||||
|
void testServiceId() throws Exception;
|
||||||
|
void testName() throws Exception;
|
||||||
|
void testId() throws Exception;
|
||||||
|
void testCleanUrl() throws Exception;
|
||||||
|
void testOriginalUrl() throws Exception;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package org.schabi.newpipe.extractor.services;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
||||||
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.*;
|
||||||
|
|
||||||
|
public interface BaseListExtractorTest extends BaseExtractorTest {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
void testRelatedItems() throws Exception;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
void testMoreRelatedItems() throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
static void defaultTestListOfItems(int expectedServiceId, List<? extends InfoItem> itemsList, List<Throwable> errors) {
|
||||||
|
assertTrue("List of items is empty", !itemsList.isEmpty());
|
||||||
|
assertFalse("List of items contains a null element", itemsList.contains(null));
|
||||||
|
assertEmptyErrors("Errors during stream list extraction", errors);
|
||||||
|
|
||||||
|
for (InfoItem item : itemsList) {
|
||||||
|
assertIsSecureUrl(item.getUrl());
|
||||||
|
if (item.getThumbnailUrl() != null && !item.getThumbnailUrl().isEmpty()) {
|
||||||
|
assertIsSecureUrl(item.getThumbnailUrl());
|
||||||
|
}
|
||||||
|
assertNotNull("InfoItem type not set: " + item, item.getInfoType());
|
||||||
|
assertEquals("Service id doesn't match: " + item, expectedServiceId, item.getServiceId());
|
||||||
|
|
||||||
|
if (item instanceof StreamInfoItem) {
|
||||||
|
StreamInfoItem streamInfoItem = (StreamInfoItem) item;
|
||||||
|
assertNotEmpty("Uploader name not set: " + item, streamInfoItem.getUploaderName());
|
||||||
|
assertNotEmpty("Uploader url not set: " + item, streamInfoItem.getUploaderUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void defaultTestRelatedItems(ListExtractor extractor, int expectedServiceId) throws Exception {
|
||||||
|
final InfoItemsCollector<? extends InfoItem, ?> itemsCollector = extractor.getInfoItems();
|
||||||
|
final List<? extends InfoItem> itemsList = itemsCollector.getItemList();
|
||||||
|
List<Throwable> errors = itemsCollector.getErrors();
|
||||||
|
|
||||||
|
defaultTestListOfItems(expectedServiceId, itemsList, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ListExtractor.InfoItemPage<? extends InfoItem> defaultTestMoreItems(ListExtractor extractor, int expectedServiceId) throws Exception {
|
||||||
|
assertTrue("Doesn't have more items", extractor.hasNextPage());
|
||||||
|
ListExtractor.InfoItemPage<? extends InfoItem> nextPage = extractor.getPage(extractor.getNextPageUrl());
|
||||||
|
assertTrue("Next page is empty", !nextPage.getItemsList().isEmpty());
|
||||||
|
assertEmptyErrors("Next page have errors", nextPage.getErrors());
|
||||||
|
|
||||||
|
defaultTestListOfItems(expectedServiceId, nextPage.getItemsList(), nextPage.getErrors());
|
||||||
|
return nextPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void defaultTestGetPageInNewExtractor(ListExtractor extractor, ListExtractor newExtractor, int expectedServiceId) throws Exception {
|
||||||
|
final String nextPageUrl = extractor.getNextPageUrl();
|
||||||
|
|
||||||
|
final ListExtractor.InfoItemPage<? extends InfoItem> page = newExtractor.getPage(nextPageUrl);
|
||||||
|
BaseListExtractorTest.defaultTestListOfItems(expectedServiceId, page.getItemsList(), page.getErrors());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.schabi.newpipe.extractor.services;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public interface BasePlaylistExtractorTest extends BaseListExtractorTest {
|
||||||
|
void testThumbnailUrl() throws Exception;
|
||||||
|
void testBannerUrl() throws Exception;
|
||||||
|
void testUploaderUrl() throws Exception;
|
||||||
|
void testUploaderName() throws Exception;
|
||||||
|
void testUploaderAvatarUrl() throws Exception;
|
||||||
|
void testStreamCount() throws Exception;
|
||||||
|
}
|
|
@ -2,87 +2,199 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.runners.Enclosed;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.ListExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||||
|
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ChannelExtractor}
|
* Test for {@link SoundcloudChannelExtractor}
|
||||||
*/
|
*/
|
||||||
|
@RunWith(Enclosed.class)
|
||||||
public class SoundcloudChannelExtractorTest {
|
public class SoundcloudChannelExtractorTest {
|
||||||
|
public static class LilUzi implements BaseChannelExtractorTest {
|
||||||
|
private static SoundcloudChannelExtractor extractor;
|
||||||
|
|
||||||
static ChannelExtractor extractor;
|
@BeforeClass
|
||||||
|
public static void setUp() throws Exception {
|
||||||
|
NewPipe.init(Downloader.getInstance());
|
||||||
|
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||||
|
.getChannelExtractor("http://soundcloud.com/liluzivert/sets");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public static void setUp() throws Exception {
|
// Extractor
|
||||||
NewPipe.init(Downloader.getInstance());
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
extractor = SoundCloud
|
|
||||||
.getChannelExtractor("https://soundcloud.com/liluzivert");
|
@Test
|
||||||
extractor.fetchPage();
|
public void testServiceId() {
|
||||||
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() {
|
||||||
|
assertEquals("LIL UZI VERT", extractor.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testId() {
|
||||||
|
assertEquals("10494998", extractor.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanUrl() {
|
||||||
|
assertEquals("https://soundcloud.com/liluzivert", extractor.getCleanUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOriginalUrl() {
|
||||||
|
assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ChannelExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDescription() {
|
||||||
|
assertNotNull(extractor.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAvatarUrl() {
|
||||||
|
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBannerUrl() {
|
||||||
|
assertIsSecureUrl(extractor.getBannerUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFeedUrl() {
|
||||||
|
assertEmpty(extractor.getFeedUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriberCount() {
|
||||||
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 1e6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public static class DubMatix implements BaseChannelExtractorTest {
|
||||||
public void testGetDownloader() throws Exception {
|
private static SoundcloudChannelExtractor extractor;
|
||||||
assertNotNull(NewPipe.getDownloader());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@BeforeClass
|
||||||
public void testGetName() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
assertEquals("LIL UZI VERT", extractor.getName());
|
NewPipe.init(Downloader.getInstance());
|
||||||
}
|
extractor = (SoundcloudChannelExtractor) SoundCloud
|
||||||
|
.getChannelExtractor("https://soundcloud.com/dubmatix");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testGetDescription() throws Exception {
|
// Additional Testing
|
||||||
assertTrue(extractor.getDescription() != null);
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAvatarUrl() throws Exception {
|
public void testGetPageInNewExtractor() throws Exception {
|
||||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
final ChannelExtractor newExtractor = SoundCloud.getChannelExtractor(extractor.getCleanUrl());
|
||||||
}
|
BaseListExtractorTest.defaultTestGetPageInNewExtractor(extractor, newExtractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testGetStreams() throws Exception {
|
// Extractor
|
||||||
assertFalse("no streams are received", extractor.getInfoItems().getItemList().isEmpty());
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStreamsErrors() throws Exception {
|
public void testServiceId() {
|
||||||
assertTrue("errors during stream list extraction", extractor.getInfoItems().getErrors().isEmpty());
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasMoreStreams() throws Exception {
|
public void testName() {
|
||||||
// Setup the streams
|
assertEquals("dubmatix", extractor.getName());
|
||||||
extractor.getInfoItems();
|
}
|
||||||
assertTrue("don't have more streams", extractor.hasNextPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubscriberCount() throws Exception {
|
public void testId() {
|
||||||
assertTrue("wrong subscriber count", extractor.getSubscriberCount() >= 1000000);
|
assertEquals("542134", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetNextPageUrl() throws Exception {
|
public void testCleanUrl() {
|
||||||
assertTrue(extractor.hasNextPage());
|
assertEquals("https://soundcloud.com/dubmatix", extractor.getCleanUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPage() throws Exception {
|
public void testOriginalUrl() {
|
||||||
// Setup the streams
|
assertEquals("https://soundcloud.com/dubmatix", extractor.getOriginalUrl());
|
||||||
extractor.getInfoItems();
|
}
|
||||||
ListExtractor.InfoItemPage<StreamInfoItem> nextItemsResult = extractor.getPage(extractor.getNextPageUrl());
|
|
||||||
assertTrue("extractor didn't have next streams", !nextItemsResult.getItemsList().isEmpty());
|
|
||||||
assertTrue("errors occurred during extraction of the next streams", nextItemsResult.getErrors().isEmpty());
|
|
||||||
assertTrue("extractor didn't have more streams after getInfoItemPage", extractor.hasNextPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ChannelExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDescription() {
|
||||||
|
assertNotNull(extractor.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAvatarUrl() {
|
||||||
|
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBannerUrl() {
|
||||||
|
assertIsSecureUrl(extractor.getBannerUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFeedUrl() {
|
||||||
|
assertEmpty(extractor.getFeedUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriberCount() {
|
||||||
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 2e6);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.runners.Enclosed;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||||
|
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||||
|
@ -14,84 +21,302 @@ import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
/**
|
/**
|
||||||
* Test for {@link PlaylistExtractor}
|
* Test for {@link PlaylistExtractor}
|
||||||
*/
|
*/
|
||||||
|
@RunWith(Enclosed.class)
|
||||||
public class SoundcloudPlaylistExtractorTest {
|
public class SoundcloudPlaylistExtractorTest {
|
||||||
private static PlaylistExtractor extractor;
|
public static class LuvTape implements BasePlaylistExtractorTest {
|
||||||
|
private static SoundcloudPlaylistExtractor extractor;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = SoundCloud
|
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||||
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r");
|
.getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Extractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServiceId() {
|
||||||
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() {
|
||||||
|
assertEquals("THE PERFECT LUV TAPE®️", extractor.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testId() {
|
||||||
|
assertEquals("246349810", extractor.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanUrl() {
|
||||||
|
assertEquals("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r", extractor.getCleanUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOriginalUrl() {
|
||||||
|
assertEquals("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123", extractor.getOriginalUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() {
|
||||||
|
try {
|
||||||
|
BaseListExtractorTest.defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fail("This playlist doesn't have more items, it should throw an error");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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("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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public static class RandomHouseDanceMusic implements BasePlaylistExtractorTest {
|
||||||
public void testGetDownloader() throws Exception {
|
private static SoundcloudPlaylistExtractor extractor;
|
||||||
assertNotNull(NewPipe.getDownloader());
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() throws Exception {
|
||||||
|
NewPipe.init(Downloader.getInstance());
|
||||||
|
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||||
|
.getPlaylistExtractor("http://soundcloud.com/finn-trapple/sets/random-house-dance-music-2");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Extractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServiceId() {
|
||||||
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() {
|
||||||
|
assertEquals("Random House & Dance Music #2", extractor.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testId() {
|
||||||
|
assertEquals("436855608", extractor.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanUrl() {
|
||||||
|
assertEquals("https://soundcloud.com/finn-trapple/sets/random-house-dance-music-2", extractor.getCleanUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOriginalUrl() {
|
||||||
|
assertEquals("http://soundcloud.com/finn-trapple/sets/random-house-dance-music-2", extractor.getOriginalUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestMoreItems(extractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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("finn-trapple"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploaderName() {
|
||||||
|
assertEquals("Finn TrApple", extractor.getUploaderName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploaderAvatarUrl() {
|
||||||
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStreamCount() {
|
||||||
|
assertTrue("Error in the streams count", extractor.getStreamCount() >= 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public static class EDMxxx implements BasePlaylistExtractorTest {
|
||||||
public void testGetId() throws Exception {
|
private static SoundcloudPlaylistExtractor extractor;
|
||||||
assertEquals(extractor.getId(), "246349810");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@BeforeClass
|
||||||
public void testGetName() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
assertEquals(extractor.getName(), "THE PERFECT LUV TAPE®️");
|
NewPipe.init(Downloader.getInstance());
|
||||||
}
|
extractor = (SoundcloudPlaylistExtractor) SoundCloud
|
||||||
|
.getPlaylistExtractor("https://soundcloud.com/user350509423/sets/edm-xxx");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testGetThumbnailUrl() throws Exception {
|
// Additional Testing
|
||||||
assertIsSecureUrl(extractor.getThumbnailUrl());
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUploaderUrl() throws Exception {
|
public void testGetPageInNewExtractor() throws Exception {
|
||||||
assertIsSecureUrl(extractor.getUploaderUrl());
|
final PlaylistExtractor newExtractor = SoundCloud.getPlaylistExtractor(extractor.getCleanUrl());
|
||||||
assertEquals(extractor.getUploaderUrl(), "https://soundcloud.com/liluzivert");
|
BaseListExtractorTest.defaultTestGetPageInNewExtractor(extractor, newExtractor, SoundCloud.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testGetUploaderName() throws Exception {
|
// Extractor
|
||||||
assertEquals(extractor.getUploaderName(), "LIL UZI VERT");
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUploaderAvatarUrl() throws Exception {
|
public void testServiceId() {
|
||||||
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStreamsCount() throws Exception {
|
public void testName() {
|
||||||
assertEquals(extractor.getStreamCount(), 10);
|
assertEquals("EDM xXx", extractor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStreams() throws Exception {
|
public void testId() {
|
||||||
assertTrue("no streams are received", !extractor.getInfoItems().getItemList().isEmpty());
|
assertEquals("136000376", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStreamsErrors() throws Exception {
|
public void testCleanUrl() {
|
||||||
assertTrue("errors during stream list extraction", extractor.getInfoItems().getErrors().isEmpty());
|
assertEquals("https://soundcloud.com/user350509423/sets/edm-xxx", extractor.getCleanUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasMoreStreams() throws Exception {
|
public void testOriginalUrl() {
|
||||||
// Setup the streams
|
assertEquals("https://soundcloud.com/user350509423/sets/edm-xxx", extractor.getOriginalUrl());
|
||||||
extractor.getInfoItems();
|
}
|
||||||
assertTrue("extractor didn't have more streams", !extractor.hasNextPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = ExtractionException.class)
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testGetNextPageNonExistent() throws Exception {
|
// ListExtractor
|
||||||
// Setup the streams
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
extractor.getInfoItems();
|
|
||||||
|
|
||||||
// This playlist don't have more streams, it should throw an error
|
@Test
|
||||||
extractor.getPage(extractor.getNextPageUrl());
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, SoundCloud.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
fail("Expected exception wasn't thrown");
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
ListExtractor.InfoItemPage<? extends InfoItem> currentPage = BaseListExtractorTest.defaultTestMoreItems(extractor, ServiceList.SoundCloud.getServiceId());
|
||||||
|
// Test for 2 more levels
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
currentPage = extractor.getPage(currentPage.getNextPageUrl());
|
||||||
|
BaseListExtractorTest.defaultTestListOfItems(SoundCloud.getServiceId(), currentPage.getItemsList(), currentPage.getErrors());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploaderAvatarUrl() {
|
||||||
|
assertIsSecureUrl(extractor.getUploaderAvatarUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStreamCount() {
|
||||||
|
assertTrue("Error in the streams count", extractor.getStreamCount() >= 3900);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,125 +2,396 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.runners.Enclosed;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.ListExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||||
|
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/*
|
|
||||||
* Created by Christian Schabesberger on 12.09.16.
|
|
||||||
*
|
|
||||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
|
||||||
* YoutubeSearchEngineStreamTest.java is part of NewPipe.
|
|
||||||
*
|
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* NewPipe is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ChannelExtractor}
|
* Test for {@link ChannelExtractor}
|
||||||
*/
|
*/
|
||||||
|
@RunWith(Enclosed.class)
|
||||||
public class YoutubeChannelExtractorTest {
|
public class YoutubeChannelExtractorTest {
|
||||||
|
public static class Gronkh implements BaseChannelExtractorTest {
|
||||||
|
private static YoutubeChannelExtractor extractor;
|
||||||
|
|
||||||
static YoutubeChannelExtractor extractor;
|
@BeforeClass
|
||||||
|
public static void setUp() throws Exception {
|
||||||
|
NewPipe.init(Downloader.getInstance());
|
||||||
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
|
.getChannelExtractor("http://www.youtube.com/user/Gronkh");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public static void setUp() throws Exception {
|
// Extractor
|
||||||
NewPipe.init(Downloader.getInstance());
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
extractor = (YoutubeChannelExtractor) YouTube
|
|
||||||
.getChannelExtractor("https://www.youtube.com/user/Gronkh");
|
@Test
|
||||||
extractor.fetchPage();
|
public void testServiceId() {
|
||||||
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() throws Exception {
|
||||||
|
assertEquals("Gronkh", extractor.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testId() throws Exception {
|
||||||
|
assertEquals("UCYJ61XIK64sp6ZFFS8sctxw", extractor.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanUrl() {
|
||||||
|
assertEquals("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", extractor.getCleanUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOriginalUrl() {
|
||||||
|
assertEquals("http://www.youtube.com/user/Gronkh", extractor.getOriginalUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ChannelExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDescription() throws Exception {
|
||||||
|
assertTrue(extractor.getDescription().contains("Zart im Schmelz und süffig im Abgang. Ungebremster Spieltrieb"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAvatarUrl() throws Exception {
|
||||||
|
String avatarUrl = extractor.getAvatarUrl();
|
||||||
|
assertIsSecureUrl(avatarUrl);
|
||||||
|
assertTrue(avatarUrl, avatarUrl.contains("yt3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBannerUrl() throws Exception {
|
||||||
|
String bannerUrl = extractor.getBannerUrl();
|
||||||
|
assertIsSecureUrl(bannerUrl);
|
||||||
|
assertTrue(bannerUrl, bannerUrl.contains("yt3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFeedUrl() throws Exception {
|
||||||
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCYJ61XIK64sp6ZFFS8sctxw", extractor.getFeedUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriberCount() throws Exception {
|
||||||
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public static class Kurzgesagt implements BaseChannelExtractorTest {
|
||||||
public void testGetDownloader() throws Exception {
|
private static YoutubeChannelExtractor extractor;
|
||||||
assertNotNull(NewPipe.getDownloader());
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() throws Exception {
|
||||||
|
NewPipe.init(Downloader.getInstance());
|
||||||
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
|
.getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Additional Testing
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPageInNewExtractor() throws Exception {
|
||||||
|
final ChannelExtractor newExtractor = YouTube.getChannelExtractor(extractor.getCleanUrl());
|
||||||
|
BaseListExtractorTest.defaultTestGetPageInNewExtractor(extractor, newExtractor, YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Extractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServiceId() {
|
||||||
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() throws Exception {
|
||||||
|
String name = extractor.getName();
|
||||||
|
assertTrue(name, name.startsWith("Kurzgesagt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testId() throws Exception {
|
||||||
|
assertEquals("UCsXVk37bltHxD1rDPwtNM8Q", extractor.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanUrl() {
|
||||||
|
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getCleanUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOriginalUrl() {
|
||||||
|
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getOriginalUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ChannelExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDescription() throws Exception {
|
||||||
|
final String description = extractor.getDescription();
|
||||||
|
assertTrue(description, description.contains("small team who want to make science look beautiful"));
|
||||||
|
//TODO: Description get cuts out, because the og:description is optimized and don't have all the content
|
||||||
|
//assertTrue(description, description.contains("Currently we make one animation video per month"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAvatarUrl() throws Exception {
|
||||||
|
String avatarUrl = extractor.getAvatarUrl();
|
||||||
|
assertIsSecureUrl(avatarUrl);
|
||||||
|
assertTrue(avatarUrl, avatarUrl.contains("yt3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBannerUrl() throws Exception {
|
||||||
|
String bannerUrl = extractor.getBannerUrl();
|
||||||
|
assertIsSecureUrl(bannerUrl);
|
||||||
|
assertTrue(bannerUrl, bannerUrl.contains("yt3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFeedUrl() throws Exception {
|
||||||
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q", extractor.getFeedUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriberCount() throws Exception {
|
||||||
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 5e6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public static class CaptainDisillusion implements BaseChannelExtractorTest {
|
||||||
public void testGetName() throws Exception {
|
private static YoutubeChannelExtractor extractor;
|
||||||
assertEquals(extractor.getName(), "Gronkh");
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() throws Exception {
|
||||||
|
NewPipe.init(Downloader.getInstance());
|
||||||
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
|
.getChannelExtractor("https://www.youtube.com/user/CaptainDisillusion/videos");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Extractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServiceId() {
|
||||||
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() throws Exception {
|
||||||
|
assertEquals("CaptainDisillusion", extractor.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testId() throws Exception {
|
||||||
|
assertEquals("UCEOXxzW2vU0P-0THehuIIeg", extractor.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanUrl() {
|
||||||
|
assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", extractor.getCleanUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOriginalUrl() {
|
||||||
|
assertEquals("https://www.youtube.com/user/CaptainDisillusion/videos", extractor.getOriginalUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ChannelExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDescription() throws Exception {
|
||||||
|
final String description = extractor.getDescription();
|
||||||
|
assertTrue(description, description.contains("In a world where"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAvatarUrl() throws Exception {
|
||||||
|
String avatarUrl = extractor.getAvatarUrl();
|
||||||
|
assertIsSecureUrl(avatarUrl);
|
||||||
|
assertTrue(avatarUrl, avatarUrl.contains("yt3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBannerUrl() throws Exception {
|
||||||
|
String bannerUrl = extractor.getBannerUrl();
|
||||||
|
assertIsSecureUrl(bannerUrl);
|
||||||
|
assertTrue(bannerUrl, bannerUrl.contains("yt3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFeedUrl() throws Exception {
|
||||||
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCEOXxzW2vU0P-0THehuIIeg", extractor.getFeedUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriberCount() throws Exception {
|
||||||
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 5e5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public static class RandomChannel implements BaseChannelExtractorTest {
|
||||||
public void testGetId() throws Exception {
|
private static YoutubeChannelExtractor extractor;
|
||||||
assertEquals(extractor.getId(), "UCYJ61XIK64sp6ZFFS8sctxw");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@BeforeClass
|
||||||
public void testGetUrl() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
assertEquals(extractor.getCleanUrl(), "https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw");
|
NewPipe.init(Downloader.getInstance());
|
||||||
}
|
extractor = (YoutubeChannelExtractor) YouTube
|
||||||
|
.getChannelExtractor("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testGetDescription() throws Exception {
|
// Extractor
|
||||||
assertEquals(extractor.getDescription(), "★ ★ ★ KLICK MICH HART, DU SAU! :D ★ ★ ★ Zart im Schmelz und süffig im Abgang. Ungebremster Spieltrieb seit 1896. Tägliche Folgen nonstop seit dem 01.04.2010!...");
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAvatarUrl() throws Exception {
|
public void testServiceId() {
|
||||||
assertTrue(extractor.getAvatarUrl(), extractor.getAvatarUrl().contains("yt3"));
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBannerUrl() throws Exception {
|
public void testName() throws Exception {
|
||||||
assertTrue(extractor.getBannerUrl(), extractor.getBannerUrl().contains("yt3"));
|
assertEquals("random channel", extractor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetFeedUrl() throws Exception {
|
public void testId() throws Exception {
|
||||||
assertEquals(extractor.getFeedUrl(), "https://www.youtube.com/feeds/videos.xml?channel_id=UCYJ61XIK64sp6ZFFS8sctxw");
|
assertEquals("UCUaQMQS9lY5lit3vurpXQ6w", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStreams() throws Exception {
|
public void testCleanUrl() {
|
||||||
assertTrue("no streams are received", !extractor.getInfoItems().getItemList().isEmpty());
|
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getCleanUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStreamsErrors() throws Exception {
|
public void testOriginalUrl() {
|
||||||
assertEmptyErrors("errors during stream list extraction", extractor.getInfoItems().getErrors());
|
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getOriginalUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testHasMoreStreams() throws Exception {
|
// ListExtractor
|
||||||
// Setup the streams
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
extractor.getInfoItems();
|
|
||||||
assertTrue("don't have more streams", extractor.hasNextPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubscriberCount() throws Exception {
|
public void testRelatedItems() throws Exception {
|
||||||
assertTrue("wrong subscriber count", extractor.getSubscriberCount() >= 0);
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetNextPageUrl() throws Exception {
|
public void testMoreRelatedItems() {
|
||||||
assertTrue(extractor.hasNextPage());
|
try {
|
||||||
}
|
BaseListExtractorTest.defaultTestMoreItems(extractor, YouTube.getServiceId());
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
fail("This channel doesn't have more items, it should throw an error");
|
||||||
public void testGetPage() throws Exception {
|
}
|
||||||
// Setup the streams
|
|
||||||
extractor.getInfoItems();
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
ListExtractor.InfoItemPage<StreamInfoItem> nextItemsResult = extractor.getPage(extractor.getNextPageUrl());
|
// ChannelExtractor
|
||||||
assertTrue("extractor didn't have next streams", !nextItemsResult.getItemsList().isEmpty());
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
assertEmptyErrors("errors occurred during extraction of the next streams", nextItemsResult.getErrors());
|
|
||||||
assertTrue("extractor didn't have more streams after getInfoItemPage", extractor.hasNextPage());
|
@Test
|
||||||
|
public void testDescription() throws Exception {
|
||||||
|
final String description = extractor.getDescription();
|
||||||
|
assertTrue(description, description.contains("Hey there iu will upoload a load of pranks onto this channel"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAvatarUrl() throws Exception {
|
||||||
|
String avatarUrl = extractor.getAvatarUrl();
|
||||||
|
assertIsSecureUrl(avatarUrl);
|
||||||
|
assertTrue(avatarUrl, avatarUrl.contains("yt3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBannerUrl() throws Exception {
|
||||||
|
String bannerUrl = extractor.getBannerUrl();
|
||||||
|
assertIsSecureUrl(bannerUrl);
|
||||||
|
assertTrue(bannerUrl, bannerUrl.contains("yt3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFeedUrl() throws Exception {
|
||||||
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCUaQMQS9lY5lit3vurpXQ6w", extractor.getFeedUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriberCount() throws Exception {
|
||||||
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,120 +1,231 @@
|
||||||
package org.schabi.newpipe.extractor.services.youtube;
|
package org.schabi.newpipe.extractor.services.youtube;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.runners.Enclosed;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.ListExtractor;
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
|
||||||
|
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
|
||||||
|
|
||||||
import java.util.List;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.*;
|
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
|
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link YoutubePlaylistExtractor}
|
* Test for {@link YoutubePlaylistExtractor}
|
||||||
*/
|
*/
|
||||||
|
@RunWith(Enclosed.class)
|
||||||
public class YoutubePlaylistExtractorTest {
|
public class YoutubePlaylistExtractorTest {
|
||||||
private static YoutubePlaylistExtractor extractor;
|
public static class TimelessPopHits implements BasePlaylistExtractorTest {
|
||||||
|
private static YoutubePlaylistExtractor extractor;
|
||||||
|
|
||||||
private static void assertNotEmpty(String message, String value) {
|
@BeforeClass
|
||||||
assertNotNull(message, value);
|
public static void setUp() throws Exception {
|
||||||
assertFalse(message, value.isEmpty());
|
NewPipe.init(Downloader.getInstance());
|
||||||
}
|
extractor = (YoutubePlaylistExtractor) YouTube
|
||||||
|
.getPlaylistExtractor("http://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public static void setUp() throws Exception {
|
// Extractor
|
||||||
NewPipe.init(Downloader.getInstance());
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
extractor = (YoutubePlaylistExtractor) YouTube
|
|
||||||
.getPlaylistExtractor("https://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
|
|
||||||
extractor.fetchPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDownloader() throws Exception {
|
public void testServiceId() {
|
||||||
assertNotNull(NewPipe.getDownloader());
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetId() throws Exception {
|
public void testName() throws Exception {
|
||||||
assertEquals(extractor.getId(), "PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj");
|
String name = extractor.getName();
|
||||||
}
|
assertTrue(name, name.startsWith("Pop Music Playlist: Timeless Pop Hits"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetName() throws Exception {
|
public void testId() throws Exception {
|
||||||
assertEquals(extractor.getName(), "Pop Music Playlist: Timeless Pop Hits (Updated Weekly 2018)");
|
assertEquals("PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetThumbnailUrl() throws Exception {
|
public void testCleanUrl() {
|
||||||
assertTrue(extractor.getThumbnailUrl(), extractor.getThumbnailUrl().contains("yt"));
|
assertEquals("https://www.youtube.com/playlist?list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj", extractor.getCleanUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBannerUrl() throws Exception {
|
public void testOriginalUrl() {
|
||||||
System.out.println(extractor.getBannerUrl());
|
assertEquals("http://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj", extractor.getOriginalUrl());
|
||||||
assertTrue(extractor.getBannerUrl(), extractor.getBannerUrl().contains("yt"));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testGetUploaderUrl() throws Exception {
|
// ListExtractor
|
||||||
assertTrue(extractor.getUploaderUrl(), extractor.getUploaderUrl().contains("youtube.com"));
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUploaderName() throws Exception {
|
public void testRelatedItems() throws Exception {
|
||||||
assertTrue(extractor.getUploaderName(), !extractor.getUploaderName().isEmpty());
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUploaderAvatarUrl() throws Exception {
|
public void testMoreRelatedItems() throws Exception {
|
||||||
assertTrue(extractor.getUploaderAvatarUrl(), extractor.getUploaderAvatarUrl().contains("yt"));
|
BaseListExtractorTest.defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
public void testGetStreamsCount() throws Exception {
|
// PlaylistExtractor
|
||||||
assertTrue("error in the streams count", extractor.getStreamCount() > 100);
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStreams() throws Exception {
|
public void testThumbnailUrl() throws Exception {
|
||||||
List<StreamInfoItem> streams = extractor.getInfoItems().getItemList();
|
final String thumbnailUrl = extractor.getThumbnailUrl();
|
||||||
assertFalse("no streams are received", streams.isEmpty());
|
assertIsSecureUrl(thumbnailUrl);
|
||||||
assertTrue(streams.size() > 60);
|
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt"));
|
||||||
assertFalse(streams.contains(null));
|
}
|
||||||
for(StreamInfoItem item: streams) {
|
|
||||||
assertEquals("Service id doesn't match", YouTube.getServiceId(), item.getServiceId());
|
@Test
|
||||||
assertNotNull("Stream type not set: " + item, item.getStreamType());
|
public void testBannerUrl() throws Exception {
|
||||||
//assertNotEmpty("Upload date not set: " + item, item.getUploadDate());
|
final String bannerUrl = extractor.getBannerUrl();
|
||||||
assertNotEmpty("Uploader name not set: " + item, item.getUploaderName());
|
assertIsSecureUrl(bannerUrl);
|
||||||
assertNotEmpty("Uploader url not set: " + item, item.getUploaderUrl());
|
assertTrue(bannerUrl, bannerUrl.contains("yt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploaderUrl() throws Exception {
|
||||||
|
assertTrue(extractor.getUploaderUrl().contains("youtube.com"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploaderName() throws Exception {
|
||||||
|
final String uploaderName = extractor.getUploaderName();
|
||||||
|
assertTrue(uploaderName, uploaderName.contains("Just Hits"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public static class ImportantVideos implements BasePlaylistExtractorTest {
|
||||||
public void testGetStreamsErrors() throws Exception {
|
private static YoutubePlaylistExtractor extractor;
|
||||||
assertEmptyErrors("errors during stream list extraction", extractor.getInfoItems().getErrors());
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() throws Exception {
|
||||||
|
NewPipe.init(Downloader.getInstance());
|
||||||
|
extractor = (YoutubePlaylistExtractor) YouTube
|
||||||
|
.getPlaylistExtractor("https://www.youtube.com/playlist?list=PLOy0j9AvlVZPto6IkjKfpu0Scx--7PGTC");
|
||||||
|
extractor.fetchPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Additional Testing
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPageInNewExtractor() throws Exception {
|
||||||
|
final PlaylistExtractor newExtractor = YouTube.getPlaylistExtractor(extractor.getCleanUrl());
|
||||||
|
BaseListExtractorTest.defaultTestGetPageInNewExtractor(extractor, newExtractor, YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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
|
||||||
|
public void testCleanUrl() {
|
||||||
|
assertEquals("https://www.youtube.com/playlist?list=PLOy0j9AvlVZPto6IkjKfpu0Scx--7PGTC", extractor.getCleanUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOriginalUrl() {
|
||||||
|
assertEquals("https://www.youtube.com/playlist?list=PLOy0j9AvlVZPto6IkjKfpu0Scx--7PGTC", extractor.getOriginalUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// ListExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRelatedItems() throws Exception {
|
||||||
|
BaseListExtractorTest.defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreRelatedItems() throws Exception {
|
||||||
|
ListExtractor.InfoItemPage<? extends InfoItem> currentPage = BaseListExtractorTest.defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
||||||
|
// Test for 2 more levels
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
currentPage = extractor.getPage(currentPage.getNextPageUrl());
|
||||||
|
BaseListExtractorTest.defaultTestListOfItems(YouTube.getServiceId(), currentPage.getItemsList(), currentPage.getErrors());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlaylistExtractor
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testThumbnailUrl() throws Exception {
|
||||||
|
final String thumbnailUrl = extractor.getThumbnailUrl();
|
||||||
|
assertIsSecureUrl(thumbnailUrl);
|
||||||
|
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHasMoreStreams() throws Exception {
|
|
||||||
// Setup the streams
|
|
||||||
extractor.getInfoItems();
|
|
||||||
assertTrue("extractor didn't have more streams", extractor.hasNextPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test @Ignore
|
|
||||||
public void testGetNextPage() throws Exception {
|
|
||||||
// Setup the streams
|
|
||||||
extractor.getInfoItems();
|
|
||||||
ListExtractor.InfoItemPage<StreamInfoItem> infoItemPage = extractor.getPage(extractor.getNextPageUrl());
|
|
||||||
assertTrue("extractor didn't have next streams", !infoItemPage.getItemsList().isEmpty());
|
|
||||||
assertEmptyErrors("errors occurred during extraction of the next streams", infoItemPage.getErrors());
|
|
||||||
assertTrue("extractor didn't have more streams after getInfoItemPage", extractor.hasNextPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue