支持设置任务开始时间
This commit is contained in:
parent
a9925e44bb
commit
f6bab9cdad
|
@ -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"); }
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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[]?> 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);
|
||||
|
@ -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)
|
||||
{
|
||||
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
|
||||
};
|
||||
|
|
|
@ -61,6 +61,10 @@ namespace N_m3u8DL_RE.CommandLine
|
|||
/// </summary>
|
||||
public TimeSpan? LiveRecordLimit { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.TaskStartAt"/>.
|
||||
/// </summary>
|
||||
public DateTime? TaskStartAt { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.SkipMerge"/>.
|
||||
/// </summary>
|
||||
public bool SkipMerge { get; set; }
|
||||
|
@ -177,14 +181,26 @@ namespace N_m3u8DL_RE.CommandLine
|
|||
/// </summary>
|
||||
public StreamFilter? VideoFilter { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.DropVideoFilter"/>.
|
||||
/// </summary>
|
||||
public StreamFilter? DropVideoFilter { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.AudioFilter"/>.
|
||||
/// </summary>
|
||||
public StreamFilter? AudioFilter { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.DropAudioFilter"/>.
|
||||
/// </summary>
|
||||
public StreamFilter? DropAudioFilter { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.SubtitleFilter"/>.
|
||||
/// </summary>
|
||||
public StreamFilter? SubtitleFilter { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.DropSubtitleFilter"/>.
|
||||
/// </summary>
|
||||
public StreamFilter? DropSubtitleFilter { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.CustomHLSMethod"/>.
|
||||
/// </summary>
|
||||
public EncryptMethod? CustomHLSMethod { get; set; }
|
||||
|
@ -205,5 +221,6 @@ namespace N_m3u8DL_RE.CommandLine
|
|||
/// </summary>
|
||||
public int? LiveWaitTime { get; set; }
|
||||
public bool MuxKeepFiles { get; set; }
|
||||
//public bool LiveWriteHLS { get; set; } = true;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue