From f6bab9cdad12263ce60915daeddbcd63e0b8d947 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Fri, 2 Dec 2022 16:31:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Common/Resource/ResString.cs | 2 ++ src/N_m3u8DL-RE.Common/Resource/StaticText.cs | 12 +++++++++ src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs | 26 ++++++++++++++++++- src/N_m3u8DL-RE/CommandLine/MyOption.cs | 17 ++++++++++++ src/N_m3u8DL-RE/Program.cs | 9 +++++++ 5 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs index a717a86..34d2040 100644 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.cs +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -69,6 +69,7 @@ namespace N_m3u8DL_RE.Common.Resource public static string cmd_customProxy { get => GetText("cmd_customProxy"); } public static string cmd_liveKeepSegments { get => GetText("cmd_liveKeepSegments"); } public static string cmd_liveRecordLimit { get => GetText("cmd_liveRecordLimit"); } + public static string cmd_taskStartAt { get => GetText("cmd_taskStartAt"); } public static string cmd_liveWaitTime { get => GetText("cmd_liveWaitTime"); } public static string cmd_liveRealTimeMerge { get => GetText("cmd_liveRealTimeMerge"); } public static string cmd_livePerformAsVod { get => GetText("cmd_livePerformAsVod"); } @@ -79,6 +80,7 @@ namespace N_m3u8DL_RE.Common.Resource public static string realTimeDecMessage { get => GetText("realTimeDecMessage"); } public static string liveLimitReached { get => GetText("liveLimitReached"); } public static string saveName { get => GetText("saveName"); } + public static string taskStartAt { get => GetText("taskStartAt"); } public static string partMerge { get => GetText("partMerge"); } public static string fetch { get => GetText("fetch"); } public static string ffmpegMerge { get => GetText("ffmpegMerge"); } diff --git a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs index 6675761..64de565 100644 --- a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs +++ b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs @@ -22,6 +22,12 @@ namespace N_m3u8DL_RE.Common.Resource zhTW: "檢測到新版本,請盡快升級!", enUS: "New version detected!" ), + ["taskStartAt"] = new TextContainer + ( + zhCN: "程序将等待,直到:", + zhTW: "程序將等待,直到:", + enUS: "The program will wait until: " + ), ["autoBinaryMerge"] = new TextContainer ( zhCN: "检测到fMP4,自动开启二进制合并", @@ -316,6 +322,12 @@ namespace N_m3u8DL_RE.Common.Resource zhTW: "錄製直播時的錄製時長限制", enUS: "Recording time limit when recording live" ), + ["cmd_taskStartAt"] = new TextContainer + ( + zhCN: "在此时间之前不会开始执行任务", + zhTW: "在此時間之前不會開始執行任務", + enUS: "Task execution will not start before this time" + ), ["cmd_useShakaPackager"] = new TextContainer ( zhCN: "解密时使用shaka-packager替代mp4decrypt", diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index 45f1e12..7920113 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -68,6 +68,9 @@ namespace N_m3u8DL_RE.CommandLine private readonly static Option CustomHLSKey = new(name: "--custom-hls-key", description: ResString.cmd_customHLSKey, parseArgument: ParseHLSCustomKey) { ArgumentHelpName = "FILE|HEX|BASE64" }; private readonly static Option CustomHLSIv = new(name: "--custom-hls-iv", description: ResString.cmd_customHLSIv, parseArgument: ParseHLSCustomKey) { ArgumentHelpName = "FILE|HEX|BASE64" }; + //任务开始时间 + private readonly static Option TaskStartAt = new(new string[] { "--task-start-at" }, description: ResString.cmd_taskStartAt, parseArgument: ParseStartTime) { ArgumentHelpName = "yyyyMMddHHmmss" }; + //直播相关 private readonly static Option LivePerformAsVod = new(new string[] { "--live-perform-as-vod" }, description: ResString.cmd_livePerformAsVod, getDefaultValue: () => false); @@ -163,6 +166,26 @@ namespace N_m3u8DL_RE.CommandLine } } + /// + /// 解析任务开始时间 + /// + /// + /// + private static DateTime? ParseStartTime(ArgumentResult result) + { + var input = result.Tokens.First().Value; + try + { + CultureInfo provider = CultureInfo.InvariantCulture; + return DateTime.ParseExact(input, "yyyyMMddHHmmss", provider); + } + catch (Exception) + { + result.ErrorMessage = "error in parse TaskStartTime: " + input; + return null; + } + } + private static string? ParseSaveName(ArgumentResult result) { var input = result.Tokens.First().Value; @@ -391,6 +414,7 @@ namespace N_m3u8DL_RE.CommandLine LiveRealTimeMerge = bindingContext.ParseResult.GetValueForOption(LiveRealTimeMerge), LiveKeepSegments = bindingContext.ParseResult.GetValueForOption(LiveKeepSegments), LiveRecordLimit = bindingContext.ParseResult.GetValueForOption(LiveRecordLimit), + TaskStartAt = bindingContext.ParseResult.GetValueForOption(TaskStartAt), LivePerformAsVod = bindingContext.ParseResult.GetValueForOption(LivePerformAsVod), UseSystemProxy = bindingContext.ParseResult.GetValueForOption(UseSystemProxy), CustomProxy = bindingContext.ParseResult.GetValueForOption(CustomProxy), @@ -460,7 +484,7 @@ namespace N_m3u8DL_RE.CommandLine FFmpegBinaryPath, LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption, MuxAfterDone, - CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, + CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, TaskStartAt, LivePerformAsVod, LiveRealTimeMerge, LiveKeepSegments, LiveRecordLimit, LiveWaitTime, MuxImports, VideoFilter, AudioFilter, SubtitleFilter, DropVideoFilter, DropAudioFilter, DropSubtitleFilter, MoreHelp }; diff --git a/src/N_m3u8DL-RE/CommandLine/MyOption.cs b/src/N_m3u8DL-RE/CommandLine/MyOption.cs index 2109f65..037d1e9 100644 --- a/src/N_m3u8DL-RE/CommandLine/MyOption.cs +++ b/src/N_m3u8DL-RE/CommandLine/MyOption.cs @@ -61,6 +61,10 @@ namespace N_m3u8DL_RE.CommandLine /// public TimeSpan? LiveRecordLimit { get; set; } /// + /// See: . + /// + public DateTime? TaskStartAt { get; set; } + /// /// See: . /// public bool SkipMerge { get; set; } @@ -177,14 +181,26 @@ namespace N_m3u8DL_RE.CommandLine /// public StreamFilter? VideoFilter { get; set; } /// + /// See: . + /// + public StreamFilter? DropVideoFilter { get; set; } + /// /// See: . /// public StreamFilter? AudioFilter { get; set; } /// + /// See: . + /// + public StreamFilter? DropAudioFilter { get; set; } + /// /// See: . /// public StreamFilter? SubtitleFilter { get; set; } /// + /// See: . + /// + public StreamFilter? DropSubtitleFilter { get; set; } + /// /// See: . /// public EncryptMethod? CustomHLSMethod { get; set; } @@ -205,5 +221,6 @@ namespace N_m3u8DL_RE.CommandLine /// public int? LiveWaitTime { get; set; } public bool MuxKeepFiles { get; set; } + //public bool LiveWriteHLS { get; set; } = true; } } \ No newline at end of file diff --git a/src/N_m3u8DL-RE/Program.cs b/src/N_m3u8DL-RE/Program.cs index df19cf7..feab8ed 100644 --- a/src/N_m3u8DL-RE/Program.cs +++ b/src/N_m3u8DL-RE/Program.cs @@ -165,6 +165,15 @@ namespace N_m3u8DL_RE //for www.nowehoryzonty.pl parserConfig.UrlProcessors.Insert(0, new NowehoryzontyUrlProcessor()); + //等待任务开始时间 + if (option.TaskStartAt != null && option.TaskStartAt > DateTime.Now) + { + Logger.InfoMarkUp(ResString.taskStartAt + option.TaskStartAt); + while (option.TaskStartAt > DateTime.Now) + { + await Task.Delay(1000); + } + } var url = option.Input;