Add TimeUsed

This commit is contained in:
genteure 2022-01-13 18:27:47 +08:00
parent 03a3a5a95b
commit 2225ca2dd3
4 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.IO.Pipelines;
@ -86,6 +87,8 @@ namespace BililiveRecorder.ToolBox.Tool.Analyze
var pipeline = new ProcessingPipelineBuilder(new ServiceCollection().BuildServiceProvider()).Add(statsRule).AddDefault().AddRemoveFillerData().Build();
// Run
var stopWatch = Stopwatch.StartNew();
await Task.Run(async () =>
{
var count = 0;
@ -116,6 +119,9 @@ namespace BililiveRecorder.ToolBox.Tool.Analyze
}
}).ConfigureAwait(false);
stopWatch.Stop();
if (cancellationToken.IsCancellationRequested)
return new CommandResponse<AnalyzeResponse> { Status = ResponseStatus.Cancelled };
@ -132,6 +138,8 @@ namespace BililiveRecorder.ToolBox.Tool.Analyze
{
InputPath = inputPath,
TimeUsed = stopWatch.Elapsed,
NeedFix = tagWriter.OutputFileCount != 1 || countableComments.Any(),
Unrepairable = countableComments.Any(x => x.T == CommentType.Unrepairable),

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using BililiveRecorder.ToolBox.ProcessingRules;
using Spectre.Console;
@ -8,6 +9,8 @@ namespace BililiveRecorder.ToolBox.Tool.Analyze
{
public string InputPath { get; set; } = string.Empty;
public TimeSpan TimeUsed { get; set; }
public bool NeedFix { get; set; }
public bool Unrepairable { get; set; }

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.IO.Pipelines;
@ -101,6 +102,8 @@ namespace BililiveRecorder.ToolBox.Tool.Fix
var pipeline = new ProcessingPipelineBuilder(new ServiceCollection().BuildServiceProvider()).Add(statsRule).AddDefault().AddRemoveFillerData().Build();
// Run
var stopWatch = Stopwatch.StartNew();
await Task.Run(async () =>
{
var count = 0;
@ -131,6 +134,9 @@ namespace BililiveRecorder.ToolBox.Tool.Fix
}
}).ConfigureAwait(false);
stopWatch.Stop();
if (cancellationToken.IsCancellationRequested)
return new CommandResponse<FixResponse> { Status = ResponseStatus.Cancelled };
@ -176,6 +182,9 @@ namespace BililiveRecorder.ToolBox.Tool.Fix
return new FixResponse
{
InputPath = inputPath,
TimeUsed = stopWatch.Elapsed,
OutputPaths = outputPaths.ToArray(),
OutputFileCount = outputPaths.Count,

View File

@ -9,6 +9,8 @@ namespace BililiveRecorder.ToolBox.Tool.Fix
{
public string InputPath { get; set; } = string.Empty;
public TimeSpan TimeUsed { get; set; }
public string[] OutputPaths { get; set; } = Array.Empty<string>();
public bool NeedFix { get; set; }