diff --git a/src/N_m3u8DL-RE/Column/DownloadStatusColumn.cs b/src/N_m3u8DL-RE/Column/DownloadStatusColumn.cs index 9383efc..2fa70f8 100644 --- a/src/N_m3u8DL-RE/Column/DownloadStatusColumn.cs +++ b/src/N_m3u8DL-RE/Column/DownloadStatusColumn.cs @@ -14,6 +14,8 @@ namespace N_m3u8DL_RE.Column internal class DownloadStatusColumn : ProgressColumn { private ConcurrentDictionary SpeedContainerDic { get; set; } + private ConcurrentDictionary DateTimeStringDic = new(); + private ConcurrentDictionary SizeDic = new(); public Style MyStyle { get; set; } = new Style(foreground: Color.DarkCyan); public Style FinishedStyle { get; set; } = new Style(foreground: Color.Green); @@ -25,15 +27,23 @@ namespace N_m3u8DL_RE.Column public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime) { if (task.Value == 0) return new Text("-", MyStyle).RightAligned(); + var now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var speedContainer = SpeedContainerDic[task.Id]; - var size = speedContainer.RDownloaded; - var totalSize = speedContainer.SingleSegment ? (speedContainer.ResponseLength ?? 0) : (long)(size / (task.Value / task.MaxValue)); - var sizeStr = $"{GlobalUtil.FormatFileSize(size)}/{GlobalUtil.FormatFileSize(totalSize)}"; + //一秒汇报一次即可 + if (DateTimeStringDic.TryGetValue(task.Id, out var oldTime) && oldTime != now) + { + var totalSize = speedContainer.SingleSegment ? (speedContainer.ResponseLength ?? 0) : (long)(size / (task.Value / task.MaxValue)); + SizeDic[task.Id] = $"{GlobalUtil.FormatFileSize(size)}/{GlobalUtil.FormatFileSize(totalSize)}"; + } + DateTimeStringDic[task.Id] = now; + SizeDic.TryGetValue(task.Id, out var sizeStr); + if (task.IsFinished) sizeStr = GlobalUtil.FormatFileSize(size); - return new Text(sizeStr, MyStyle).RightAligned(); + + return new Text(sizeStr ?? "-", MyStyle).RightAligned(); } } }