From d9f72e51e11d78d4d5b240e0113ec9bf6f609a8e Mon Sep 17 00:00:00 2001 From: nilaoda Date: Thu, 1 Sep 2022 11:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=96=87=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E4=B8=AD=E4=B8=8D=E5=86=8D=E5=A2=9E=E5=8A=A0=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=20#18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DownloadManager/SimpleDownloadManager.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index 57f7dd7..4dcaa4c 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -126,7 +126,7 @@ namespace N_m3u8DL_RE.DownloadManager var dirName = $"{DownloaderConfig.MyOptions.SaveName ?? NowDateTime.ToString("yyyy-MM-dd_HH-mm-ss")}_{task.Id}_{streamSpec.GroupId}_{streamSpec.Codecs}_{streamSpec.Bandwidth}_{streamSpec.Language}"; var tmpDir = Path.Combine(DownloaderConfig.MyOptions.TmpDir ?? Environment.CurrentDirectory, dirName); var saveDir = DownloaderConfig.MyOptions.SaveDir ?? Environment.CurrentDirectory; - var saveName = DownloaderConfig.MyOptions.SaveName != null ? $"{DownloaderConfig.MyOptions.SaveName}.{type}.{streamSpec.Language}".TrimEnd('.') : dirName; + var saveName = DownloaderConfig.MyOptions.SaveName != null ? $"{DownloaderConfig.MyOptions.SaveName}.{streamSpec.Language}".TrimEnd('.') : dirName; var headers = DownloaderConfig.Headers; //mp4decrypt @@ -623,9 +623,10 @@ namespace N_m3u8DL_RE.DownloadManager } OutputFiles.ForEach(f => Logger.WarnMarkUp($"[grey]{Path.GetFileName(f.FilePath).EscapeMarkup()}[/]")); var saveDir = DownloaderConfig.MyOptions.SaveDir ?? Environment.CurrentDirectory; - var outName = $"{DownloaderConfig.MyOptions.SaveName ?? NowDateTime.ToString("yyyy-MM-dd_HH-mm-ss")}"; + var ext = DownloaderConfig.MyOptions.MuxToMp4 ? ".mp4" : ".mkv"; + var outName = $"{DownloaderConfig.MyOptions.SaveName ?? NowDateTime.ToString("yyyy-MM-dd_HH-mm-ss")}.MUX"; var outPath = Path.Combine(saveDir, outName); - Logger.WarnMarkUp($"Muxing to [grey]{outName.EscapeMarkup()}.{(DownloaderConfig.MyOptions.MuxToMp4 ? "mp4" : "mkv")}[/]"); + Logger.WarnMarkUp($"Muxing to [grey]{outName.EscapeMarkup()}{ext}[/]"); var result = false; if (DownloaderConfig.MyOptions.UseMkvmerge) result = MergeUtil.MuxInputsByMkvmerge(DownloaderConfig.MyOptions.MkvmergeBinaryPath!, OutputFiles.ToArray(), outPath); else result = MergeUtil.MuxInputsByFFmpeg(DownloaderConfig.MyOptions.FFmpegBinaryPath!, OutputFiles.ToArray(), outPath, DownloaderConfig.MyOptions.MuxToMp4); @@ -638,6 +639,13 @@ namespace N_m3u8DL_RE.DownloadManager SafeDeleteDir(tmpDir); } else Logger.ErrorMarkUp($"Mux failed"); + //判断是否要改名 + var newPath = Path.ChangeExtension(outPath, ext); + if (result && !File.Exists(newPath)) + { + Logger.WarnMarkUp($"Rename to [grey]{Path.GetFileName(newPath).EscapeMarkup()}[/]"); + File.Move(outPath + ext, newPath); + } } return success;