From d58168a3376d400441f886ed438a4fdd6f82c127 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Wed, 28 Jun 2023 15:22:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=B4=E6=92=AD=E5=BD=95?= =?UTF-8?q?=E5=88=B6=E9=80=BB=E8=BE=91;=20=E4=BC=98=E5=8C=96=E5=B7=B2?= =?UTF-8?q?=E5=BD=95=E5=88=B6=E6=97=B6=E9=95=BF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/N_m3u8DL-RE.Parser/StreamExtractor.cs | 4 ++-- .../Column/RecordingDurationColumn.cs | 16 ++++++++++++++-- .../DownloadManager/SimpleLiveRecordManager2.cs | 14 +++++++------- src/N_m3u8DL-RE/Program.cs | 6 ++++++ 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/N_m3u8DL-RE.Parser/StreamExtractor.cs b/src/N_m3u8DL-RE.Parser/StreamExtractor.cs index 8559442..8d0d92d 100644 --- a/src/N_m3u8DL-RE.Parser/StreamExtractor.cs +++ b/src/N_m3u8DL-RE.Parser/StreamExtractor.cs @@ -134,7 +134,7 @@ namespace N_m3u8DL_RE.Parser try { await semaphore.WaitAsync(); - int retryCount = 3; //增加重试 + int retryCount = 5; //增加重试 reGet: try { @@ -145,7 +145,7 @@ namespace N_m3u8DL_RE.Parser if (retryCount-- > 0) { Logger.WarnMarkUp($"[grey]Refresh Exception: {ex.Message.EscapeMarkup()} retryCount: {retryCount}[/]"); - await Task.Delay(300); + await Task.Delay(1000); goto reGet; } else throw; diff --git a/src/N_m3u8DL-RE/Column/RecordingDurationColumn.cs b/src/N_m3u8DL-RE/Column/RecordingDurationColumn.cs index e5af045..cf76384 100644 --- a/src/N_m3u8DL-RE/Column/RecordingDurationColumn.cs +++ b/src/N_m3u8DL-RE/Column/RecordingDurationColumn.cs @@ -14,14 +14,26 @@ namespace N_m3u8DL_RE.Column { protected override bool NoWrap => true; private ConcurrentDictionary _recodingDurDic; - public Style MyStyle { get; set; } = new Style(foreground: Color.Grey); + private ConcurrentDictionary? _refreshedDurDic; + public Style GreyStyle { get; set; } = new Style(foreground: Color.Grey); + public Style MyStyle { get; set; } = new Style(foreground: Color.DarkGreen); public RecordingDurationColumn(ConcurrentDictionary recodingDurDic) { _recodingDurDic = recodingDurDic; } + public RecordingDurationColumn(ConcurrentDictionary recodingDurDic, ConcurrentDictionary refreshedDurDic) + { + _recodingDurDic = recodingDurDic; + _refreshedDurDic = refreshedDurDic; + } public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime) { - return new Text(GlobalUtil.FormatTime(_recodingDurDic[task.Id]), MyStyle).LeftAligned(); + if (_refreshedDurDic == null) + return new Text($"{GlobalUtil.FormatTime(_recodingDurDic[task.Id])}", MyStyle).LeftAligned(); + else + { + return new Text($"{GlobalUtil.FormatTime(_recodingDurDic[task.Id])}/{GlobalUtil.FormatTime(_refreshedDurDic[task.Id])}", GreyStyle); + } } } } diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs index 2c93f7f..229d3cf 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs @@ -641,7 +641,7 @@ namespace N_m3u8DL_RE.DownloadManager } } - if (STOP_FLAG) + if (STOP_FLAG && source.Count == 0) break; } @@ -720,11 +720,6 @@ namespace N_m3u8DL_RE.DownloadManager Logger.WarnMarkUp($"[darkorange3_1]{ResString.liveLimitReached}[/]"); STOP_FLAG = true; CancellationTokenSource.Cancel(); - - foreach (var target in BlockDic.Values) - { - target.Complete(); - } } }); @@ -743,6 +738,11 @@ namespace N_m3u8DL_RE.DownloadManager { Logger.ErrorMarkUp(e); STOP_FLAG = true; + //停止所有Block + foreach (var target in BlockDic.Values) + { + target.Complete(); + } } } } @@ -825,7 +825,7 @@ namespace N_m3u8DL_RE.DownloadManager progress.Columns(new ProgressColumn[] { new TaskDescriptionColumn() { Alignment = Justify.Left }, - new RecordingDurationColumn(RecordedDurDic), //时长显示 + new RecordingDurationColumn(RecordedDurDic, RefreshedDurDic), //时长显示 new RecordingStatusColumn(), new PercentageColumn(), new DownloadSpeedColumn(SpeedContainerDic), //速度计算 diff --git a/src/N_m3u8DL-RE/Program.cs b/src/N_m3u8DL-RE/Program.cs index 0c4ca8c..4f42c8a 100644 --- a/src/N_m3u8DL-RE/Program.cs +++ b/src/N_m3u8DL-RE/Program.cs @@ -96,6 +96,12 @@ namespace N_m3u8DL_RE throw new ArgumentException("MuxAfterDone disabled, MuxImports not allowed!"); } + if (option.LivePipeMux && !option.LiveRealTimeMerge) + { + Logger.WarnMarkUp("LivePipeMux detected, forced enable LiveRealTimeMerge"); + option.LiveRealTimeMerge = true; + } + //预先检查ffmpeg if (option.FFmpegBinaryPath == null) option.FFmpegBinaryPath = GlobalUtil.FindExecutable("ffmpeg");