优化进度显示
This commit is contained in:
parent
cde1492dd3
commit
99f0d66d62
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the style for a non-complete task.
|
||||
/// </summary>
|
||||
public Style Style { get; set; } = Style.Plain;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style for a completed task.
|
||||
/// </summary>
|
||||
public Style CompletedStyle { get; set; } = new Style(foreground: Color.Green);
|
||||
|
||||
/// <inheritdoc/>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -292,6 +292,7 @@ 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;
|
||||
if (result != null && result.Success)
|
||||
task.Increment(1);
|
||||
//实时解密
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && result != null && result.Success && !string.IsNullOrEmpty(currentKID))
|
||||
|
@ -641,8 +642,8 @@ 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(),
|
||||
|
|
|
@ -354,6 +354,7 @@ 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;
|
||||
if (result != null && result.Success)
|
||||
task.Increment(1);
|
||||
//实时解密
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && result != null && result.Success && !string.IsNullOrEmpty(currentKID))
|
||||
|
|
Loading…
Reference in New Issue