BililiveRecorder/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeResponse.cs

65 lines
2.5 KiB
C#
Raw Normal View History

using BililiveRecorder.ToolBox.ProcessingRules;
using Spectre.Console;
2021-07-15 12:58:50 +08:00
namespace BililiveRecorder.ToolBox.Tool.Analyze
{
public class AnalyzeResponse : IResponseData
2021-07-15 12:58:50 +08:00
{
public string InputPath { get; set; } = string.Empty;
public bool NeedFix { get; set; }
public bool Unrepairable { get; set; }
public int OutputFileCount { get; set; }
public FlvStats? VideoStats { get; set; }
public FlvStats? AudioStats { get; set; }
public int IssueTypeOther { get; set; }
public int IssueTypeUnrepairable { get; set; }
public int IssueTypeTimestampJump { get; set; }
public int IssueTypeTimestampOffset { get; set; }
public int IssueTypeDecodingHeader { get; set; }
public int IssueTypeRepeatingData { get; set; }
public void PrintToConsole()
{
if (this.NeedFix)
2022-05-17 00:53:37 +08:00
AnsiConsole.Write(new FigletText("Need Fix").Color(Color.Red));
else
2022-05-17 00:53:37 +08:00
AnsiConsole.Write(new FigletText("All Good").Color(Color.Green));
if (this.Unrepairable)
{
2022-05-17 00:53:37 +08:00
AnsiConsole.Write(new Panel("This file contains error(s) that are identified as unrepairable (yet).\n" +
"Please check if you're using the newest version.\n" +
"Please consider send a sample file to the developer.")
{
Header = new PanelHeader("Important Note"),
Border = BoxBorder.Rounded,
BorderStyle = new Style(foreground: Color.Red)
});
}
2022-05-17 00:53:37 +08:00
AnsiConsole.Write(new Panel(this.InputPath.EscapeMarkup())
{
Header = new PanelHeader("Input"),
Border = BoxBorder.Rounded
});
AnsiConsole.MarkupLine("Will output [lime]{0}[/] file(s) if repaired", this.OutputFileCount);
2022-05-17 00:53:37 +08:00
AnsiConsole.Write(new Table()
.Border(TableBorder.Rounded)
.AddColumns("Category", "Count")
.AddRow("Unrepairable", this.IssueTypeUnrepairable.ToString())
.AddRow("Other", this.IssueTypeOther.ToString())
.AddRow("TimestampJump", this.IssueTypeTimestampJump.ToString())
.AddRow("TimestampOffset", this.IssueTypeTimestampOffset.ToString())
.AddRow("DecodingHeader", this.IssueTypeDecodingHeader.ToString())
.AddRow("RepeatingData", this.IssueTypeRepeatingData.ToString())
);
}
2021-07-15 12:58:50 +08:00
}
}