混流后若临时文件夹空则删除

This commit is contained in:
nilaoda 2022-08-21 18:22:01 +08:00
parent f7d20c3dfb
commit b13027a758
1 changed files with 12 additions and 2 deletions

View File

@ -564,11 +564,21 @@ namespace N_m3u8DL_RE.DownloadManager
//混流
if (success && OutputFiles.Count > 0)
{
var saveDir = DownloaderConfig.SaveDir ?? Environment.CurrentDirectory;
var outName = $"{DownloaderConfig.SaveName ?? NowDateTime.ToString("yyyy-MM-dd_HH-mm-ss")}";
var outPath = Path.Combine(saveDir, outName);
Logger.WarnMarkUp($"Muxing to [grey]{outName.EscapeMarkup()}.mkv[/]");
var result = MergeUtil.MuxInputsByFFmpeg(DownloaderConfig.FFmpegBinaryPath!, OutputFiles.ToArray(), outName);
var result = MergeUtil.MuxInputsByFFmpeg(DownloaderConfig.FFmpegBinaryPath!, OutputFiles.ToArray(), outPath);
//完成后删除各轨道文件
if (result) OutputFiles.ForEach(f => File.Delete(f.FilePath));
if (result)
{
OutputFiles.ForEach(f => File.Delete(f.FilePath));
var tmpDir = DownloaderConfig.TmpDir ?? Environment.CurrentDirectory;
if (!Directory.EnumerateFiles(tmpDir).Any())
{
Directory.Delete(tmpDir);
}
}
else Logger.ErrorMarkUp($"Mux failed");
}