forked from j62/ctbrec
Don't catch exceptions in generatePlaylist
This commit is contained in:
parent
a3dee454a5
commit
0fe466bc1a
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue