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.Format;
|
||||||
import com.iheartradio.m3u8.ParseException;
|
import com.iheartradio.m3u8.ParseException;
|
||||||
import com.iheartradio.m3u8.ParsingMode;
|
import com.iheartradio.m3u8.ParsingMode;
|
||||||
import com.iheartradio.m3u8.PlaylistError;
|
|
||||||
import com.iheartradio.m3u8.PlaylistException;
|
import com.iheartradio.m3u8.PlaylistException;
|
||||||
import com.iheartradio.m3u8.PlaylistParser;
|
import com.iheartradio.m3u8.PlaylistParser;
|
||||||
import com.iheartradio.m3u8.data.MediaPlaylist;
|
import com.iheartradio.m3u8.data.MediaPlaylist;
|
||||||
|
@ -46,7 +45,6 @@ import ctbrec.Recording.State;
|
||||||
import ctbrec.io.HttpClient;
|
import ctbrec.io.HttpClient;
|
||||||
import ctbrec.io.HttpException;
|
import ctbrec.io.HttpException;
|
||||||
import ctbrec.recorder.PlaylistGenerator;
|
import ctbrec.recorder.PlaylistGenerator;
|
||||||
import ctbrec.recorder.PlaylistGenerator.InvalidPlaylistException;
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
@ -196,53 +194,29 @@ public class HlsDownload extends AbstractHlsDownload {
|
||||||
public void postprocess(Recording recording) {
|
public void postprocess(Recording recording) {
|
||||||
Thread.currentThread().setName("PP " + model.getName());
|
Thread.currentThread().setName("PP " + model.getName());
|
||||||
recording.setStatusWithEvent(State.GENERATING_PLAYLIST);
|
recording.setStatusWithEvent(State.GENERATING_PLAYLIST);
|
||||||
|
try {
|
||||||
generatePlaylist(recording);
|
generatePlaylist(recording);
|
||||||
recording.setStatusWithEvent(State.POST_PROCESSING);
|
recording.setStatusWithEvent(State.POST_PROCESSING);
|
||||||
try {
|
|
||||||
runPostProcessingScript(recording);
|
runPostProcessingScript(recording);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new PostProcessingException(e);
|
throw new PostProcessingException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File generatePlaylist(Recording recording) {
|
protected File generatePlaylist(Recording recording) throws IOException, ParseException, PlaylistException {
|
||||||
File recDir = recording.getAbsoluteFile();
|
File recDir = recording.getAbsoluteFile();
|
||||||
if (!config.getSettings().generatePlaylist) {
|
if (!config.getSettings().generatePlaylist) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistGenerator playlistGenerator = new PlaylistGenerator();
|
PlaylistGenerator playlistGenerator = new PlaylistGenerator();
|
||||||
playlistGenerator.addProgressListener(recording::setProgress);
|
playlistGenerator.addProgressListener(recording::setProgress);
|
||||||
|
|
||||||
try {
|
|
||||||
File playlist = playlistGenerator.generate(recDir);
|
File playlist = playlistGenerator.generate(recDir);
|
||||||
if (playlist != null) {
|
if (playlist != null) {
|
||||||
playlistGenerator.validate(recDir);
|
playlistGenerator.validate(recDir);
|
||||||
}
|
}
|
||||||
recording.setProgress(-1);
|
recording.setProgress(-1);
|
||||||
return playlist;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean splitRecording() {
|
private boolean splitRecording() {
|
||||||
|
|
Loading…
Reference in New Issue