diff --git a/src/N_m3u8DL-RE/Column/MyPercentageColumn.cs b/src/N_m3u8DL-RE/Column/MyPercentageColumn.cs new file mode 100644 index 0000000..e138458 --- /dev/null +++ b/src/N_m3u8DL-RE/Column/MyPercentageColumn.cs @@ -0,0 +1,31 @@ +using Spectre.Console.Rendering; +using Spectre.Console; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace N_m3u8DL_RE.Column +{ + internal class MyPercentageColumn : ProgressColumn + { + /// + /// Gets or sets the style for a non-complete task. + /// + public Style Style { get; set; } = Style.Plain; + + /// + /// Gets or sets the style for a completed task. + /// + public Style CompletedStyle { get; set; } = new Style(foreground: Color.Green); + + /// + public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime) + { + var percentage = task.Percentage; + var style = percentage == 100 ? CompletedStyle : Style ?? Style.Plain; + return new Text($"{task.Value}/{task.MaxValue} {percentage:F2}%", style).RightAligned(); + } + } +} diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index 68742f5..9f9ad4a 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine { internal partial class CommandInvoker { - public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20230712"; + public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20230721"; [GeneratedRegex("((best|worst)\\d*|all)")] private static partial Regex ForStrRegex(); diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index a5b60e4..21f272b 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -292,7 +292,8 @@ namespace N_m3u8DL_RE.DownloadManager var path = Path.Combine(tmpDir, index.ToString(pad) + $".{streamSpec.Extension ?? "clip"}.tmp"); var result = await Downloader.DownloadSegmentAsync(seg, path, speedContainer, headers); FileDic[seg] = result; - task.Increment(1); + if (result != null && result.Success) + task.Increment(1); //实时解密 if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && result != null && result.Success && !string.IsNullOrEmpty(currentKID)) { @@ -641,13 +642,13 @@ namespace N_m3u8DL_RE.DownloadManager progress.Columns(new ProgressColumn[] { new TaskDescriptionColumn() { Alignment = Justify.Left }, - new ProgressBarColumn(), - new PercentageColumn(), + new ProgressBarColumn(){ Width = 30 }, + new MyPercentageColumn(), new DownloadStatusColumn(SpeedContainerDic), new DownloadSpeedColumn(SpeedContainerDic), //速度计算 new RemainingTimeColumn(), new SpinnerColumn(), - }) ; + }); if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && !DownloaderConfig.MyOptions.UseShakaPackager && DownloaderConfig.MyOptions.Keys != null && DownloaderConfig.MyOptions.Keys.Length > 0) diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs index 08fd5a9..ed051d2 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager2.cs @@ -354,7 +354,8 @@ namespace N_m3u8DL_RE.DownloadManager var path = Path.Combine(tmpDir, filename + $".{streamSpec.Extension ?? "clip"}.tmp"); var result = await Downloader.DownloadSegmentAsync(seg, path, speedContainer, headers); FileDic[seg] = result; - task.Increment(1); + if (result != null && result.Success) + task.Increment(1); //实时解密 if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && result != null && result.Success && !string.IsNullOrEmpty(currentKID)) {