diff --git a/BililiveRecorder.ToolBox/Commands/Analyze.cs b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeHandler.cs similarity index 92% rename from BililiveRecorder.ToolBox/Commands/Analyze.cs rename to BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeHandler.cs index c6b1106..6a08258 100644 --- a/BililiveRecorder.ToolBox/Commands/Analyze.cs +++ b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeHandler.cs @@ -18,33 +18,8 @@ using BililiveRecorder.ToolBox.ProcessingRules; using Microsoft.Extensions.DependencyInjection; using Serilog; -namespace BililiveRecorder.ToolBox.Commands +namespace BililiveRecorder.ToolBox.Tool.Analyze { - public class AnalyzeRequest : ICommandRequest - { - public string Input { get; set; } = string.Empty; - } - - public class AnalyzeResponse - { - 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 class AnalyzeHandler : ICommandHandler { private static readonly ILogger logger = Log.ForContext(); diff --git a/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeRequest.cs b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeRequest.cs new file mode 100644 index 0000000..139ad92 --- /dev/null +++ b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeRequest.cs @@ -0,0 +1,7 @@ +namespace BililiveRecorder.ToolBox.Tool.Analyze +{ + public class AnalyzeRequest : ICommandRequest + { + public string Input { get; set; } = string.Empty; + } +} diff --git a/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeResponse.cs b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeResponse.cs new file mode 100644 index 0000000..493fbcd --- /dev/null +++ b/BililiveRecorder.ToolBox/Tool/Analyze/AnalyzeResponse.cs @@ -0,0 +1,24 @@ +using BililiveRecorder.ToolBox.ProcessingRules; + +namespace BililiveRecorder.ToolBox.Tool.Analyze +{ + public class AnalyzeResponse + { + 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; } + } +} diff --git a/BililiveRecorder.ToolBox/Commands/Export.cs b/BililiveRecorder.ToolBox/Tool/Export/ExportHandler.cs similarity index 94% rename from BililiveRecorder.ToolBox/Commands/Export.cs rename to BililiveRecorder.ToolBox/Tool/Export/ExportHandler.cs index 6e3aef7..a8174af 100644 --- a/BililiveRecorder.ToolBox/Commands/Export.cs +++ b/BililiveRecorder.ToolBox/Tool/Export/ExportHandler.cs @@ -10,19 +10,8 @@ using BililiveRecorder.Flv.Parser; using BililiveRecorder.Flv.Xml; using Serilog; -namespace BililiveRecorder.ToolBox.Commands +namespace BililiveRecorder.ToolBox.Tool.Export { - public class ExportRequest : ICommandRequest - { - public string Input { get; set; } = string.Empty; - - public string Output { get; set; } = string.Empty; - } - - public class ExportResponse - { - } - public class ExportHandler : ICommandHandler { private static readonly ILogger logger = Log.ForContext(); diff --git a/BililiveRecorder.ToolBox/Tool/Export/ExportRequest.cs b/BililiveRecorder.ToolBox/Tool/Export/ExportRequest.cs new file mode 100644 index 0000000..eb3ec3c --- /dev/null +++ b/BililiveRecorder.ToolBox/Tool/Export/ExportRequest.cs @@ -0,0 +1,9 @@ +namespace BililiveRecorder.ToolBox.Tool.Export +{ + public class ExportRequest : ICommandRequest + { + public string Input { get; set; } = string.Empty; + + public string Output { get; set; } = string.Empty; + } +} diff --git a/BililiveRecorder.ToolBox/Tool/Export/ExportResponse.cs b/BililiveRecorder.ToolBox/Tool/Export/ExportResponse.cs new file mode 100644 index 0000000..8ffbb15 --- /dev/null +++ b/BililiveRecorder.ToolBox/Tool/Export/ExportResponse.cs @@ -0,0 +1,6 @@ +namespace BililiveRecorder.ToolBox.Tool.Export +{ + public class ExportResponse + { + } +} diff --git a/BililiveRecorder.ToolBox/Commands/Fix.cs b/BililiveRecorder.ToolBox/Tool/Fix/FixHandler.cs similarity index 92% rename from BililiveRecorder.ToolBox/Commands/Fix.cs rename to BililiveRecorder.ToolBox/Tool/Fix/FixHandler.cs index d2eb659..979aba1 100644 --- a/BililiveRecorder.ToolBox/Commands/Fix.cs +++ b/BililiveRecorder.ToolBox/Tool/Fix/FixHandler.cs @@ -17,37 +17,8 @@ using BililiveRecorder.ToolBox.ProcessingRules; using Microsoft.Extensions.DependencyInjection; using Serilog; -namespace BililiveRecorder.ToolBox.Commands +namespace BililiveRecorder.ToolBox.Tool.Fix { - public class FixRequest : ICommandRequest - { - public string Input { get; set; } = string.Empty; - - public string OutputBase { get; set; } = string.Empty; - } - - public class FixResponse - { - public string InputPath { get; set; } = string.Empty; - - public string[] OutputPaths { get; set; } = Array.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 class FixHandler : ICommandHandler { private static readonly ILogger logger = Log.ForContext(); @@ -115,9 +86,7 @@ namespace BililiveRecorder.ToolBox.Commands var outputPaths = new List(); IFlvTagWriter tagWriter; if (xmlMode) - { tagWriter = new FlvTagListWriter(); - } else { var targetProvider = new AutoFixFlvWriterTargetProvider(request.OutputBase); @@ -170,7 +139,6 @@ namespace BililiveRecorder.ToolBox.Commands logger.Information("Xml meta: {@Meta}", meta); if (xmlMode) - { await Task.Run(() => { var w = (FlvTagListWriter)tagWriter; @@ -195,7 +163,6 @@ namespace BililiveRecorder.ToolBox.Commands } } }); - } if (cancellationToken.IsCancellationRequested) return new CommandResponse { Status = ResponseStatus.Cancelled }; diff --git a/BililiveRecorder.ToolBox/Tool/Fix/FixRequest.cs b/BililiveRecorder.ToolBox/Tool/Fix/FixRequest.cs new file mode 100644 index 0000000..0ca1fe5 --- /dev/null +++ b/BililiveRecorder.ToolBox/Tool/Fix/FixRequest.cs @@ -0,0 +1,9 @@ +namespace BililiveRecorder.ToolBox.Tool.Fix +{ + public class FixRequest : ICommandRequest + { + public string Input { get; set; } = string.Empty; + + public string OutputBase { get; set; } = string.Empty; + } +} diff --git a/BililiveRecorder.ToolBox/Tool/Fix/FixResponse.cs b/BililiveRecorder.ToolBox/Tool/Fix/FixResponse.cs new file mode 100644 index 0000000..e6f4134 --- /dev/null +++ b/BililiveRecorder.ToolBox/Tool/Fix/FixResponse.cs @@ -0,0 +1,27 @@ +using System; +using BililiveRecorder.ToolBox.ProcessingRules; + +namespace BililiveRecorder.ToolBox.Tool.Fix +{ + public class FixResponse + { + public string InputPath { get; set; } = string.Empty; + + public string[] OutputPaths { get; set; } = Array.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; } + } +} diff --git a/BililiveRecorder.ToolBox/ToolCommand.cs b/BililiveRecorder.ToolBox/ToolCommand.cs index 1890ae9..611b9dd 100644 --- a/BililiveRecorder.ToolBox/ToolCommand.cs +++ b/BililiveRecorder.ToolBox/ToolCommand.cs @@ -2,7 +2,9 @@ using System; using System.CommandLine; using System.CommandLine.Invocation; using System.Threading.Tasks; -using BililiveRecorder.ToolBox.Commands; +using BililiveRecorder.ToolBox.Tool.Analyze; +using BililiveRecorder.ToolBox.Tool.Export; +using BililiveRecorder.ToolBox.Tool.Fix; using Newtonsoft.Json; namespace BililiveRecorder.ToolBox