Add AccountTerminatedException for better error handling of terminated channels

This commit is contained in:
TobiGr
2021-03-22 10:35:05 +01:00
parent 284362fc15
commit bb3861ddce
5 changed files with 73 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import org.schabi.newpipe.downloader.DownloaderFactory;
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.AccountTerminatedException;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -50,6 +51,13 @@ public class YoutubeChannelExtractorTest {
YouTube.getChannelExtractor("https://www.youtube.com/channel/DOESNT-EXIST");
extractor.fetchPage();
}
@Test(expected = AccountTerminatedException.class)
public void accountTerminatedFetch() throws Exception {
final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UC0AuOxCr9TZ0TtEgL1zpIgA");
extractor.fetchPage();
}
}
public static class NotSupported {

View File

@@ -4,10 +4,13 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeFeedExtractor;
import java.io.IOException;
import java.util.Random;
import static org.junit.Assert.assertEquals;
@@ -77,4 +80,20 @@ public class YoutubeFeedExtractorTest {
assertNoMoreItems(extractor);
}
}
public static class NotAvailable {
@BeforeClass
public static void setUp() throws IOException {
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable/"));
}
@Test(expected = ContentNotAvailableException.class)
public void AccountTerminatedFetch() throws Exception {
YoutubeFeedExtractor extractor = (YoutubeFeedExtractor) YouTube
.getFeedExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ");
extractor.fetchPage();
}
}
}