mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-06 05:36:53 +00:00
refactor: Move the related configuration items to the Common library.
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
namespace ZonyLrcTools.Cli.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// 屏蔽词选项类。
|
||||
/// </summary>
|
||||
public class BlockWordOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用本功能。
|
||||
/// </summary>
|
||||
public bool IsEnable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 屏蔽词字典文件,用于替换歌曲名或者歌手名称。
|
||||
/// </summary>
|
||||
public string FilePath { get; set; }
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Config;
|
||||
|
||||
public class LyricOption
|
||||
{
|
||||
public IEnumerable<LyricProviderOption> Plugin { get; set; }
|
||||
|
||||
public LyricConfigOption Config { get; set; }
|
||||
|
||||
public LyricProviderOption GetLyricProviderOption(string name)
|
||||
{
|
||||
return Plugin.FirstOrDefault(x => x.Name == name);
|
||||
}
|
||||
}
|
||||
|
||||
public class LyricConfigOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 双语歌词是否合并为一行。
|
||||
/// </summary>
|
||||
public bool IsOneLine { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 换行符格式,取值来自 <see cref="LineBreakType"/> 常量类。
|
||||
/// </summary>
|
||||
public string LineBreak { get; set; } = LineBreakType.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用歌词翻译功能。
|
||||
/// </summary>
|
||||
public bool IsEnableTranslation { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 如果歌词文件已经存在,是否跳过这些文件
|
||||
/// </summary>
|
||||
public bool IsSkipExistLyricFiles { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 歌词文件的编码格式。
|
||||
/// </summary>
|
||||
public string FileEncoding { get; set; } = "utf-8";
|
||||
|
||||
/// <summary>
|
||||
/// 是否只输出翻译歌词。
|
||||
/// </summary>
|
||||
public bool IsOnlyOutputTranslation { get; set; } = false;
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
namespace ZonyLrcTools.Cli.Config
|
||||
{
|
||||
public class LyricProviderOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 歌词下载器的唯一标识。
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌词下载时的优先级,当值为 -1 时是禁用。
|
||||
/// </summary>
|
||||
public int Priority { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 搜索深度,值越大搜索结果越多,但搜索时间越长。
|
||||
/// </summary>
|
||||
public int Depth { get; set; }
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
using ZonyLrcTools.Cli.Infrastructure.Tag;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Config;
|
||||
|
||||
public class ProviderOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签加载器相关的配置属性。
|
||||
/// </summary>
|
||||
public TagOption Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 歌词下载相关的配置信息。
|
||||
/// </summary>
|
||||
public LyricOption Lyric { get; set; }
|
||||
}
|
@@ -3,6 +3,7 @@ using YamlDotNet.Serialization;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Network;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Tag;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Config
|
||||
{
|
||||
@@ -21,6 +22,6 @@ namespace ZonyLrcTools.Cli.Config
|
||||
/// <summary>
|
||||
/// 定义下载器的相关配置信息。
|
||||
/// </summary>
|
||||
public ProviderOption Provider { get; set; }
|
||||
public ProviderOptions Provider { get; set; }
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
{
|
||||
/// <summary>
|
||||
/// 换行符格式定义。
|
||||
/// </summary>
|
||||
public static class LineBreakType
|
||||
{
|
||||
/// <summary>
|
||||
/// Windows 系统。
|
||||
/// </summary>
|
||||
public const string Windows = "\r\n";
|
||||
|
||||
/// <summary>
|
||||
/// macOS 系统。
|
||||
/// </summary>
|
||||
public const string MacOs = "\r";
|
||||
|
||||
/// <summary>
|
||||
/// UNIX 系统(Linux)。
|
||||
/// </summary>
|
||||
public const string Unix = "\n";
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using ZonyLrcTools.Cli.Config;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Extensions;
|
||||
using ZonyLrcTools.Common.Configuration;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
{
|
||||
@@ -17,11 +18,11 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
/// </summary>
|
||||
public bool IsPruneMusic => Count == 0;
|
||||
|
||||
public LyricConfigOption Option { get; private set; }
|
||||
public GlobalLyricsConfigOptions Options { get; private set; }
|
||||
|
||||
public LyricItemCollection(LyricConfigOption option)
|
||||
public LyricItemCollection(GlobalLyricsConfigOptions options)
|
||||
{
|
||||
Option = option;
|
||||
Options = options;
|
||||
}
|
||||
|
||||
public static LyricItemCollection operator +(LyricItemCollection left, LyricItemCollection right)
|
||||
@@ -31,7 +32,7 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
return left;
|
||||
}
|
||||
|
||||
var option = left.Option;
|
||||
var option = left.Options;
|
||||
var newCollection = new LyricItemCollection(option);
|
||||
var indexDiff = left.Count - right.Count;
|
||||
if (!option.IsOneLine)
|
||||
@@ -104,8 +105,8 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
public override string ToString()
|
||||
{
|
||||
var lyricBuilder = new StringBuilder();
|
||||
ForEach(lyric => lyricBuilder.Append(lyric).Append(Option.LineBreak));
|
||||
return lyricBuilder.ToString().TrimEnd(Option.LineBreak);
|
||||
ForEach(lyric => lyricBuilder.Append(lyric).Append(Options.LineBreak));
|
||||
return lyricBuilder.ToString().TrimEnd(Options.LineBreak);
|
||||
}
|
||||
|
||||
public byte[] GetUtf8Bytes()
|
||||
|
@@ -1,25 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using YamlDotNet.Serialization;
|
||||
using ZonyLrcTools.Cli.Config;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Tag
|
||||
{
|
||||
public class TagInfoProviderOption
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Priority { get; set; }
|
||||
|
||||
public Dictionary<string, string> Extensions { get; set; }
|
||||
}
|
||||
|
||||
public class TagOption
|
||||
{
|
||||
public IEnumerable<TagInfoProviderOption> Plugin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 屏蔽词功能相关配置。
|
||||
/// </summary>
|
||||
public BlockWordOption BlockWord { get; set; }
|
||||
}
|
||||
}
|
@@ -43,4 +43,8 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZonyLrcTools.Common\ZonyLrcTools.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user