mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-02 05:10:42 +00:00
feat: 屏蔽词功能同标签读取器集成。
This commit is contained in:
parent
e917f6ee80
commit
625f24ccbf
@ -87,10 +87,12 @@ namespace ZonyLrcTools.Cli.Commands
|
|||||||
var buffer = new Memory<byte>(new byte[2048]);
|
var buffer = new Memory<byte>(new byte[2048]);
|
||||||
while (await file.ReadAsync(buffer) > 0)
|
while (await file.ReadAsync(buffer) > 0)
|
||||||
{
|
{
|
||||||
|
// TODO: Large Object Issue!!!!!
|
||||||
await memoryStream.WriteAsync(buffer);
|
await memoryStream.WriteAsync(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Large Object Issue!!!!!
|
||||||
var result = await _musicDecryptor.ConvertMusic(memoryStream.ToArray());
|
var result = await _musicDecryptor.ConvertMusic(memoryStream.ToArray());
|
||||||
var newFileName = Path.Combine(Path.GetDirectoryName(filePath),
|
var newFileName = Path.Combine(Path.GetDirectoryName(filePath),
|
||||||
$"{Path.GetFileNameWithoutExtension(filePath)}.{((JObject) result.ExtensionObjects["JSON"]).SelectToken("$.format").Value<string>()}");
|
$"{Path.GetFileNameWithoutExtension(filePath)}.{((JObject) result.ExtensionObjects["JSON"]).SelectToken("$.format").Value<string>()}");
|
||||||
|
@ -13,12 +13,12 @@ namespace ZonyLrcTools.Cli.Infrastructure
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 歌曲的名称。
|
/// 歌曲的名称。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 歌曲的作者。
|
/// 歌曲的作者。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Artist { get; }
|
public string Artist { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建一个新的 <see cref="MusicInfo"/> 对象。
|
/// 构建一个新的 <see cref="MusicInfo"/> 对象。
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using ZonyLrcTools.Cli.Config;
|
||||||
using ZonyLrcTools.Cli.Infrastructure.DependencyInject;
|
using ZonyLrcTools.Cli.Infrastructure.DependencyInject;
|
||||||
using ZonyLrcTools.Cli.Infrastructure.Exceptions;
|
using ZonyLrcTools.Cli.Infrastructure.Exceptions;
|
||||||
|
|
||||||
@ -12,10 +14,16 @@ namespace ZonyLrcTools.Cli.Infrastructure.Tag
|
|||||||
public class DefaultTagLoader : ITagLoader, ITransientDependency
|
public class DefaultTagLoader : ITagLoader, ITransientDependency
|
||||||
{
|
{
|
||||||
protected readonly IEnumerable<ITagInfoProvider> TagInfoProviders;
|
protected readonly IEnumerable<ITagInfoProvider> TagInfoProviders;
|
||||||
|
protected readonly IBlockWordDictionary BlockWordDictionary;
|
||||||
|
protected ToolOptions Options;
|
||||||
|
|
||||||
public DefaultTagLoader(IEnumerable<ITagInfoProvider> tagInfoProviders)
|
public DefaultTagLoader(IEnumerable<ITagInfoProvider> tagInfoProviders,
|
||||||
|
IBlockWordDictionary blockWordDictionary,
|
||||||
|
IOptions<ToolOptions> options)
|
||||||
{
|
{
|
||||||
TagInfoProviders = tagInfoProviders;
|
TagInfoProviders = tagInfoProviders;
|
||||||
|
BlockWordDictionary = blockWordDictionary;
|
||||||
|
Options = options.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual async ValueTask<MusicInfo> LoadTagAsync(string filePath)
|
public virtual async ValueTask<MusicInfo> LoadTagAsync(string filePath)
|
||||||
@ -30,11 +38,21 @@ namespace ZonyLrcTools.Cli.Infrastructure.Tag
|
|||||||
var info = await provider.LoadAsync(filePath);
|
var info = await provider.LoadAsync(filePath);
|
||||||
if (info != null)
|
if (info != null)
|
||||||
{
|
{
|
||||||
|
HandleBlockWord(info);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void HandleBlockWord(MusicInfo info)
|
||||||
|
{
|
||||||
|
if (Options.BlockWordOptions.IsEnable)
|
||||||
|
{
|
||||||
|
info.Name = BlockWordDictionary.GetValue(info.Name) ?? info.Name;
|
||||||
|
info.Artist = BlockWordDictionary.GetValue(info.Name) ?? info.Artist;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user