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