refactor: Move the related configuration items to the Common library.

This commit is contained in:
real-zony
2022-10-06 12:27:21 +08:00
parent bccfaaaa5b
commit 9f96aa0186
16 changed files with 89 additions and 71 deletions

View File

@@ -0,0 +1,18 @@
namespace ZonyLrcTools.Common.Configuration
{
/// <summary>
/// 屏蔽词选项类。
/// </summary>
public class BlockWordOptions
{
/// <summary>
/// 是否启用本功能。
/// </summary>
public bool IsEnable { get; set; }
/// <summary>
/// 屏蔽词字典文件,用于替换歌曲名或者歌手名称。
/// </summary>
public string FilePath { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
using ZonyLrcTools.Common.Lyrics;
namespace ZonyLrcTools.Common.Configuration;
public class GlobalLyricsConfigOptions
{
/// <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;
}

View File

@@ -0,0 +1,13 @@
namespace ZonyLrcTools.Common.Configuration;
public class LyricsOptions
{
public IEnumerable<LyricsProviderOptions> Plugin { get; set; }
public GlobalLyricsConfigOptions Config { get; set; }
public LyricsProviderOptions GetLyricProviderOption(string name)
{
return Plugin.FirstOrDefault(x => x.Name == name);
}
}

View File

@@ -0,0 +1,20 @@
namespace ZonyLrcTools.Common.Configuration
{
public class LyricsProviderOptions
{
/// <summary>
/// 歌词下载器的唯一标识。
/// </summary>
public string Name { get; set; }
/// <summary>
/// 歌词下载时的优先级,当值为 -1 时是禁用。
/// </summary>
public int Priority { get; set; }
/// <summary>
/// 搜索深度,值越大搜索结果越多,但搜索时间越长。
/// </summary>
public int Depth { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
namespace ZonyLrcTools.Common.Configuration;
public class ProviderOptions
{
/// <summary>
/// 标签加载器相关的配置属性。
/// </summary>
public TagInfoOptions Tag { get; set; }
/// <summary>
/// 歌词下载相关的配置信息。
/// </summary>
public LyricsOptions Lyric { get; set; }
}

View File

@@ -0,0 +1,11 @@
namespace ZonyLrcTools.Common.Configuration;
public class TagInfoOptions
{
public IEnumerable<TagInfoProviderOptions> Plugin { get; set; }
/// <summary>
/// 屏蔽词功能相关配置。
/// </summary>
public BlockWordOptions BlockWord { get; set; }
}

View File

@@ -0,0 +1,11 @@
namespace ZonyLrcTools.Common.Configuration
{
public class TagInfoProviderOptions
{
public string Name { get; set; }
public int Priority { get; set; }
public Dictionary<string, string> Extensions { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
namespace ZonyLrcTools.Common.Lyrics
{
/// <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";
}
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>