tests: add tests for channel tab urls

This commit is contained in:
ThetaDev 2023-04-27 12:31:39 +02:00
parent 417b79757f
commit 0e28f2b560
7 changed files with 101 additions and 12 deletions

View File

@ -285,16 +285,15 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
case "videos": case "videos":
// since the videos tab already has its contents fetched, make sure // since the videos tab already has its contents fetched, make sure
// it is in the first position // it is in the first position
String mutName = ""; String name = "";
try { try {
mutName = getName(); name = getName();
} catch (final ParsingException ignored) { } catch (final ParsingException ignored) {
} }
final String name = mutName;
final String url = getUrl();
tabs.add(0, new ReadyChannelTabListLinkHandler(tabUrl, tabs.add(0, new ReadyChannelTabListLinkHandler(tabUrl,
redirectedChannelId, ChannelTabs.VIDEOS, redirectedChannelId, ChannelTabs.VIDEOS,
new VideoTabExtractorBuilder(name, url, tabRenderer))); new VideoTabExtractorBuilder(name, getUrl(), getId(),
tabRenderer)));
break; break;
case "playlists": case "playlists":
addTab.accept(ChannelTabs.PLAYLISTS); addTab.accept(ChannelTabs.PLAYLISTS);
@ -329,12 +328,14 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
implements ReadyChannelTabListLinkHandler.ChannelTabExtractorBuilder { implements ReadyChannelTabListLinkHandler.ChannelTabExtractorBuilder {
private final String channelName; private final String channelName;
private final String channelUrl; private final String channelUrl;
private final String channelId;
private final JsonObject tabRenderer; private final JsonObject tabRenderer;
VideoTabExtractorBuilder(final String channelName, final String channelUrl, VideoTabExtractorBuilder(final String channelName, final String channelUrl,
final JsonObject tabRenderer) { final String channelId, final JsonObject tabRenderer) {
this.channelName = channelName; this.channelName = channelName;
this.channelUrl = channelUrl; this.channelUrl = channelUrl;
this.channelId = channelId;
this.tabRenderer = tabRenderer; this.tabRenderer = tabRenderer;
} }
@ -342,7 +343,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
public ChannelTabExtractor build(final StreamingService service, public ChannelTabExtractor build(final StreamingService service,
final ListLinkHandler linkHandler) { final ListLinkHandler linkHandler) {
return new YoutubeChannelTabExtractor.VideoTabExtractor( return new YoutubeChannelTabExtractor.VideoTabExtractor(
service, linkHandler, tabRenderer, channelName, channelUrl); service, linkHandler, tabRenderer, channelName, channelId, channelUrl);
} }
} }
} }

View File

@ -119,6 +119,24 @@ public class YoutubeChannelTabExtractor extends ChannelTabExtractor {
if (!id.isEmpty()) { if (!id.isEmpty()) {
return id; return id;
} }
final Optional<String> carouselHeaderId = initialData
.getObject("header")
.getObject("carouselHeaderRenderer")
.getArray("contents")
.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
.filter(itm -> itm.has("topicChannelDetailsRenderer"))
.findFirst()
.flatMap(itm ->
Optional.ofNullable(itm.getObject("topicChannelDetailsRenderer")
.getObject("navigationEndpoint")
.getObject("browseEndpoint")
.getString("browseId")));
if (carouselHeaderId.isPresent()) {
return carouselHeaderId.get();
}
} }
if (!isNullOrEmpty(channelId)) { if (!isNullOrEmpty(channelId)) {
@ -357,16 +375,19 @@ public class YoutubeChannelTabExtractor extends ChannelTabExtractor {
public static class VideoTabExtractor extends YoutubeChannelTabExtractor { public static class VideoTabExtractor extends YoutubeChannelTabExtractor {
private final JsonObject tabRenderer; private final JsonObject tabRenderer;
private final String channelName; private final String channelName;
private final String channelId;
private final String channelUrl; private final String channelUrl;
VideoTabExtractor(final StreamingService service, VideoTabExtractor(final StreamingService service,
final ListLinkHandler linkHandler, final ListLinkHandler linkHandler,
final JsonObject tabRenderer, final JsonObject tabRenderer,
final String channelName, final String channelName,
final String channelId,
final String channelUrl) { final String channelUrl) {
super(service, linkHandler); super(service, linkHandler);
this.tabRenderer = tabRenderer; this.tabRenderer = tabRenderer;
this.channelName = channelName; this.channelName = channelName;
this.channelId = channelId;
this.channelUrl = channelUrl; this.channelUrl = channelUrl;
} }
@ -375,6 +396,12 @@ public class YoutubeChannelTabExtractor extends ChannelTabExtractor {
// nothing to do, all data was already fetched and is stored in the link handler // nothing to do, all data was already fetched and is stored in the link handler
} }
@Nonnull
@Override
public String getId() throws ParsingException {
return channelId;
}
@Nonnull @Nonnull
@Override @Override
public String getUrl() throws ParsingException { public String getUrl() throws ParsingException {

View File

@ -83,6 +83,7 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(Bandcamp.getServiceId(), extractor.getServiceId()); assertEquals(Bandcamp.getServiceId(), extractor.getServiceId());
assertEquals(Bandcamp.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -93,15 +94,18 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
@Test @Test
public void testId() throws Exception { public void testId() throws Exception {
assertEquals("2450875064", extractor.getId()); assertEquals("2450875064", extractor.getId());
assertEquals("2450875064", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws Exception { public void testUrl() throws Exception {
assertEquals("https://toupie.bandcamp.com", extractor.getUrl()); assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
assertEquals("https://toupie.bandcamp.com/album", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws Exception { public void testOriginalUrl() throws Exception {
assertEquals("https://toupie.bandcamp.com", extractor.getUrl()); assertEquals("https://toupie.bandcamp.com", extractor.getUrl());
assertEquals("https://toupie.bandcamp.com/album", tabExtractor.getUrl());
} }
} }

View File

@ -37,11 +37,13 @@ public class MediaCCCConferenceExtractorTest {
@Test @Test
public void testGetUrl() throws Exception { public void testGetUrl() throws Exception {
assertEquals("https://media.ccc.de/c/froscon2017", extractor.getUrl()); assertEquals("https://media.ccc.de/c/froscon2017", extractor.getUrl());
assertEquals("https://media.ccc.de/c/froscon2017", tabExtractor.getUrl());
} }
@Test @Test
public void testGetOriginalUrl() throws Exception { public void testGetOriginalUrl() throws Exception {
assertEquals("https://media.ccc.de/c/froscon2017", extractor.getOriginalUrl()); assertEquals("https://media.ccc.de/c/froscon2017", extractor.getOriginalUrl());
assertEquals("https://media.ccc.de/c/froscon2017", tabExtractor.getOriginalUrl());
} }
@Test @Test
@ -77,11 +79,13 @@ public class MediaCCCConferenceExtractorTest {
@Test @Test
public void testGetUrl() throws Exception { public void testGetUrl() throws Exception {
assertEquals("https://media.ccc.de/c/oscal19", extractor.getUrl()); assertEquals("https://media.ccc.de/c/oscal19", extractor.getUrl());
assertEquals("https://media.ccc.de/c/oscal19", tabExtractor.getUrl());
} }
@Test @Test
public void testGetOriginalUrl() throws Exception { public void testGetOriginalUrl() throws Exception {
assertEquals("https://media.ccc.de/c/oscal19", extractor.getOriginalUrl()); assertEquals("https://media.ccc.de/c/oscal19", extractor.getOriginalUrl());
assertEquals("https://media.ccc.de/c/oscal19", tabExtractor.getOriginalUrl());
} }
@Test @Test

View File

@ -49,6 +49,7 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(PeerTube.getServiceId(), extractor.getServiceId()); assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
assertEquals(PeerTube.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -59,16 +60,19 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testId() throws ParsingException { public void testId() throws ParsingException {
assertEquals("video-channels/lqdn_channel@video.lqdn.fr", extractor.getId()); assertEquals("video-channels/lqdn_channel@video.lqdn.fr", extractor.getId());
assertEquals("video-channels/lqdn_channel@video.lqdn.fr", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr", extractor.getUrl()); assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr", extractor.getUrl());
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getOriginalUrl()); assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", extractor.getOriginalUrl());
assertEquals("https://framatube.org/video-channels/lqdn_channel@video.lqdn.fr/videos", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -179,6 +183,7 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(PeerTube.getServiceId(), extractor.getServiceId()); assertEquals(PeerTube.getServiceId(), extractor.getServiceId());
assertEquals(PeerTube.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -189,16 +194,19 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testId() throws ParsingException { public void testId() throws ParsingException {
assertEquals("video-channels/chatsceptique@skeptikon.fr", extractor.getId()); assertEquals("video-channels/chatsceptique@skeptikon.fr", extractor.getId());
assertEquals("video-channels/chatsceptique@skeptikon.fr", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr", extractor.getUrl()); assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr", extractor.getUrl());
assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr/videos", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr", extractor.getOriginalUrl()); assertEquals("https://framatube.org/api/v1/video-channels/chatsceptique@skeptikon.fr", extractor.getOriginalUrl());
assertEquals("https://framatube.org/video-channels/chatsceptique@skeptikon.fr/videos", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////

View File

@ -46,6 +46,7 @@ public class SoundcloudChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
assertEquals(SoundCloud.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -54,18 +55,21 @@ public class SoundcloudChannelExtractorTest {
} }
@Test @Test
public void testId() { public void testId() throws ParsingException {
assertEquals("10494998", extractor.getId()); assertEquals("10494998", extractor.getId());
assertEquals("10494998", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://soundcloud.com/liluzivert", extractor.getUrl()); assertEquals("https://soundcloud.com/liluzivert", extractor.getUrl());
assertEquals("https://soundcloud.com/liluzivert/tracks", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl()); assertEquals("http://soundcloud.com/liluzivert/sets", extractor.getOriginalUrl());
assertEquals("http://soundcloud.com/liluzivert/tracks", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -160,16 +164,18 @@ public class SoundcloudChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(SoundCloud.getServiceId(), extractor.getServiceId()); assertEquals(SoundCloud.getServiceId(), extractor.getServiceId());
assertEquals(SoundCloud.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
public void testName() { public void testName() throws ParsingException {
assertEquals("dubmatix", extractor.getName()); assertEquals("dubmatix", extractor.getName());
} }
@Test @Test
public void testId() { public void testId() throws ParsingException {
assertEquals("542134", extractor.getId()); assertEquals("542134", extractor.getId());
assertEquals("542134", tabExtractor.getId());
} }
@Test @Test

View File

@ -168,6 +168,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(YouTube.getServiceId(), extractor.getServiceId()); assertEquals(YouTube.getServiceId(), extractor.getServiceId());
assertEquals(YouTube.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -178,16 +179,19 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testId() throws Exception { public void testId() throws Exception {
assertEquals("UCYJ61XIK64sp6ZFFS8sctxw", extractor.getId()); assertEquals("UCYJ61XIK64sp6ZFFS8sctxw", extractor.getId());
assertEquals("UCYJ61XIK64sp6ZFFS8sctxw", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", extractor.getUrl()); assertEquals("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", extractor.getUrl());
assertEquals("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("http://www.youtube.com/@Gronkh", extractor.getOriginalUrl()); assertEquals("http://www.youtube.com/@Gronkh", extractor.getOriginalUrl());
assertEquals("/c/gronkh/videos", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -277,6 +281,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(YouTube.getServiceId(), extractor.getServiceId()); assertEquals(YouTube.getServiceId(), extractor.getServiceId());
assertEquals(YouTube.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -287,16 +292,19 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testId() throws Exception { public void testId() throws Exception {
assertEquals("UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getId()); assertEquals("UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getId());
assertEquals("UC6nSFpj9HTCZ5t-N3Rm3-HA", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getUrl()); assertEquals("https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getUrl());
assertEquals("https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://www.youtube.com/user/Vsauce", extractor.getOriginalUrl()); assertEquals("https://www.youtube.com/user/Vsauce", extractor.getOriginalUrl());
assertEquals("/@Vsauce/videos", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -386,6 +394,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(YouTube.getServiceId(), extractor.getServiceId()); assertEquals(YouTube.getServiceId(), extractor.getServiceId());
assertEquals(YouTube.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -396,16 +405,19 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testId() throws Exception { public void testId() throws Exception {
assertEquals("UCsXVk37bltHxD1rDPwtNM8Q", extractor.getId()); assertEquals("UCsXVk37bltHxD1rDPwtNM8Q", extractor.getId());
assertEquals("UCsXVk37bltHxD1rDPwtNM8Q", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getUrl()); assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getUrl());
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getOriginalUrl()); assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getOriginalUrl());
assertEquals("/@kurzgesagt/videos", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -522,6 +534,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(YouTube.getServiceId(), extractor.getServiceId()); assertEquals(YouTube.getServiceId(), extractor.getServiceId());
assertEquals(YouTube.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -532,16 +545,19 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testId() throws Exception { public void testId() throws Exception {
assertEquals("UCEOXxzW2vU0P-0THehuIIeg", extractor.getId()); assertEquals("UCEOXxzW2vU0P-0THehuIIeg", extractor.getId());
assertEquals("UCEOXxzW2vU0P-0THehuIIeg", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", extractor.getUrl()); assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", extractor.getUrl());
assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://www.youtube.com/user/CaptainDisillusion/videos", extractor.getOriginalUrl()); assertEquals("https://www.youtube.com/user/CaptainDisillusion/videos", extractor.getOriginalUrl());
assertEquals("/@CaptainDisillusion/videos", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -629,6 +645,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(YouTube.getServiceId(), extractor.getServiceId()); assertEquals(YouTube.getServiceId(), extractor.getServiceId());
assertEquals(YouTube.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -639,16 +656,19 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testId() throws Exception { public void testId() throws Exception {
assertEquals("UCUaQMQS9lY5lit3vurpXQ6w", extractor.getId()); assertEquals("UCUaQMQS9lY5lit3vurpXQ6w", extractor.getId());
assertEquals("UCUaQMQS9lY5lit3vurpXQ6w", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getUrl()); assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getUrl());
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getOriginalUrl()); assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getOriginalUrl());
assertEquals("/channel/UCUaQMQS9lY5lit3vurpXQ6w/videos", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -721,6 +741,7 @@ public class YoutubeChannelExtractorTest {
public static class CarouselHeader implements BaseChannelExtractorTest { public static class CarouselHeader implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor; private static YoutubeChannelExtractor extractor;
private static ChannelTabExtractor tabExtractor;
@BeforeAll @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
@ -729,6 +750,9 @@ public class YoutubeChannelExtractorTest {
extractor = (YoutubeChannelExtractor) YouTube extractor = (YoutubeChannelExtractor) YouTube
.getChannelExtractor("https://www.youtube.com/channel/UCHF66aWLOxBW4l6VkSrS3cQ"); .getChannelExtractor("https://www.youtube.com/channel/UCHF66aWLOxBW4l6VkSrS3cQ");
extractor.fetchPage(); extractor.fetchPage();
tabExtractor = YouTube.getChannelTabExtractor(extractor.getTabs().get(0));
tabExtractor.fetchPage();
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -738,6 +762,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testServiceId() { public void testServiceId() {
assertEquals(YouTube.getServiceId(), extractor.getServiceId()); assertEquals(YouTube.getServiceId(), extractor.getServiceId());
assertEquals(YouTube.getServiceId(), tabExtractor.getServiceId());
} }
@Test @Test
@ -748,16 +773,19 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testId() throws Exception { public void testId() throws Exception {
assertEquals("UCHF66aWLOxBW4l6VkSrS3cQ", extractor.getId()); assertEquals("UCHF66aWLOxBW4l6VkSrS3cQ", extractor.getId());
assertEquals("UCHF66aWLOxBW4l6VkSrS3cQ", tabExtractor.getId());
} }
@Test @Test
public void testUrl() throws ParsingException { public void testUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UCHF66aWLOxBW4l6VkSrS3cQ", extractor.getUrl()); assertEquals("https://www.youtube.com/channel/UCHF66aWLOxBW4l6VkSrS3cQ", extractor.getUrl());
assertEquals("https://www.youtube.com/channel/UCHF66aWLOxBW4l6VkSrS3cQ", tabExtractor.getUrl());
} }
@Test @Test
public void testOriginalUrl() throws ParsingException { public void testOriginalUrl() throws ParsingException {
assertEquals("https://www.youtube.com/channel/UCHF66aWLOxBW4l6VkSrS3cQ", extractor.getOriginalUrl()); assertEquals("https://www.youtube.com/channel/UCHF66aWLOxBW4l6VkSrS3cQ", extractor.getOriginalUrl());
assertEquals("/@Coachella/videos", tabExtractor.getOriginalUrl());
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -766,12 +794,12 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testRelatedItems() throws Exception { public void testRelatedItems() throws Exception {
defaultTestRelatedItems(extractor); defaultTestRelatedItems(tabExtractor);
} }
@Test @Test
public void testMoreRelatedItems() throws Exception { public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor); defaultTestMoreItems(tabExtractor);
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -807,5 +835,16 @@ public class YoutubeChannelExtractorTest {
public void testVerified() throws Exception { public void testVerified() throws Exception {
assertTrue(extractor.isVerified()); assertTrue(extractor.isVerified());
} }
@Test
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));
assertTrue(tabs.contains(ChannelTabs.CHANNELS));
}
} }
} }