forked from j62/ctbrec
Fix NPE in MergedHlsDownload
This commit is contained in:
parent
d48498e715
commit
5b2ddfb825
|
@ -11,6 +11,7 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jcodec.containers.mp4.MP4Util;
|
||||
import org.jcodec.containers.mp4.boxes.MovieBox;
|
||||
|
@ -55,18 +56,18 @@ public class MergedHlsDownload extends HlsDownload {
|
|||
|
||||
@Override
|
||||
public void postprocess(ctbrec.Recording recording) {
|
||||
File playlist = super.generatePlaylist(recording);
|
||||
File dir = playlist.getParentFile();
|
||||
|
||||
try {
|
||||
File playlist = super.generatePlaylist(recording);
|
||||
Objects.requireNonNull(playlist, "Generated playlist is null");
|
||||
|
||||
postprocess(playlist, finalFile);
|
||||
String recordingsDir = Config.getInstance().getSettings().recordingsDir;
|
||||
String path = finalFile.getAbsolutePath().substring(recordingsDir.length());
|
||||
recording.setPath(path);
|
||||
File dir = playlist.getParentFile();
|
||||
if (dir.list().length == 0) {
|
||||
RecordingManager.deleteEmptyParents(dir);
|
||||
}
|
||||
|
||||
runPostProcessingScript(recording);
|
||||
} catch (Exception e) {
|
||||
throw new PostProcessingException(e);
|
||||
|
@ -93,7 +94,7 @@ public class MergedHlsDownload extends HlsDownload {
|
|||
int exitCode = ffmpeg.waitFor();
|
||||
if (exitCode == 0) {
|
||||
Files.delete(playlist.toPath());
|
||||
File[] segments = dir.listFiles((directory, filename) -> filename.endsWith(".ts"));
|
||||
File[] segments = dir.listFiles((directory, filename) -> filename.endsWith(".ts") || filename.endsWith(".corrupt"));
|
||||
for (File segment : segments) {
|
||||
Files.delete(segment.toPath());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue