支持设置任务开始时间

This commit is contained in:
nilaoda 2022-12-02 16:31:02 +08:00
parent a9925e44bb
commit f6bab9cdad
5 changed files with 65 additions and 1 deletions

View File

@ -69,6 +69,7 @@ namespace N_m3u8DL_RE.Common.Resource
public static string cmd_customProxy { get => GetText("cmd_customProxy"); } public static string cmd_customProxy { get => GetText("cmd_customProxy"); }
public static string cmd_liveKeepSegments { get => GetText("cmd_liveKeepSegments"); } public static string cmd_liveKeepSegments { get => GetText("cmd_liveKeepSegments"); }
public static string cmd_liveRecordLimit { get => GetText("cmd_liveRecordLimit"); } 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_liveWaitTime { get => GetText("cmd_liveWaitTime"); }
public static string cmd_liveRealTimeMerge { get => GetText("cmd_liveRealTimeMerge"); } public static string cmd_liveRealTimeMerge { get => GetText("cmd_liveRealTimeMerge"); }
public static string cmd_livePerformAsVod { get => GetText("cmd_livePerformAsVod"); } 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 realTimeDecMessage { get => GetText("realTimeDecMessage"); }
public static string liveLimitReached { get => GetText("liveLimitReached"); } public static string liveLimitReached { get => GetText("liveLimitReached"); }
public static string saveName { get => GetText("saveName"); } public static string saveName { get => GetText("saveName"); }
public static string taskStartAt { get => GetText("taskStartAt"); }
public static string partMerge { get => GetText("partMerge"); } public static string partMerge { get => GetText("partMerge"); }
public static string fetch { get => GetText("fetch"); } public static string fetch { get => GetText("fetch"); }
public static string ffmpegMerge { get => GetText("ffmpegMerge"); } public static string ffmpegMerge { get => GetText("ffmpegMerge"); }

View File

@ -22,6 +22,12 @@ namespace N_m3u8DL_RE.Common.Resource
zhTW: "檢測到新版本,請盡快升級!", zhTW: "檢測到新版本,請盡快升級!",
enUS: "New version detected!" enUS: "New version detected!"
), ),
["taskStartAt"] = new TextContainer
(
zhCN: "程序将等待,直到:",
zhTW: "程序將等待,直到:",
enUS: "The program will wait until: "
),
["autoBinaryMerge"] = new TextContainer ["autoBinaryMerge"] = new TextContainer
( (
zhCN: "检测到fMP4自动开启二进制合并", zhCN: "检测到fMP4自动开启二进制合并",
@ -316,6 +322,12 @@ namespace N_m3u8DL_RE.Common.Resource
zhTW: "錄製直播時的錄製時長限制", zhTW: "錄製直播時的錄製時長限制",
enUS: "Recording time limit when recording live" 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 ["cmd_useShakaPackager"] = new TextContainer
( (
zhCN: "解密时使用shaka-packager替代mp4decrypt", zhCN: "解密时使用shaka-packager替代mp4decrypt",

View File

@ -68,6 +68,9 @@ namespace N_m3u8DL_RE.CommandLine
private readonly static Option<byte[]?> CustomHLSKey = new(name: "--custom-hls-key", description: ResString.cmd_customHLSKey, parseArgument: ParseHLSCustomKey) { ArgumentHelpName = "FILE|HEX|BASE64" }; private readonly static Option<byte[]?> CustomHLSKey = new(name: "--custom-hls-key", description: ResString.cmd_customHLSKey, parseArgument: ParseHLSCustomKey) { ArgumentHelpName = "FILE|HEX|BASE64" };
private readonly static Option<byte[]?> CustomHLSIv = new(name: "--custom-hls-iv", description: ResString.cmd_customHLSIv, parseArgument: ParseHLSCustomKey) { ArgumentHelpName = "FILE|HEX|BASE64" }; private readonly static Option<byte[]?> CustomHLSIv = new(name: "--custom-hls-iv", description: ResString.cmd_customHLSIv, parseArgument: ParseHLSCustomKey) { ArgumentHelpName = "FILE|HEX|BASE64" };
//任务开始时间
private readonly static Option<DateTime?> TaskStartAt = new(new string[] { "--task-start-at" }, description: ResString.cmd_taskStartAt, parseArgument: ParseStartTime) { ArgumentHelpName = "yyyyMMddHHmmss" };
//直播相关 //直播相关
private readonly static Option<bool> LivePerformAsVod = new(new string[] { "--live-perform-as-vod" }, description: ResString.cmd_livePerformAsVod, getDefaultValue: () => false); private readonly static Option<bool> LivePerformAsVod = new(new string[] { "--live-perform-as-vod" }, description: ResString.cmd_livePerformAsVod, getDefaultValue: () => false);
@ -163,6 +166,26 @@ namespace N_m3u8DL_RE.CommandLine
} }
} }
/// <summary>
/// 解析任务开始时间
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
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) private static string? ParseSaveName(ArgumentResult result)
{ {
var input = result.Tokens.First().Value; var input = result.Tokens.First().Value;
@ -391,6 +414,7 @@ namespace N_m3u8DL_RE.CommandLine
LiveRealTimeMerge = bindingContext.ParseResult.GetValueForOption(LiveRealTimeMerge), LiveRealTimeMerge = bindingContext.ParseResult.GetValueForOption(LiveRealTimeMerge),
LiveKeepSegments = bindingContext.ParseResult.GetValueForOption(LiveKeepSegments), LiveKeepSegments = bindingContext.ParseResult.GetValueForOption(LiveKeepSegments),
LiveRecordLimit = bindingContext.ParseResult.GetValueForOption(LiveRecordLimit), LiveRecordLimit = bindingContext.ParseResult.GetValueForOption(LiveRecordLimit),
TaskStartAt = bindingContext.ParseResult.GetValueForOption(TaskStartAt),
LivePerformAsVod = bindingContext.ParseResult.GetValueForOption(LivePerformAsVod), LivePerformAsVod = bindingContext.ParseResult.GetValueForOption(LivePerformAsVod),
UseSystemProxy = bindingContext.ParseResult.GetValueForOption(UseSystemProxy), UseSystemProxy = bindingContext.ParseResult.GetValueForOption(UseSystemProxy),
CustomProxy = bindingContext.ParseResult.GetValueForOption(CustomProxy), CustomProxy = bindingContext.ParseResult.GetValueForOption(CustomProxy),
@ -460,7 +484,7 @@ namespace N_m3u8DL_RE.CommandLine
FFmpegBinaryPath, FFmpegBinaryPath,
LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption, LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption,
MuxAfterDone, MuxAfterDone,
CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, TaskStartAt,
LivePerformAsVod, LiveRealTimeMerge, LiveKeepSegments, LiveRecordLimit, LiveWaitTime, LivePerformAsVod, LiveRealTimeMerge, LiveKeepSegments, LiveRecordLimit, LiveWaitTime,
MuxImports, VideoFilter, AudioFilter, SubtitleFilter, DropVideoFilter, DropAudioFilter, DropSubtitleFilter, MoreHelp MuxImports, VideoFilter, AudioFilter, SubtitleFilter, DropVideoFilter, DropAudioFilter, DropSubtitleFilter, MoreHelp
}; };

