增加重试次数设置 #6

This commit is contained in:
nilaoda 2022-08-18 20:04:00 +08:00
parent d9cc09dff8
commit 68e8e1d739
6 changed files with 21 additions and 3 deletions

View File

@ -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"); }

View File

@ -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",

View File

@ -25,6 +25,7 @@ namespace N_m3u8DL_RE.CommandLine
private readonly static Option<bool> AutoSelect = new(new string[] { "--auto-select" }, description: ResString.cmd_autoSelect, getDefaultValue: () => false);
private readonly static Option<bool> SubOnly = new(new string[] { "--sub-only" }, description: ResString.cmd_subOnly, getDefaultValue: () => false);
private readonly static Option<int> ThreadCount = new(new string[] { "--thread-count" }, description: ResString.cmd_threadCount, getDefaultValue: () => 8);
private readonly static Option<int> DownloadRetryCount = new(new string[] { "--download-retry-count" }, description: ResString.cmd_downloadRetryCount, getDefaultValue: () => 3);
private readonly static Option<bool> SkipMerge = new(new string[] { "--skip-merge" }, description: ResString.cmd_skipMerge, getDefaultValue: () => false);
private readonly static Option<bool> SkipDownload = new(new string[] { "--skip-download" }, description: ResString.cmd_skipDownload, getDefaultValue: () => false);
private readonly static Option<bool> 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<int> InvokeArgs(string[] args, Func<MyOption, Task> 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

View File

@ -42,6 +42,10 @@ namespace N_m3u8DL_RE.CommandLine
/// </summary>
public int ThreadCount { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.DownloadRetryCount"/>.
/// </summary>
public int DownloadRetryCount { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.SkipMerge"/>.
/// </summary>
public bool SkipMerge { get; set; }

View File

@ -32,6 +32,7 @@ namespace N_m3u8DL_RE.Config
DecryptionBinaryPath = option.DecryptionBinaryPath;
FFmpegBinaryPath = option.FFmpegBinaryPath;
KeyTextFile = option.KeyTextFile;
DownloadRetryCount = option.DownloadRetryCount;
}
/// <summary>
@ -55,6 +56,10 @@ namespace N_m3u8DL_RE.Config
/// </summary>
public int ThreadCount { get; set; } = 8;
/// <summary>
/// 每个分片的重试次数
/// </summary>
public int DownloadRetryCount { get; set; } = 3;
/// <summary>
/// 跳过合并
/// </summary>
public bool SkipMerge { get; set; } = false;

View File

@ -30,7 +30,7 @@ namespace N_m3u8DL_RE.Downloader
public async Task<DownloadResult?> DownloadSegmentAsync(MediaSegment segment, string savePath, Dictionary<string, string>? 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)