Toolbox: Change source file structure

This commit is contained in:
Genteure 2021-07-15 12:58:50 +08:00
parent 2b482a9c4b
commit e2d5a3fd47
10 changed files with 88 additions and 73 deletions

View File

@ -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<AnalyzeResponse>
{
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<AnalyzeRequest, AnalyzeResponse>
{
private static readonly ILogger logger = Log.ForContext<AnalyzeHandler>();

View File

@ -0,0 +1,7 @@
namespace BililiveRecorder.ToolBox.Tool.Analyze
{
public class AnalyzeRequest : ICommandRequest<AnalyzeResponse>
{
public string Input { get; set; } = string.Empty;
}
}

View File

@ -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; }
}
}

View File

@ -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<ExportResponse>
{
public string Input { get; set; } = string.Empty;
public string Output { get; set; } = string.Empty;
}
public class ExportResponse
{
}
public class ExportHandler : ICommandHandler<ExportRequest, ExportResponse>
{
private static readonly ILogger logger = Log.ForContext<ExportHandler>();

View File

@ -0,0 +1,9 @@
namespace BililiveRecorder.ToolBox.Tool.Export
{
public class ExportRequest : ICommandRequest<ExportResponse>
{
public string Input { get; set; } = string.Empty;
public string Output { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,6 @@
namespace BililiveRecorder.ToolBox.Tool.Export
{
public class ExportResponse
{
}
}

View File

@ -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<FixResponse>
{
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<string>();
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<FixRequest, FixResponse>
{
private static readonly ILogger logger = Log.ForContext<FixHandler>();
@ -115,9 +86,7 @@ namespace BililiveRecorder.ToolBox.Commands
var outputPaths = new List<string>();
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<FixResponse> { Status = ResponseStatus.Cancelled };

View File

@ -0,0 +1,9 @@
namespace BililiveRecorder.ToolBox.Tool.Fix
{
public class FixRequest : ICommandRequest<FixResponse>
{
public string Input { get; set; } = string.Empty;
public string OutputBase { get; set; } = string.Empty;
}
}

View File

@ -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<string>();
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; }
}
}

View File

@ -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