From 26c74f4392564879246efdee5f62dbc58c95135f Mon Sep 17 00:00:00 2001 From: nilaoda Date: Tue, 1 Nov 2022 00:08:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=8D=E5=86=99=E5=85=A5?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Common/Resource/ResString.cs | 1 + src/N_m3u8DL-RE.Common/Resource/StaticText.cs | 6 ++++++ src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs | 6 ++++-- src/N_m3u8DL-RE/CommandLine/MyOption.cs | 4 ++++ src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs | 4 ++-- src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs | 2 +- src/N_m3u8DL-RE/Util/MergeUtil.cs | 5 +++-- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs index 4dd6535..d43796f 100644 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.cs +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -49,6 +49,7 @@ namespace N_m3u8DL_RE.Common.Resource public static string cmd_saveName { get => GetText("cmd_saveName"); } public static string cmd_savePattern { get => GetText("cmd_savePattern"); } public static string cmd_skipDownload { get => GetText("cmd_skipDownload"); } + public static string cmd_noDateInfo { get => GetText("cmd_noDateInfo"); } public static string cmd_skipMerge { get => GetText("cmd_skipMerge"); } public static string cmd_subFormat { get => GetText("cmd_subFormat"); } public static string cmd_subOnly { get => GetText("cmd_subOnly"); } diff --git a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs index 61f561c..5f9c22c 100644 --- a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs +++ b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs @@ -64,6 +64,12 @@ namespace N_m3u8DL_RE.Common.Resource zhTW: "設置BaseURL", enUS: "Set BaseURL" ), + ["cmd_noDateInfo"] = new TextContainer + ( + zhCN: "混流时不写入日期信息", + zhTW: "混流時不寫入日期訊息", + enUS: "Date information is not written during muxing" + ), ["cmd_appendUrlParams"] = new TextContainer ( zhCN: "将输入Url的Params添加至分片, 对某些网站很有用, 例如 kakao.com", diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index 0530a4a..976cd9f 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine { internal partial class CommandInvoker { - public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20221031"; + public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20221101"; [GeneratedRegex("((best|worst)\\d*|all)")] private static partial Regex ForStrRegex(); @@ -41,6 +41,7 @@ namespace N_m3u8DL_RE.CommandLine private readonly static Option DownloadRetryCount = new(new string[] { "--download-retry-count" }, description: ResString.cmd_downloadRetryCount, getDefaultValue: () => 3) { ArgumentHelpName = "number" }; private readonly static Option SkipMerge = new(new string[] { "--skip-merge" }, description: ResString.cmd_skipMerge, getDefaultValue: () => false); private readonly static Option SkipDownload = new(new string[] { "--skip-download" }, description: ResString.cmd_skipDownload, getDefaultValue: () => false); + private readonly static Option NoDateInfo = new(new string[] { "--no-date-info" }, description: ResString.cmd_noDateInfo, getDefaultValue: () => false); private readonly static Option BinaryMerge = new(new string[] { "--binary-merge" }, description: ResString.cmd_binaryMerge, getDefaultValue: () => false); private readonly static Option DelAfterDone = new(new string[] { "--del-after-done" }, description: ResString.cmd_delAfterDone, getDefaultValue: () => true); private readonly static Option AutoSubtitleFix = new(new string[] { "--auto-subtitle-fix" }, description: ResString.cmd_subtitleFix, getDefaultValue: () => true); @@ -379,6 +380,7 @@ namespace N_m3u8DL_RE.CommandLine UseSystemProxy = bindingContext.ParseResult.GetValueForOption(UseSystemProxy), CustomProxy = bindingContext.ParseResult.GetValueForOption(CustomProxy), LiveWaitTime = bindingContext.ParseResult.GetValueForOption(LiveWaitTime), + NoDateInfo = bindingContext.ParseResult.GetValueForOption(NoDateInfo), }; if (bindingContext.ParseResult.HasOption(CustomHLSMethod)) option.CustomHLSMethod = bindingContext.ParseResult.GetValueForOption(CustomHLSMethod); @@ -439,7 +441,7 @@ namespace N_m3u8DL_RE.CommandLine var rootCommand = new RootCommand(VERSION_INFO) { Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, - BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, + BinaryMerge, DelAfterDone, NoDateInfo, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, FFmpegBinaryPath, LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption, MuxAfterDone, diff --git a/src/N_m3u8DL-RE/CommandLine/MyOption.cs b/src/N_m3u8DL-RE/CommandLine/MyOption.cs index 24cc8b5..2109f65 100644 --- a/src/N_m3u8DL-RE/CommandLine/MyOption.cs +++ b/src/N_m3u8DL-RE/CommandLine/MyOption.cs @@ -37,6 +37,10 @@ namespace N_m3u8DL_RE.CommandLine /// public LogLevel LogLevel { get; set; } /// + /// See: . + /// + public bool NoDateInfo { get; set; } + /// /// See: . /// public bool AutoSelect { get; set; } diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index 3610847..f4d7a99 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -501,7 +501,7 @@ namespace N_m3u8DL_RE.DownloadManager }; } } - mergeSuccess = MergeUtil.MergeByFFmpeg(DownloaderConfig.MyOptions.FFmpegBinaryPath!, files, Path.ChangeExtension(ffOut, null), ext, useAACFilter); + mergeSuccess = MergeUtil.MergeByFFmpeg(DownloaderConfig.MyOptions.FFmpegBinaryPath!, files, Path.ChangeExtension(ffOut, null), ext, useAACFilter, writeDate: !DownloaderConfig.MyOptions.NoDateInfo); if (mergeSuccess) output = ffOut; } } @@ -625,7 +625,7 @@ namespace N_m3u8DL_RE.DownloadManager 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); + else result = MergeUtil.MuxInputsByFFmpeg(DownloaderConfig.MyOptions.FFmpegBinaryPath!, OutputFiles.ToArray(), outPath, DownloaderConfig.MyOptions.MuxToMp4, !DownloaderConfig.MyOptions.NoDateInfo); //完成后删除各轨道文件 if (result && !DownloaderConfig.MyOptions.MuxKeepFiles) { diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs index 24af798..28f1595 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs @@ -710,7 +710,7 @@ namespace N_m3u8DL_RE.DownloadManager 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); + else result = MergeUtil.MuxInputsByFFmpeg(DownloaderConfig.MyOptions.FFmpegBinaryPath!, OutputFiles.ToArray(), outPath, DownloaderConfig.MyOptions.MuxToMp4, !DownloaderConfig.MyOptions.NoDateInfo); //完成后删除各轨道文件 if (result && !DownloaderConfig.MyOptions.MuxKeepFiles) { diff --git a/src/N_m3u8DL-RE/Util/MergeUtil.cs b/src/N_m3u8DL-RE/Util/MergeUtil.cs index 965d73d..3880392 100644 --- a/src/N_m3u8DL-RE/Util/MergeUtil.cs +++ b/src/N_m3u8DL-RE/Util/MergeUtil.cs @@ -175,7 +175,7 @@ namespace N_m3u8DL_RE.Util return false; } - public static bool MuxInputsByFFmpeg(string binary, OutputFile[] files, string outputPath, bool mp4) + public static bool MuxInputsByFFmpeg(string binary, OutputFile[] files, string outputPath, bool mp4, bool dateinfo) { var ext = mp4 ? "mp4" : "mkv"; string dateString = DateTime.Now.ToString("o"); @@ -223,7 +223,8 @@ namespace N_m3u8DL_RE.Util streamIndex++; } - command.Append($" -metadata date=\"{dateString}\" -ignore_unknown -copy_unknown "); + if(dateinfo) command.Append($" -metadata date=\"{dateString}\" "); + command.Append($" -ignore_unknown -copy_unknown "); command.Append($" \"{outputPath}.{ext}\""); InvokeFFmpeg(binary, command.ToString(), Environment.CurrentDirectory);