mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-15 06:40:33 +05:30
Fixed exceptions as requested
This commit is contained in:
parent
310b34558b
commit
2c7acc74f5
@ -148,12 +148,12 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException, JsonParserException {
|
public List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Subtitles> getSubtitles(SubtitlesFormat format) throws IOException, ExtractionException, JsonParserException {
|
public List<Subtitles> getSubtitles(SubtitlesFormat format) throws IOException, ExtractionException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,19 +380,25 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException, JsonParserException {
|
public List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException {
|
||||||
return getSubtitles(SubtitlesFormat.TTML);
|
return getSubtitles(SubtitlesFormat.TTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Subtitles> getSubtitles(SubtitlesFormat format) throws IOException, ExtractionException, JsonParserException {
|
public List<Subtitles> getSubtitles(SubtitlesFormat format) throws IOException, ExtractionException {
|
||||||
JsonObject playerConfig = getPlayerConfig(getPageHtml());
|
JsonObject playerConfig = getPlayerConfig(getPageHtml());
|
||||||
String playerResponse = playerConfig.getObject("args").getString("player_response");
|
String playerResponse = playerConfig.getObject("args").getString("player_response");
|
||||||
|
|
||||||
|
JsonObject captions;
|
||||||
|
try {
|
||||||
// Captions does not exist, return null
|
// Captions does not exist, return null
|
||||||
if (!JsonParser.object().from(playerResponse).has("captions")) return null;
|
if (!JsonParser.object().from(playerResponse).has("captions")) return null;
|
||||||
|
|
||||||
JsonObject captions = JsonParser.object().from(playerResponse).getObject("captions");
|
captions = JsonParser.object().from(playerResponse).getObject("captions");
|
||||||
|
} catch (JsonParserException e) {
|
||||||
|
// Failed to parse subtitles
|
||||||
|
return null;
|
||||||
|
}
|
||||||
JsonArray captionsArray = captions.getObject("playerCaptionsTracklistRenderer").getArray("captionTracks");
|
JsonArray captionsArray = captions.getObject("playerCaptionsTracklistRenderer").getArray("captionTracks");
|
||||||
|
|
||||||
int captionsSize = captionsArray.size();
|
int captionsSize = captionsArray.size();
|
||||||
|
@ -112,9 +112,8 @@ public abstract class StreamExtractor extends Extractor {
|
|||||||
public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException;
|
public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException;
|
||||||
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
|
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
|
||||||
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;
|
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;
|
||||||
public abstract List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException, JsonParserException;
|
public abstract List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException;
|
||||||
|
public abstract List<Subtitles> getSubtitles(SubtitlesFormat format) throws IOException, ExtractionException;
|
||||||
public abstract List<Subtitles> getSubtitles(SubtitlesFormat format) throws IOException, ExtractionException, JsonParserException;
|
|
||||||
|
|
||||||
public abstract StreamType getStreamType() throws ParsingException;
|
public abstract StreamType getStreamType() throws ParsingException;
|
||||||
public abstract StreamInfoItem getNextVideo() throws IOException, ExtractionException;
|
public abstract StreamInfoItem getNextVideo() throws IOException, ExtractionException;
|
||||||
|
@ -107,13 +107,13 @@ public class SoundcloudStreamExtractorDefaultTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException, JsonParserException {
|
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||||
assertTrue(extractor.getSubtitlesDefault() == null);
|
assertTrue(extractor.getSubtitlesDefault() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubtitlesList() throws IOException, ExtractionException, JsonParserException {
|
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||||
assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT) == null);
|
assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT) == null);
|
||||||
}
|
}
|
||||||
|
@ -149,13 +149,13 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException, JsonParserException {
|
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||||
assertTrue(extractor.getSubtitlesDefault() == null);
|
assertTrue(extractor.getSubtitlesDefault() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubtitlesList() throws IOException, ExtractionException, JsonParserException {
|
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||||
assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT) == null);
|
assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT) == null);
|
||||||
}
|
}
|
||||||
|
@ -108,13 +108,13 @@ public class YoutubeStreamExtractorRestrictedTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubtitlesListDefault() throws IOException, ExtractionException, JsonParserException {
|
public void testGetSubtitlesListDefault() throws IOException, ExtractionException {
|
||||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||||
assertTrue(extractor.getSubtitlesDefault() == null);
|
assertTrue(extractor.getSubtitlesDefault() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubtitlesList() throws IOException, ExtractionException, JsonParserException {
|
public void testGetSubtitlesList() throws IOException, ExtractionException {
|
||||||
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
// Video (/view?v=YQHsXMglC9A) set in the setUp() method has no captions => null
|
||||||
assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT) == null);
|
assertTrue(extractor.getSubtitles(SubtitlesFormat.VTT) == null);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user