diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs index 9cae7d1..0f49c04 100644 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.cs +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -23,6 +23,7 @@ public class ResString public static string checkingLast => GetText("checkingLast"); public static string cmd_appendUrlParams => GetText("cmd_appendUrlParams"); public static string cmd_autoSelect => GetText("cmd_autoSelect"); + public static string cmd_disableUpdateCheck => GetText("cmd_disableUpdateCheck"); public static string cmd_binaryMerge => GetText("cmd_binaryMerge"); public static string cmd_useFFmpegConcatDemuxer => GetText("cmd_useFFmpegConcatDemuxer"); public static string cmd_checkSegmentsCount => GetText("cmd_checkSegmentsCount"); @@ -70,6 +71,7 @@ public class ResString public static string cmd_subtitleFix => GetText("cmd_subtitleFix"); public static string cmd_threadCount => GetText("cmd_threadCount"); public static string cmd_downloadRetryCount => GetText("cmd_downloadRetryCount"); + public static string cmd_httpRequestTimeout => GetText("cmd_httpRequestTimeout"); public static string cmd_tmpDir => GetText("cmd_tmpDir"); public static string cmd_uiLanguage => GetText("cmd_uiLanguage"); public static string cmd_urlProcessorArgs => GetText("cmd_urlProcessorArgs"); diff --git a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs index 1739d53..bdcbd71 100644 --- a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs +++ b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs @@ -184,6 +184,12 @@ internal class StaticText zhTW: "自動選擇所有類型的最佳軌道", enUS: "Automatically selects the best tracks of all types" ), + ["cmd_disableUpdateCheck"] = new TextContainer + ( + zhCN: "禁用版本更新检测", + zhTW: "禁用版本更新檢測", + enUS: "Disable version update check" + ), ["cmd_binaryMerge"] = new TextContainer ( zhCN: "二进制合并", @@ -208,6 +214,12 @@ internal class StaticText zhTW: "每個分片下載異常時的重試次數", enUS: "The number of retries when download segment error" ), + ["cmd_httpRequestTimeout"] = new TextContainer + ( + zhCN: "HTTP请求的超时时间(秒)", + zhTW: "HTTP請求的超時時間(秒)", + enUS: "Timeout duration for HTTP requests (in seconds)" + ), ["cmd_decryptionBinaryPath"] = new TextContainer ( zhCN: "MP4解密所用工具的全路径, 例如 C:\\Tools\\mp4decrypt.exe", diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index ca97691..9b4d724 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -36,10 +36,12 @@ internal partial class CommandInvoker private static readonly Option> Headers = new(["-H", "--header"], description: ResString.cmd_header, parseArgument: ParseHeaders) { Arity = ArgumentArity.OneOrMore, AllowMultipleArgumentsPerToken = false }; private static readonly Option LogLevel = new(name: "--log-level", description: ResString.cmd_logLevel, getDefaultValue: () => Common.Log.LogLevel.INFO); private static readonly Option SubtitleFormat = new(name: "--sub-format", description: ResString.cmd_subFormat, getDefaultValue: () => Enum.SubtitleFormat.SRT); + private static readonly Option DisableUpdateCheck = new(["--disable-update-check"], description: ResString.cmd_disableUpdateCheck, getDefaultValue: () => false); private static readonly Option AutoSelect = new(["--auto-select"], description: ResString.cmd_autoSelect, getDefaultValue: () => false); private static readonly Option SubOnly = new(["--sub-only"], description: ResString.cmd_subOnly, getDefaultValue: () => false); private static readonly Option ThreadCount = new(["--thread-count"], description: ResString.cmd_threadCount, getDefaultValue: () => Environment.ProcessorCount) { ArgumentHelpName = "number" }; private static readonly Option DownloadRetryCount = new(["--download-retry-count"], description: ResString.cmd_downloadRetryCount, getDefaultValue: () => 3) { ArgumentHelpName = "number" }; + private static readonly Option HttpRequestTimeout = new(["--http-request-timeout"], description: ResString.cmd_httpRequestTimeout, getDefaultValue: () => 100) { ArgumentHelpName = "seconds" }; private static readonly Option SkipMerge = new(["--skip-merge"], description: ResString.cmd_skipMerge, getDefaultValue: () => false); private static readonly Option SkipDownload = new(["--skip-download"], description: ResString.cmd_skipDownload, getDefaultValue: () => false); private static readonly Option NoDateInfo = new(["--no-date-info"], description: ResString.cmd_noDateInfo, getDefaultValue: () => false); @@ -498,6 +500,7 @@ internal partial class CommandInvoker NoAnsiColor = bindingContext.ParseResult.GetValueForOption(NoAnsiColor), LogLevel = bindingContext.ParseResult.GetValueForOption(LogLevel), AutoSelect = bindingContext.ParseResult.GetValueForOption(AutoSelect), + DisableUpdateCheck = bindingContext.ParseResult.GetValueForOption(DisableUpdateCheck), SkipMerge = bindingContext.ParseResult.GetValueForOption(SkipMerge), BinaryMerge = bindingContext.ParseResult.GetValueForOption(BinaryMerge), UseFFmpegConcatDemuxer = bindingContext.ParseResult.GetValueForOption(UseFFmpegConcatDemuxer), @@ -523,6 +526,7 @@ internal partial class CommandInvoker FFmpegBinaryPath = bindingContext.ParseResult.GetValueForOption(FFmpegBinaryPath), KeyTextFile = bindingContext.ParseResult.GetValueForOption(KeyTextFile), DownloadRetryCount = bindingContext.ParseResult.GetValueForOption(DownloadRetryCount), + HttpRequestTimeout = bindingContext.ParseResult.GetValueForOption(HttpRequestTimeout), BaseUrl = bindingContext.ParseResult.GetValueForOption(BaseUrl), MuxImports = bindingContext.ParseResult.GetValueForOption(MuxImports), ConcurrentDownload = bindingContext.ParseResult.GetValueForOption(ConcurrentDownload), @@ -606,7 +610,7 @@ internal partial class CommandInvoker var rootCommand = new RootCommand(VERSION_INFO) { - Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, ForceAnsiConsole, NoAnsiColor,AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, + Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, HttpRequestTimeout, ForceAnsiConsole, NoAnsiColor,AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, BinaryMerge, UseFFmpegConcatDemuxer, DelAfterDone, NoDateInfo, NoLog, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, FFmpegBinaryPath, LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption, @@ -614,7 +618,7 @@ internal partial class CommandInvoker MuxAfterDone, CustomHLSMethod, CustomHLSKey, CustomHLSIv, UseSystemProxy, CustomProxy, CustomRange, TaskStartAt, LivePerformAsVod, LiveRealTimeMerge, LiveKeepSegments, LivePipeMux, LiveFixVttByAudio, LiveRecordLimit, LiveWaitTime, LiveTakeCount, - MuxImports, VideoFilter, AudioFilter, SubtitleFilter, DropVideoFilter, DropAudioFilter, DropSubtitleFilter, AdKeywords, MoreHelp + MuxImports, VideoFilter, AudioFilter, SubtitleFilter, DropVideoFilter, DropAudioFilter, DropSubtitleFilter, AdKeywords, DisableUpdateCheck, MoreHelp }; rootCommand.TreatUnmatchedTokensAsErrors = true; diff --git a/src/N_m3u8DL-RE/CommandLine/MyOption.cs b/src/N_m3u8DL-RE/CommandLine/MyOption.cs index 0cb77e4..2b60f0b 100644 --- a/src/N_m3u8DL-RE/CommandLine/MyOption.cs +++ b/src/N_m3u8DL-RE/CommandLine/MyOption.cs @@ -57,6 +57,10 @@ internal class MyOption /// public bool AutoSelect { get; set; } /// + /// See: . + /// + public bool DisableUpdateCheck { get; set; } + /// /// See: . /// public bool SubOnly { get; set; } @@ -69,6 +73,10 @@ internal class MyOption /// public int DownloadRetryCount { get; set; } /// + /// See: . + /// + public double HttpRequestTimeout { get; set; } + /// /// See: . /// public TimeSpan? LiveRecordLimit { get; set; } diff --git a/src/N_m3u8DL-RE/Program.cs b/src/N_m3u8DL-RE/Program.cs index c683787..404d3b3 100644 --- a/src/N_m3u8DL-RE/Program.cs +++ b/src/N_m3u8DL-RE/Program.cs @@ -75,7 +75,7 @@ internal class Program static async Task DoWorkAsync(MyOption option) { - + HTTPUtil.AppHttpClient.Timeout = TimeSpan.FromSeconds(option.HttpRequestTimeout); if (Console.IsOutputRedirected || Console.IsErrorRedirected) { option.ForceAnsiConsole = true; @@ -83,8 +83,10 @@ internal class Program Logger.Info(ResString.consoleRedirected); } CustomAnsiConsole.InitConsole(option.ForceAnsiConsole, option.NoAnsiColor); + // 检测更新 - _ = CheckUpdateAsync(); + if (!option.DisableUpdateCheck) + _ = CheckUpdateAsync(); Logger.IsWriteFile = !option.NoLog; Logger.InitLogFile();