View File

@ -61,6 +61,10 @@ namespace N_m3u8DL_RE.CommandLine
/// </summary> /// </summary>
public TimeSpan? LiveRecordLimit { get; set; } public TimeSpan? LiveRecordLimit { get; set; }
/// <summary> /// <summary>
/// See: <see cref="CommandInvoker.TaskStartAt"/>.
/// </summary>
public DateTime? TaskStartAt { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.SkipMerge"/>. /// See: <see cref="CommandInvoker.SkipMerge"/>.
/// </summary> /// </summary>
public bool SkipMerge { get; set; } public bool SkipMerge { get; set; }
@ -177,14 +181,26 @@ namespace N_m3u8DL_RE.CommandLine
/// </summary> /// </summary>
public StreamFilter? VideoFilter { get; set; } public StreamFilter? VideoFilter { get; set; }
/// <summary> /// <summary>
/// See: <see cref="CommandInvoker.DropVideoFilter"/>.
/// </summary>
public StreamFilter? DropVideoFilter { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.AudioFilter"/>. /// See: <see cref="CommandInvoker.AudioFilter"/>.
/// </summary> /// </summary>
public StreamFilter? AudioFilter { get; set; } public StreamFilter? AudioFilter { get; set; }
/// <summary> /// <summary>
/// See: <see cref="CommandInvoker.DropAudioFilter"/>.
/// </summary>
public StreamFilter? DropAudioFilter { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.SubtitleFilter"/>. /// See: <see cref="CommandInvoker.SubtitleFilter"/>.
/// </summary> /// </summary>
public StreamFilter? SubtitleFilter { get; set; } public StreamFilter? SubtitleFilter { get; set; }
/// <summary> /// <summary>
/// See: <see cref="CommandInvoker.DropSubtitleFilter"/>.
/// </summary>
public StreamFilter? DropSubtitleFilter { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.CustomHLSMethod"/>. /// See: <see cref="CommandInvoker.CustomHLSMethod"/>.
/// </summary> /// </summary>
public EncryptMethod? CustomHLSMethod { get; set; } public EncryptMethod? CustomHLSMethod { get; set; }
@ -205,5 +221,6 @@ namespace N_m3u8DL_RE.CommandLine
/// </summary> /// </summary>
public int? LiveWaitTime { get; set; } public int? LiveWaitTime { get; set; }
public bool MuxKeepFiles { get; set; } public bool MuxKeepFiles { get; set; }
//public bool LiveWriteHLS { get; set; } = true;
} }
} }

View File

@ -165,6 +165,15 @@ namespace N_m3u8DL_RE
//for www.nowehoryzonty.pl //for www.nowehoryzonty.pl
parserConfig.UrlProcessors.Insert(0, new NowehoryzontyUrlProcessor()); 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; var url = option.Input;