[YouTube] Detect when a stream is deleted or doesn't exist
Added a test case as well.
This commit is contained in:
@@ -7,6 +7,7 @@ import org.schabi.newpipe.DownloaderTestImpl;
|
||||
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
@@ -56,6 +57,27 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
*/
|
||||
public class YoutubeStreamExtractorDefaultTest {
|
||||
|
||||
public static class NotAvailable {
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test(expected = ContentNotAvailableException.class)
|
||||
public void nonExistentFetch() throws Exception {
|
||||
final StreamExtractor extractor =
|
||||
YouTube.getStreamExtractor("https://www.youtube.com/watch?v=don-t-exist");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
|
||||
@Test(expected = ParsingException.class)
|
||||
public void invalidId() throws Exception {
|
||||
final StreamExtractor extractor =
|
||||
YouTube.getStreamExtractor("https://www.youtube.com/watch?v=INVALID_ID_INVALID_ID");
|
||||
extractor.fetchPage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link StreamExtractor}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user