fix tests

This commit is contained in:
ThetaDev 2023-04-14 14:10:26 +02:00
parent c3651bef5c
commit 12ca6a22cf
17 changed files with 132 additions and 53 deletions

View File

@ -4,7 +4,6 @@ import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import java.util.Collections;
import java.util.List;
public class ReadyChannelTabListLinkHandler extends ListLinkHandler {

View File

@ -5,9 +5,7 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;

View File

@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.services.peertube.extractors;
import com.grack.nanojson.JsonObject;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;

View File

@ -11,11 +11,9 @@ import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.downloader.Response;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper;
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelTabLinkHandlerFactory;
import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull;

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.collectItemsFrom;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class PeertubePlaylistExtractor extends PlaylistExtractor {

View File

@ -23,7 +23,6 @@ import javax.annotation.Nonnull;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.collectItemsFrom;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class PeertubeTrendingExtractor extends KioskExtractor<StreamInfoItem> {

View File

@ -284,7 +284,8 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
if (isNullOrEmpty(publishedTimeText)) {
publishedTimeText = getTextFromObject(videoInfo
.getObject("navigationEndpoint")
.getObject("reelWatchEndpoint").getObject("overlay")
.getObject("reelWatchEndpoint")
.getObject("overlay")
.getObject("reelPlayerOverlayRenderer")
.getObject("reelPlayerHeaderSupportedRenderers")
.getObject("reelPlayerHeaderRenderer")

View File

@ -7,31 +7,30 @@ import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
import java.io.IOException;
import java.util.Set;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
private static ChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases");
extractor.fetchPage();
}
@Test
public void testLength() throws ExtractionException, IOException {
assertTrue(extractor.getInitialPage().getItems().size() >= 0);
tabExtractor = Bandcamp.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
@Test
@ -68,12 +67,13 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.TRACKS));
assertTrue(tabs.contains(ChannelTabs.ALBUMS));
}
@Override
public void testRelatedItems() throws Exception {
// not implemented
defaultTestRelatedItems(tabExtractor);
}
@Override

View File

@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -16,12 +17,16 @@ import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
public class MediaCCCConferenceExtractorTest {
public static class FrOSCon2017 {
private static MediaCCCConferenceExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (MediaCCCConferenceExtractor) MediaCCC.getChannelExtractor("https://media.ccc.de/c/froscon2017");
extractor.fetchPage();
tabExtractor = MediaCCC.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
@Test
@ -46,18 +51,22 @@ public class MediaCCCConferenceExtractorTest {
@Test
public void testGetInitalPage() throws Exception {
assertEquals(97, extractor.getInitialPage().getItems().size());
assertEquals(97, tabExtractor.getInitialPage().getItems().size());
}
}
public static class Oscal2019 {
private static MediaCCCConferenceExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (MediaCCCConferenceExtractor) MediaCCC.getChannelExtractor("https://media.ccc.de/c/oscal19");
extractor.fetchPage();
tabExtractor = MediaCCC.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
@Test
@ -82,7 +91,7 @@ public class MediaCCCConferenceExtractorTest {
@Test
public void testGetInitalPage() throws Exception {
assertTrue(extractor.getInitialPage().getItems().size() >= 21);
assertTrue(tabExtractor.getInitialPage().getItems().size() >= 21);
}
}
}

View File

@ -6,6 +6,7 @@ import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
@ -26,6 +27,7 @@ public class PeertubeAccountExtractorTest {
public static class Framasoft implements BaseChannelExtractorTest {
private static PeertubeAccountExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -35,6 +37,9 @@ public class PeertubeAccountExtractorTest {
extractor = (PeertubeAccountExtractor) PeerTube
.getChannelExtractor("https://framatube.org/accounts/framasoft");
extractor.fetchPage();
tabExtractor = PeerTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -72,12 +77,12 @@ public class PeertubeAccountExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -118,12 +123,14 @@ public class PeertubeAccountExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.VIDEOS));
assertTrue(tabs.contains(ChannelTabs.CHANNELS));
}
}
public static class FreeSoftwareFoundation implements BaseChannelExtractorTest {
private static PeertubeAccountExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -133,6 +140,9 @@ public class PeertubeAccountExtractorTest {
extractor = (PeertubeAccountExtractor) PeerTube
.getChannelExtractor("https://framatube.org/api/v1/accounts/fsf");
extractor.fetchPage();
tabExtractor = PeerTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -142,7 +152,9 @@ public class PeertubeAccountExtractorTest {
@Test
public void testGetPageInNewExtractor() throws Exception {
final ChannelExtractor newExtractor = PeerTube.getChannelExtractor(extractor.getUrl());
defaultTestGetPageInNewExtractor(extractor, newExtractor);
newExtractor.fetchPage();
final ChannelTabExtractor newTabExtractor = PeerTube.getChannelTabExtractor(newExtractor.getTabs().get(0));
defaultTestGetPageInNewExtractor(tabExtractor, newTabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -180,12 +192,12 @@ public class PeertubeAccountExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -226,6 +238,7 @@ public class PeertubeAccountExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.VIDEOS));
assertTrue(tabs.contains(ChannelTabs.CHANNELS));
}
}

View File

@ -6,6 +6,7 @@ import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
@ -26,6 +27,7 @@ public class PeertubeChannelExtractorTest {
public static class LaQuadratureDuNet implements BaseChannelExtractorTest {
private static PeertubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -35,6 +37,9 @@ public class PeertubeChannelExtractorTest {
extractor = (PeertubeChannelExtractor) PeerTube
.getChannelExtractor("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos");
extractor.fetchPage();
tabExtractor = PeerTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -72,12 +77,12 @@ public class PeertubeChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -140,6 +145,7 @@ public class PeertubeChannelExtractorTest {
public static class ChatSceptique implements BaseChannelExtractorTest {
private static PeertubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -149,6 +155,9 @@ public class PeertubeChannelExtractorTest {
extractor = (PeertubeChannelExtractor) PeerTube
.getChannelExtractor("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr");
extractor.fetchPage();
tabExtractor = PeerTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -158,7 +167,9 @@ public class PeertubeChannelExtractorTest {
@Test
public void testGetPageInNewExtractor() throws Exception {
final ChannelExtractor newExtractor = PeerTube.getChannelExtractor(extractor.getUrl());
defaultTestGetPageInNewExtractor(extractor, newExtractor);
newExtractor.fetchPage();
final ChannelTabExtractor newTabExtractor = PeerTube.getChannelTabExtractor(newExtractor.getTabs().get(0));
defaultTestGetPageInNewExtractor(tabExtractor, newTabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -196,12 +207,12 @@ public class PeertubeChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////

View File

@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
@ -25,6 +26,7 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.*;
public class SoundcloudChannelExtractorTest {
public static class LilUzi implements BaseChannelExtractorTest {
private static SoundcloudChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -32,6 +34,9 @@ public class SoundcloudChannelExtractorTest {
extractor = (SoundcloudChannelExtractor) SoundCloud
.getChannelExtractor("http://soundcloud.com/liluzivert/sets");
extractor.fetchPage();
tabExtractor = SoundCloud.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -69,12 +74,12 @@ public class SoundcloudChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -115,6 +120,7 @@ public class SoundcloudChannelExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.TRACKS));
assertTrue(tabs.contains(ChannelTabs.PLAYLISTS));
assertTrue(tabs.contains(ChannelTabs.ALBUMS));
}
@ -122,6 +128,7 @@ public class SoundcloudChannelExtractorTest {
public static class DubMatix implements BaseChannelExtractorTest {
private static SoundcloudChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -129,6 +136,9 @@ public class SoundcloudChannelExtractorTest {
extractor = (SoundcloudChannelExtractor) SoundCloud
.getChannelExtractor("https://soundcloud.com/dubmatix");
extractor.fetchPage();
tabExtractor = SoundCloud.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -138,7 +148,9 @@ public class SoundcloudChannelExtractorTest {
@Test
public void testGetPageInNewExtractor() throws Exception {
final ChannelExtractor newExtractor = SoundCloud.getChannelExtractor(extractor.getUrl());
defaultTestGetPageInNewExtractor(extractor, newExtractor);
newExtractor.fetchPage();
final ChannelTabExtractor newTabExtractor = SoundCloud.getChannelTabExtractor(newExtractor.getTabs().get(0));
defaultTestGetPageInNewExtractor(tabExtractor, newTabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -176,12 +188,12 @@ public class SoundcloudChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -222,6 +234,7 @@ public class SoundcloudChannelExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.TRACKS));
assertTrue(tabs.contains(ChannelTabs.PLAYLISTS));
assertTrue(tabs.contains(ChannelTabs.ALBUMS));
}

View File

@ -7,6 +7,7 @@ import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
@ -14,6 +15,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelTabExtractor;
import java.io.IOException;
import java.util.Set;
@ -138,14 +140,14 @@ public class YoutubeChannelExtractorTest {
@Test
void noVideoTab() throws Exception {
final ChannelExtractor extractor = YouTube.getChannelExtractor("https://invidio.us/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ");
extractor.fetchPage();
assertThrows(ContentNotSupportedException.class, extractor::getInitialPage);
assertTrue(extractor.getTabs().isEmpty());
}
}
public static class Gronkh implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -154,6 +156,9 @@ public class YoutubeChannelExtractorTest {
extractor = (YoutubeChannelExtractor) YouTube
.getChannelExtractor("http://www.youtube.com/@Gronkh");
extractor.fetchPage();
tabExtractor = YouTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -191,12 +196,12 @@ public class YoutubeChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -241,6 +246,7 @@ public class YoutubeChannelExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.VIDEOS));
assertTrue(tabs.contains(ChannelTabs.LIVESTREAMS));
assertTrue(tabs.contains(ChannelTabs.PLAYLISTS));
assertTrue(tabs.contains(ChannelTabs.CHANNELS));
@ -250,6 +256,7 @@ public class YoutubeChannelExtractorTest {
// Youtube RED/Premium ad blocking test
public static class VSauce implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -258,6 +265,9 @@ public class YoutubeChannelExtractorTest {
extractor = (YoutubeChannelExtractor) YouTube
.getChannelExtractor("https://www.youtube.com/user/Vsauce");
extractor.fetchPage();
tabExtractor = YouTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -295,12 +305,12 @@ public class YoutubeChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -345,6 +355,7 @@ public class YoutubeChannelExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.VIDEOS));
assertTrue(tabs.contains(ChannelTabs.SHORTS));
assertTrue(tabs.contains(ChannelTabs.LIVESTREAMS));
assertTrue(tabs.contains(ChannelTabs.PLAYLISTS));
@ -354,6 +365,7 @@ public class YoutubeChannelExtractorTest {
public static class Kurzgesagt implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -362,6 +374,9 @@ public class YoutubeChannelExtractorTest {
extractor = (YoutubeChannelExtractor) YouTube
.getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
extractor.fetchPage();
tabExtractor = YouTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -399,12 +414,12 @@ public class YoutubeChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -452,6 +467,7 @@ public class YoutubeChannelExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.VIDEOS));
assertTrue(tabs.contains(ChannelTabs.PLAYLISTS));
assertTrue(tabs.contains(ChannelTabs.CHANNELS));
}
@ -460,6 +476,7 @@ public class YoutubeChannelExtractorTest {
public static class KurzgesagtAdditional {
private static YoutubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -468,17 +485,23 @@ public class YoutubeChannelExtractorTest {
extractor = (YoutubeChannelExtractor) YouTube
.getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
extractor.fetchPage();
tabExtractor = YouTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
@Test
public void testGetPageInNewExtractor() throws Exception {
final ChannelExtractor newExtractor = YouTube.getChannelExtractor(extractor.getUrl());
defaultTestGetPageInNewExtractor(extractor, newExtractor);
newExtractor.fetchPage();
final ChannelTabExtractor newTabExtractor = YouTube.getChannelTabExtractor(newExtractor.getTabs().get(0));
defaultTestGetPageInNewExtractor(tabExtractor, newTabExtractor);
}
}
public static class CaptainDisillusion implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -487,6 +510,9 @@ public class YoutubeChannelExtractorTest {
extractor = (YoutubeChannelExtractor) YouTube
.getChannelExtractor("https://www.youtube.com/user/CaptainDisillusion/videos");
extractor.fetchPage();
tabExtractor = YouTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -524,12 +550,12 @@ public class YoutubeChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
}
/*//////////////////////////////////////////////////////////////////////////
@ -574,6 +600,7 @@ public class YoutubeChannelExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.VIDEOS));
assertTrue(tabs.contains(ChannelTabs.PLAYLISTS));
assertTrue(tabs.contains(ChannelTabs.CHANNELS));
}
@ -581,6 +608,7 @@ public class YoutubeChannelExtractorTest {
public static class RandomChannel implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll
public static void setUp() throws Exception {
@ -589,6 +617,9 @@ public class YoutubeChannelExtractorTest {
extractor = (YoutubeChannelExtractor) YouTube
.getChannelExtractor("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w");
extractor.fetchPage();
tabExtractor = YouTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
}
/*//////////////////////////////////////////////////////////////////////////
@ -626,13 +657,13 @@ public class YoutubeChannelExtractorTest {
@Test
public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor);
defaultTestRelatedItems(tabExtractor);
}
@Test
public void testMoreRelatedItems() {
try {
defaultTestMoreItems(extractor);
defaultTestMoreItems(tabExtractor);
} catch (final Throwable ignored) {
return;
}
@ -682,6 +713,7 @@ public class YoutubeChannelExtractorTest {
public void testTabs() throws Exception {
Set<String> tabs = extractor.getTabs().stream()
.map(linkHandler -> linkHandler.getContentFilters().get(0)).collect(Collectors.toSet());
assertTrue(tabs.contains(ChannelTabs.VIDEOS));
assertTrue(tabs.contains(ChannelTabs.PLAYLISTS));
assertTrue(tabs.contains(ChannelTabs.CHANNELS));
}

View File

@ -6,9 +6,11 @@ import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRela
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.ChannelTabExtractor;
import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.localization.Localization;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
@ -18,6 +20,7 @@ import java.time.temporal.ChronoUnit;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* A class that tests multiple channels and ranges of "time ago".
@ -47,18 +50,23 @@ public class YoutubeChannelLocalizationTest {
for (Localization currentLocalization : supportedLocalizations) {
if (DEBUG) System.out.println("Testing localization = " + currentLocalization);
ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage;
ListExtractor.InfoItemsPage<InfoItem> itemsPage;
try {
final ChannelExtractor extractor = YouTube.getChannelExtractor(channelUrl);
extractor.forceLocalization(currentLocalization);
extractor.fetchPage();
itemsPage = defaultTestRelatedItems(extractor);
final ChannelTabExtractor tabExtractor = YouTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
itemsPage = defaultTestRelatedItems(tabExtractor);
} catch (final Throwable e) {
System.out.println("[!] " + currentLocalization + " → failed");
throw e;
}
final List<StreamInfoItem> items = itemsPage.getItems();
final List<StreamInfoItem> items = itemsPage.getItems().stream()
.filter(s -> s instanceof StreamInfoItem)
.map(s -> ((StreamInfoItem) s)).collect(Collectors.toList());
for (int i = 0; i < items.size(); i++) {
final StreamInfoItem item = items.get(i);
@ -73,7 +81,7 @@ public class YoutubeChannelLocalizationTest {
}
if (DEBUG) System.out.println(debugMessage + "\n");
}
results.put(currentLocalization, itemsPage.getItems());
results.put(currentLocalization, items);
if (DEBUG) System.out.println("\n===============================\n");
}

View File

@ -40,7 +40,7 @@ public class YoutubeStreamExtractorLivestreamTest extends DefaultStreamExtractor
@Override public StreamExtractor extractor() { return extractor; }
@Override public StreamingService expectedService() { return YouTube; }
@Override public String expectedName() { return "lofi hip hop radio - beats to relax/study to"; }
@Override public String expectedName() { return "lofi hip hop radio \uD83D\uDCDA - beats to relax/study to"; }
@Override public String expectedId() { return ID; }
@Override public String expectedUrlContains() { return YoutubeStreamExtractorDefaultTest.BASE_URL + ID; }
@Override public String expectedOriginalUrlContains() { return URL; }