2021-07-15 19:56:58 +08:00
|
|
|
using System;
|
2021-07-15 12:58:50 +08:00
|
|
|
using BililiveRecorder.ToolBox.ProcessingRules;
|
2021-07-15 19:56:58 +08:00
|
|
|
using Spectre.Console;
|
2021-07-15 12:58:50 +08:00
|
|
|
|
|
|
|
namespace BililiveRecorder.ToolBox.Tool.Fix
|
|
|
|
{
|
2021-07-15 19:56:58 +08:00
|
|
|
public class FixResponse : IResponseData
|
2021-07-15 12:58:50 +08:00
|
|
|
{
|
|
|
|
public string InputPath { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
public string[] OutputPaths { get; set; } = Array.Empty<string>();
|
|
|
|
|
|
|
|
public bool NeedFix { get; set; }
|
|
|
|
public bool Unrepairable { get; set; }
|
2022-06-22 23:57:48 +08:00
|
|
|
public bool FfmpegDetected { get; set; }
|
2021-07-15 12:58:50 +08:00
|
|
|
|
|
|
|
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; }
|
2021-07-15 19:56:58 +08:00
|
|
|
|
|
|
|
public void PrintToConsole()
|
|
|
|
{
|
2022-05-17 00:53:37 +08:00
|
|
|
AnsiConsole.Write(new FigletText("Done").Color(Color.Green));
|
2021-07-15 19:56:58 +08:00
|
|
|
|
|
|
|
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" +
|
2021-07-15 19:56:58 +08:00
|
|
|
"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-06-22 23:57:48 +08:00
|
|
|
if (this.FfmpegDetected)
|
|
|
|
{
|
|
|
|
AnsiConsole.Write(new Panel("This file seems like it was written by FFmpeg.\n" +
|
|
|
|
"It might no longer possible to fix this file, if there's any problem.\n" +
|
|
|
|
"Only unprocessed data taken directly from the stream server could be fixed.")
|
|
|
|
{
|
|
|
|
Header = new PanelHeader("[bold yellow]FFmpeg Detected[/]"),
|
|
|
|
Border = BoxBorder.Rounded,
|
|
|
|
BorderStyle = new Style(foreground: Color.Yellow)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-05-17 00:53:37 +08:00
|
|
|
AnsiConsole.Write(new Panel(this.InputPath.EscapeMarkup())
|
2021-07-15 19:56:58 +08:00
|
|
|
{
|
|
|
|
Header = new PanelHeader("Input"),
|
|
|
|
Border = BoxBorder.Rounded
|
|
|
|
});
|
|
|
|
|
|
|
|
var table_output = new Table()
|
|
|
|
.Border(TableBorder.Rounded)
|
|
|
|
.AddColumns("Output");
|
|
|
|
|
|
|
|
for (var i = 0; i < this.OutputPaths.Length; i++)
|
2022-01-24 07:58:06 +08:00
|
|
|
table_output.AddRow(this.OutputPaths[i].EscapeMarkup());
|
2021-07-15 19:56:58 +08:00
|
|
|
|
2022-05-17 00:53:37 +08:00
|
|
|
AnsiConsole.Write(table_output);
|
2021-07-15 19:56:58 +08:00
|
|
|
|
2022-05-17 00:53:37 +08:00
|
|
|
AnsiConsole.Write(new Table()
|
2021-07-15 19:56:58 +08:00
|
|
|
.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
|
|
|
}
|
|
|
|
}
|