forked from j62/ctbrec
Create a temporary directory for HLS downloads
Create a temporary download directory similar to DASH downloads
This commit is contained in:
parent
e8fccb327a
commit
4f852bd5f3
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue