2017-08-05 16:15:36 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.youtube;
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2017-12-07 02:09:46 +01:00
|
|
|
import org.junit.BeforeClass;
|
2017-08-05 10:03:56 +02:00
|
|
|
import org.junit.Test;
|
|
|
|
import org.schabi.newpipe.Downloader;
|
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
2018-03-04 21:26:13 +01:00
|
|
|
import org.schabi.newpipe.extractor.ServiceList;
|
2017-08-11 03:23:09 +02:00
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
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.services.BaseChannelExtractorTest;
|
2018-05-08 21:19:03 +02:00
|
|
|
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2017-08-08 17:01:50 +02:00
|
|
|
import static org.junit.Assert.*;
|
2018-03-04 21:26:13 +01:00
|
|
|
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-08-05 10:03:56 +02:00
|
|
|
/**
|
2017-08-11 03:23:09 +02:00
|
|
|
* Test for {@link ChannelExtractor}
|
2017-08-05 10:03:56 +02:00
|
|
|
*/
|
2017-08-11 03:23:09 +02:00
|
|
|
public class YoutubeChannelExtractorTest {
|
2018-03-04 21:26:13 +01:00
|
|
|
public static class Gronkh implements BaseChannelExtractorTest {
|
|
|
|
private static YoutubeChannelExtractor extractor;
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(Downloader.getInstance());
|
|
|
|
extractor = (YoutubeChannelExtractor) YouTube
|
|
|
|
.getChannelExtractor("http://www.youtube.com/user/Gronkh");
|
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
|
|
|
assertEquals("Gronkh", extractor.getName());
|
|
|
|
}
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
|
|
|
assertEquals("UCYJ61XIK64sp6ZFFS8sctxw", extractor.getId());
|
|
|
|
}
|
2017-08-16 04:56:10 +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/channel/UCYJ61XIK64sp6ZFFS8sctxw", extractor.getUrl());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
2017-08-16 04:56:10 +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/user/Gronkh", extractor.getOriginalUrl());
|
|
|
|
}
|
2017-08-07 19:00:36 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-05 10:03:56 +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-05 10:03:56 +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-05 10:03:56 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@Test
|
|
|
|
public void testDescription() throws Exception {
|
|
|
|
assertTrue(extractor.getDescription().contains("Zart im Schmelz und süffig im Abgang. Ungebremster Spieltrieb"));
|
|
|
|
}
|
2017-08-05 10:03:56 +02:00
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
@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);
|
|
|
|
}
|
2018-04-07 16:45:07 +02:00
|
|
|
|
2018-08-04 14:20:27 +02:00
|
|
|
@Test
|
|
|
|
public void testChannelDonation() throws Exception {
|
|
|
|
// this needs to be ignored since wed have to upgrade channel extractor to the new yt interface
|
|
|
|
// in order to make this work
|
|
|
|
assertTrue(extractor.getDonationLinks().length == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Youtube RED/Premium ad blocking test
|
|
|
|
public static class VSauce implements BaseChannelExtractorTest {
|
|
|
|
private static YoutubeChannelExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(Downloader.getInstance());
|
|
|
|
extractor = (YoutubeChannelExtractor) YouTube
|
|
|
|
.getChannelExtractor("https://www.youtube.com/user/Vsauce");
|
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
|
|
|
assertEquals("Vsauce", extractor.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
|
|
|
assertEquals("UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testOriginalUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/user/Vsauce", extractor.getOriginalUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ListExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRelatedItems() throws Exception {
|
|
|
|
defaultTestRelatedItems(extractor, YouTube.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMoreRelatedItems() throws Exception {
|
|
|
|
defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDescription() throws Exception {
|
|
|
|
assertTrue("What it actually was: " + extractor.getDescription(),
|
|
|
|
extractor.getDescription().contains("Our World is Amazing. Questions? Ideas? Tweet me:"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@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=UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getFeedUrl());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSubscriberCount() throws Exception {
|
|
|
|
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 0);
|
|
|
|
}
|
|
|
|
|
2018-04-07 16:45:07 +02:00
|
|
|
@Test
|
|
|
|
public void testChannelDonation() throws Exception {
|
2018-04-07 21:36:20 +02:00
|
|
|
// this needs to be ignored since wed have to upgrade channel extractor to the new yt interface
|
|
|
|
// in order to make this work
|
2018-04-08 15:58:42 +02:00
|
|
|
assertTrue(extractor.getDonationLinks().length == 0);
|
2018-04-07 16:45:07 +02:00
|
|
|
}
|
2017-08-05 10:03:56 +02:00
|
|
|
}
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
public static class Kurzgesagt implements BaseChannelExtractorTest {
|
|
|
|
private static YoutubeChannelExtractor extractor;
|
|
|
|
|
|
|
|
@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 {
|
2018-05-06 14:08:50 +02:00
|
|
|
final ChannelExtractor newExtractor = YouTube.getChannelExtractor(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.startsWith("Kurzgesagt"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
|
|
|
assertEquals("UCsXVk37bltHxD1rDPwtNM8Q", extractor.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
public void testUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", 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/channel/UCsXVk37bltHxD1rDPwtNM8Q", 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-04 22:22:27 +01:00
|
|
|
defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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);
|
|
|
|
}
|
2018-04-07 16:45:07 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testChannelDonation() throws Exception {
|
2018-04-08 15:58:42 +02:00
|
|
|
assertTrue(extractor.getDonationLinks().length == 1);
|
2018-04-07 16:45:07 +02:00
|
|
|
}
|
2017-08-05 10:03:56 +02:00
|
|
|
}
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
public static class CaptainDisillusion implements BaseChannelExtractorTest {
|
|
|
|
private static YoutubeChannelExtractor extractor;
|
|
|
|
|
|
|
|
@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
|
2018-05-06 14:08:50 +02:00
|
|
|
public void testUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", 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/user/CaptainDisillusion/videos", 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-04 22:22:27 +01:00
|
|
|
defaultTestMoreItems(extractor, ServiceList.YouTube.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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);
|
|
|
|
}
|
2018-02-26 16:49:15 +01:00
|
|
|
}
|
|
|
|
|
2018-03-04 21:26:13 +01:00
|
|
|
public static class RandomChannel implements BaseChannelExtractorTest {
|
|
|
|
private static YoutubeChannelExtractor extractor;
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUp() throws Exception {
|
|
|
|
NewPipe.init(Downloader.getInstance());
|
|
|
|
extractor = (YoutubeChannelExtractor) YouTube
|
|
|
|
.getChannelExtractor("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w");
|
|
|
|
extractor.fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Extractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testServiceId() {
|
|
|
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testName() throws Exception {
|
|
|
|
assertEquals("random channel", extractor.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testId() throws Exception {
|
|
|
|
assertEquals("UCUaQMQS9lY5lit3vurpXQ6w", extractor.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-05-06 14:08:50 +02:00
|
|
|
public void testUrl() throws ParsingException {
|
|
|
|
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", 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/channel/UCUaQMQS9lY5lit3vurpXQ6w", 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() {
|
|
|
|
try {
|
2018-03-04 22:22:27 +01:00
|
|
|
defaultTestMoreItems(extractor, YouTube.getServiceId());
|
2018-03-04 21:26:13 +01:00
|
|
|
} catch (Throwable ignored) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fail("This channel doesn't have more items, it should throw an error");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// ChannelExtractor
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
|
|
|
@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);
|
|
|
|
}
|
2018-04-07 16:45:07 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testChannelDonation() throws Exception {
|
|
|
|
assertTrue(extractor.getDonationLinks().length == 0);
|
|
|
|
}
|
2017-08-05 10:03:56 +02:00
|
|
|
}
|
2018-03-04 21:26:13 +01:00
|
|
|
};
|
|
|
|
|