From 0fe466bc1a185861ba2f4fafe7751de6abf89f1a Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Sat, 28 Dec 2019 16:58:43 +0100 Subject: [PATCH] Don't catch exceptions in generatePlaylist --- .../recorder/download/hls/HlsDownload.java | 42 ++++--------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/common/src/main/java/ctbrec/recorder/download/hls/HlsDownload.java b/common/src/main/java/ctbrec/recorder/download/hls/HlsDownload.java index e7c53b7e..d0eb5da2 100644 --- a/common/src/main/java/ctbrec/recorder/download/hls/HlsDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/hls/HlsDownload.java @@ -32,7 +32,6 @@ import com.iheartradio.m3u8.Encoding; import com.iheartradio.m3u8.Format; import com.iheartradio.m3u8.ParseException; import com.iheartradio.m3u8.ParsingMode; -import com.iheartradio.m3u8.PlaylistError; import com.iheartradio.m3u8.PlaylistException; import com.iheartradio.m3u8.PlaylistParser; import com.iheartradio.m3u8.data.MediaPlaylist; @@ -46,7 +45,6 @@ import ctbrec.Recording.State; import ctbrec.io.HttpClient; import ctbrec.io.HttpException; import ctbrec.recorder.PlaylistGenerator; -import ctbrec.recorder.PlaylistGenerator.InvalidPlaylistException; import okhttp3.Request; import okhttp3.Response; @@ -196,53 +194,29 @@ public class HlsDownload extends AbstractHlsDownload { public void postprocess(Recording recording) { Thread.currentThread().setName("PP " + model.getName()); recording.setStatusWithEvent(State.GENERATING_PLAYLIST); - generatePlaylist(recording); - recording.setStatusWithEvent(State.POST_PROCESSING); try { + generatePlaylist(recording); + recording.setStatusWithEvent(State.POST_PROCESSING); runPostProcessingScript(recording); } catch (Exception e) { throw new PostProcessingException(e); } } - protected File generatePlaylist(Recording recording) { + protected File generatePlaylist(Recording recording) throws IOException, ParseException, PlaylistException { File recDir = recording.getAbsoluteFile(); if (!config.getSettings().generatePlaylist) { return null; } - PlaylistGenerator playlistGenerator = new PlaylistGenerator(); playlistGenerator.addProgressListener(recording::setProgress); - - try { - File playlist = playlistGenerator.generate(recDir); - if (playlist != null) { - playlistGenerator.validate(recDir); - } - recording.setProgress(-1); - return playlist; - } catch (IOException | ParseException e) { - LOG.error("Couldn't generate playlist file", e); - } catch (PlaylistException e) { - if (e.getErrors().isEmpty()) { - LOG.error("Couldn't generate playlist file", e); - } else { - LOG.error("Playlist contains errors"); - for (PlaylistError error : e.getErrors()) { - LOG.error("Error: {}", error); - } - } - } catch (InvalidPlaylistException e) { - LOG.error("Playlist is invalid and will be deleted", e); - File playlist = new File(recDir, "playlist.m3u8"); - try { - Files.deleteIfExists(playlist.toPath()); - } catch (IOException e1) { - LOG.error("Couldn't delete playlist {}", playlist, e1); - } + File playlist = playlistGenerator.generate(recDir); + if (playlist != null) { + playlistGenerator.validate(recDir); } + recording.setProgress(-1); + return playlist; - return null; } private boolean splitRecording() {