diff --git a/src/N_m3u8DL-RE.Common/Resource/ResString.cs b/src/N_m3u8DL-RE.Common/Resource/ResString.cs index 0c9437b..3f66120 100644 --- a/src/N_m3u8DL-RE.Common/Resource/ResString.cs +++ b/src/N_m3u8DL-RE.Common/Resource/ResString.cs @@ -39,6 +39,7 @@ namespace N_m3u8DL_RE.Common.Resource public static string cmd_subOnly { get => GetText("cmd_subOnly"); } public static string cmd_subtitleFix { get => GetText("cmd_subtitleFix"); } public static string cmd_threadCount { get => GetText("cmd_threadCount"); } + public static string cmd_downloadRetryCount { get => GetText("cmd_downloadRetryCount"); } public static string cmd_tmpDir { get => GetText("cmd_tmpDir"); } public static string cmd_uiLanguage { get => GetText("cmd_uiLanguage"); } public static string cmd_urlProcessorArgs { get => GetText("cmd_urlProcessorArgs"); } diff --git a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs index c4676da..1dc45ac 100644 --- a/src/N_m3u8DL-RE.Common/Resource/StaticText.cs +++ b/src/N_m3u8DL-RE.Common/Resource/StaticText.cs @@ -76,6 +76,12 @@ namespace N_m3u8DL_RE.Common.Resource zhTW: "檢測實際下載的分片數量和預期數量是否匹配", enUS: "Check if the actual number of segments downloaded matches the expected number" ), + ["cmd_downloadRetryCount"] = new TextContainer + ( + zhCN: "每个分片下载异常时的重试次数", + zhTW: "每個分片下載異常時的重試次數", + enUS: "The number of retries when download segment error" + ), ["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 431dcdd..771b33a 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -25,6 +25,7 @@ namespace N_m3u8DL_RE.CommandLine private readonly static Option AutoSelect = new(new string[] { "--auto-select" }, description: ResString.cmd_autoSelect, getDefaultValue: () => false); private readonly static Option SubOnly = new(new string[] { "--sub-only" }, description: ResString.cmd_subOnly, getDefaultValue: () => false); private readonly static Option ThreadCount = new(new string[] { "--thread-count" }, description: ResString.cmd_threadCount, getDefaultValue: () => 8); + private readonly static Option DownloadRetryCount = new(new string[] { "--download-retry-count" }, description: ResString.cmd_downloadRetryCount, getDefaultValue: () => 3); private readonly static Option SkipMerge = new(new string[] { "--skip-merge" }, description: ResString.cmd_skipMerge, getDefaultValue: () => false); private readonly static Option SkipDownload = new(new string[] { "--skip-download" }, description: ResString.cmd_skipDownload, getDefaultValue: () => false); private readonly static Option BinaryMerge = new(new string[] { "--binary-merge" }, description: ResString.cmd_binaryMerge, getDefaultValue: () => false); @@ -71,6 +72,7 @@ namespace N_m3u8DL_RE.CommandLine DecryptionBinaryPath = bindingContext.ParseResult.GetValueForOption(DecryptionBinaryPath), FFmpegBinaryPath = bindingContext.ParseResult.GetValueForOption(FFmpegBinaryPath), KeyTextFile = bindingContext.ParseResult.GetValueForOption(KeyTextFile), + DownloadRetryCount = bindingContext.ParseResult.GetValueForOption(DownloadRetryCount), }; @@ -89,9 +91,9 @@ namespace N_m3u8DL_RE.CommandLine public static async Task InvokeArgs(string[] args, Func action) { - var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20220817") + var rootCommand = new RootCommand("N_m3u8DL-RE (Beta version) 20220818") { - Input, TmpDir, SaveDir, SaveName, ThreadCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, + Input, TmpDir, SaveDir, SaveName, ThreadCount, DownloadRetryCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount, BinaryMerge, DelAfterDone, WriteMetaJson, AppendUrlParams, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix, FFmpegBinaryPath, LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption diff --git a/src/N_m3u8DL-RE/CommandLine/MyOption.cs b/src/N_m3u8DL-RE/CommandLine/MyOption.cs index 93a6685..9b4f438 100644 --- a/src/N_m3u8DL-RE/CommandLine/MyOption.cs +++ b/src/N_m3u8DL-RE/CommandLine/MyOption.cs @@ -42,6 +42,10 @@ namespace N_m3u8DL_RE.CommandLine /// public int ThreadCount { get; set; } /// + /// See: . + /// + public int DownloadRetryCount { get; set; } + /// /// See: . /// public bool SkipMerge { get; set; } diff --git a/src/N_m3u8DL-RE/Config/DownloaderConfig.cs b/src/N_m3u8DL-RE/Config/DownloaderConfig.cs index fba4eb4..29f6f07 100644 --- a/src/N_m3u8DL-RE/Config/DownloaderConfig.cs +++ b/src/N_m3u8DL-RE/Config/DownloaderConfig.cs @@ -32,6 +32,7 @@ namespace N_m3u8DL_RE.Config DecryptionBinaryPath = option.DecryptionBinaryPath; FFmpegBinaryPath = option.FFmpegBinaryPath; KeyTextFile = option.KeyTextFile; + DownloadRetryCount = option.DownloadRetryCount; } /// @@ -55,6 +56,10 @@ namespace N_m3u8DL_RE.Config /// public int ThreadCount { get; set; } = 8; /// + /// 每个分片的重试次数 + /// + public int DownloadRetryCount { get; set; } = 3; + /// /// 跳过合并 /// public bool SkipMerge { get; set; } = false; diff --git a/src/N_m3u8DL-RE/Downloader/SimpleDownloader.cs b/src/N_m3u8DL-RE/Downloader/SimpleDownloader.cs index c83bd65..ef248f8 100644 --- a/src/N_m3u8DL-RE/Downloader/SimpleDownloader.cs +++ b/src/N_m3u8DL-RE/Downloader/SimpleDownloader.cs @@ -30,7 +30,7 @@ namespace N_m3u8DL_RE.Downloader public async Task DownloadSegmentAsync(MediaSegment segment, string savePath, Dictionary? headers = null) { var url = segment.Url; - var dResult = await DownClipAsync(url, savePath, segment.StartRange, segment.StopRange, headers); + var dResult = await DownClipAsync(url, savePath, segment.StartRange, segment.StopRange, headers, DownloaderConfig.DownloadRetryCount); if (dResult != null && dResult.Success && segment.EncryptInfo != null) { if (segment.EncryptInfo.Method == EncryptMethod.AES_128)