[PeerTube] Report Exceptions thrown while getting a stream's subtitles

This commit is contained in:
TobiGr 2022-12-03 16:10:45 +01:00
parent 41c8dce452
commit cd3262745d
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);
}
}
}