Merge pull request #994 from TeamNewPipe/fix/peertube-subtitles-exception

[PeerTube] Report Exceptions thrown while getting a stream's subtitles
This commit is contained in:
Stypox 2022-12-31 15:01:39 +01:00 committed by GitHub
commit 95cc6aefbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -61,6 +61,8 @@ public class PeertubeStreamExtractor extends StreamExtractor {
private final List<AudioStream> audioStreams = new ArrayList<>();
private final List<VideoStream> videoStreams = new ArrayList<>();
private ParsingException subtitlesException = null;
public PeertubeStreamExtractor(final StreamingService service, final LinkHandler linkHandler)
throws ParsingException {
super(service, linkHandler);
@ -262,13 +264,19 @@ public class PeertubeStreamExtractor extends StreamExtractor {
@Nonnull
@Override
public List<SubtitlesStream> getSubtitlesDefault() {
public List<SubtitlesStream> getSubtitlesDefault() throws ParsingException {
if (subtitlesException != null) {
throw subtitlesException;
}
return subtitles;
}
@Nonnull
@Override
public List<SubtitlesStream> getSubtitles(final MediaFormat format) {
public List<SubtitlesStream> getSubtitles(final MediaFormat format) throws ParsingException {
if (subtitlesException != null) {
throw subtitlesException;
}
return subtitles.stream()
.filter(sub -> sub.getFormat() == format)
.collect(Collectors.toList());
@ -420,8 +428,8 @@ public class PeertubeStreamExtractor extends StreamExtractor {
}
}
}
} catch (final Exception ignored) {
// Ignore all exceptions
} catch (final Exception e) {
subtitlesException = new ParsingException("Could not get subtitles", e);
}
}
}