forked from j62/ctbrec
1
0
Fork 0

Create a temporary directory for HLS downloads

Create a temporary download directory similar to DASH downloads
This commit is contained in:
0xboobface 2019-12-27 14:26:48 +01:00
parent e8fccb327a
commit 4f852bd5f3
1 changed files with 17 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.Objects;
import java.util.regex.Pattern;
import org.jcodec.containers.mp4.MP4Util;
import org.jcodec.containers.mp4.boxes.MovieBox;
@ -32,6 +33,7 @@ public class MergedHlsDownload extends HlsDownload {
private static final Logger LOG = LoggerFactory.getLogger(MergedHlsDownload.class);
private File finalFile;
private File targetFile;
public MergedHlsDownload(HttpClient client) {
super(client);
@ -46,7 +48,8 @@ public class MergedHlsDownload extends HlsDownload {
Thread.currentThread().interrupt();
}
finalFile = Config.getInstance().getFileForRecording(model, "mp4", startTime);
downloadDir = finalFile.getParentFile().toPath();
targetFile = new File(finalFile.getParentFile(), finalFile.getName() + ".part");
downloadDir = targetFile.toPath();
}
@Override
@ -169,4 +172,17 @@ public class MergedHlsDownload extends HlsDownload {
return Duration.ofSeconds(0);
}
}
@Override
public File getTarget() {
return targetFile;
}
@Override
public String getPath(Model model) {
String absolutePath = targetFile.getAbsolutePath();
String recordingsDir = Config.getInstance().getSettings().recordingsDir;
String relativePath = absolutePath.replaceFirst(Pattern.quote(recordingsDir), "");
return relativePath;
}
}