Skip to content

Commit 9a7c6b7

Browse files
committed
use ContentNotSupportedException for channels without tabs
1 parent a22104c commit 9a7c6b7

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.schabi.newpipe.extractor.StreamingService;
66
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
77
import org.schabi.newpipe.extractor.downloader.Downloader;
8+
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
89
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
910
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1011
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
@@ -310,7 +311,7 @@ private JsonObject getVideoTab() throws ParsingException {
310311
}
311312

312313
if (videoTab == null) {
313-
throw new ParsingException("Could not find Videos tab");
314+
throw new ContentNotSupportedException("This channel has no Videos tab");
314315
}
315316

316317
try {

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import org.schabi.newpipe.DownloaderTestImpl;
66
import org.schabi.newpipe.extractor.NewPipe;
77
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
8-
import org.schabi.newpipe.extractor.channel.ChannelInfo;
98
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
9+
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
10+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
1011
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1112
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
1213
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
1314

14-
import java.util.List;
15+
import java.io.IOException;
1516

1617
import static org.junit.Assert.*;
1718
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
@@ -45,6 +46,20 @@ public void nonExistentFetch() throws Exception {
4546
}
4647
}
4748

49+
public static class NotSupported {
50+
@BeforeClass
51+
public static void setUp() {
52+
NewPipe.init(DownloaderTestImpl.getInstance());
53+
}
54+
55+
@Test(expected = ContentNotSupportedException.class)
56+
public void noVideoTab() throws Exception {
57+
final ChannelExtractor extractor = YouTube.getChannelExtractor("https://invidio.us/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ");
58+
extractor.fetchPage();
59+
extractor.getInitialPage();
60+
}
61+
}
62+
4863
public static class Gronkh implements BaseChannelExtractorTest {
4964
private static YoutubeChannelExtractor extractor;
5065

0 commit comments

Comments
 (0)