From b13027a758c2c4eb0b549c2ec71964508c092fff Mon Sep 17 00:00:00 2001 From: nilaoda Date: Sun, 21 Aug 2022 18:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=B7=E6=B5=81=E5=90=8E=E8=8B=A5=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E6=96=87=E4=BB=B6=E5=A4=B9=E7=A9=BA=E5=88=99=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DownloadManager/SimpleDownloadManager.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index 03ba634..ddc2141 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -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"); }