支持设置http请求超时时间和设置禁止检测更新 (#502)
`--disable-update-check` `--http-request-timeout`
This commit is contained in:
parent
c004a1c72f
commit
0c73b730bb
|
@ -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");
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -36,10 +36,12 @@ internal partial class CommandInvoker
|
|||
private static readonly Option<Dictionary<string, string>> Headers = new(["-H", "--header"], description: ResString.cmd_header, parseArgument: ParseHeaders) { Arity = ArgumentArity.OneOrMore, AllowMultipleArgumentsPerToken = false };
|
||||
private static readonly Option<LogLevel> LogLevel = new(name: "--log-level", description: ResString.cmd_logLevel, getDefaultValue: () => Common.Log.LogLevel.INFO);
|
||||
private static readonly Option<SubtitleFormat> SubtitleFormat = new(name: "--sub-format", description: ResString.cmd_subFormat, getDefaultValue: () => Enum.SubtitleFormat.SRT);
|
||||
private static readonly Option<bool> DisableUpdateCheck = new(["--disable-update-check"], description: ResString.cmd_disableUpdateCheck, getDefaultValue: () => false);
|
||||
private static readonly Option<bool> AutoSelect = new(["--auto-select"], description: ResString.cmd_autoSelect, getDefaultValue: () => false);
|
||||
private static readonly Option<bool> SubOnly = new(["--sub-only"], description: ResString.cmd_subOnly, getDefaultValue: () => false);
|
||||
private static readonly Option<int> ThreadCount = new(["--thread-count"], description: ResString.cmd_threadCount, getDefaultValue: () => Environment.ProcessorCount) { ArgumentHelpName = "number" };
|
||||
private static readonly Option<int> DownloadRetryCount = new(["--download-retry-count"], description: ResString.cmd_downloadRetryCount, getDefaultValue: () => 3) { ArgumentHelpName = "number" };
|
||||
private static readonly Option<double> HttpRequestTimeout = new(["--http-request-timeout"], description: ResString.cmd_httpRequestTimeout, getDefaultValue: () => 100) { ArgumentHelpName = "seconds" };
|
||||
private static readonly Option<bool> SkipMerge = new(["--skip-merge"], description: ResString.cmd_skipMerge, getDefaultValue: () => false);
|
||||
private static readonly Option<bool> SkipDownload = new(["--skip-download"], description: ResString.cmd_skipDownload, getDefaultValue: () => false);
|
||||
private static readonly Option<bool> 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;
|
||||
|
|
|
@ -57,6 +57,10 @@ internal class MyOption
|
|||
/// </summary>
|
||||
public bool AutoSelect { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.DisableUpdateCheck"/>.
|
||||
/// </summary>
|
||||
public bool DisableUpdateCheck { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.SubOnly"/>.
|
||||
/// </summary>
|
||||
public bool SubOnly { get; set; }
|
||||
|
@ -69,6 +73,10 @@ internal class MyOption
|
|||
/// </summary>
|
||||
public int DownloadRetryCount { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.HttpRequestTimeout"/>.
|
||||
/// </summary>
|
||||
public double HttpRequestTimeout { get; set; }
|
||||
/// <summary>
|
||||
/// See: <see cref="CommandInvoker.LiveRecordLimit"/>.
|
||||
/// </summary>
|
||||
public TimeSpan? LiveRecordLimit { get; set; }
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue