mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-01 20:30:41 +00:00
feat: Provide the 'isOnlyOutputTranslation option to output only translated lyrics.
This commit is contained in:
parent
be4380c744
commit
8385f6f118
@ -36,4 +36,9 @@ public class LyricConfigOption
|
|||||||
/// 歌词文件的编码格式。
|
/// 歌词文件的编码格式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileEncoding { get; set; } = "utf-8";
|
public string FileEncoding { get; set; } = "utf-8";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否只输出翻译歌词。
|
||||||
|
/// </summary>
|
||||||
|
public bool IsOnlyOutputTranslation { get; set; } = false;
|
||||||
}
|
}
|
@ -43,6 +43,11 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
|||||||
if (_options.Provider.Lyric.Config.IsEnableTranslation && !string.IsNullOrEmpty(translationLyric))
|
if (_options.Provider.Lyric.Config.IsEnableTranslation && !string.IsNullOrEmpty(translationLyric))
|
||||||
{
|
{
|
||||||
var translatedLyric = InternalBuildLyricObject(new LyricItemCollection(_options.Provider.Lyric.Config), translationLyric);
|
var translatedLyric = InternalBuildLyricObject(new LyricItemCollection(_options.Provider.Lyric.Config), translationLyric);
|
||||||
|
if (_options.Provider.Lyric.Config.IsOnlyOutputTranslation)
|
||||||
|
{
|
||||||
|
return translatedLyric;
|
||||||
|
}
|
||||||
|
|
||||||
return lyric + translatedLyric;
|
return lyric + translatedLyric;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,9 @@ globalOption:
|
|||||||
priority: 3
|
priority: 3
|
||||||
# 歌词下载的一些共有配置参数。
|
# 歌词下载的一些共有配置参数。
|
||||||
config:
|
config:
|
||||||
isOneLine: true # 双语歌词是否合并为一行展示。
|
isOneLine: true # 双语歌词是否合并为一行展示。
|
||||||
lineBreak: "\n" # 换行符的类型,记得使用双引号指定。
|
lineBreak: "\n" # 换行符的类型,记得使用双引号指定。
|
||||||
isEnableTranslation: true # 是否启用翻译歌词。
|
isEnableTranslation: true # 是否启用翻译歌词。
|
||||||
isSkipExistLyricFiles: false # 如果歌词文件已经存在,是否跳过这些文件。
|
isOnlyOutputTranslation: false # 是否只输出翻译歌词。
|
||||||
fileEncoding: 'utf-8' # 歌词文件的编码格式。
|
isSkipExistLyricFiles: false # 如果歌词文件已经存在,是否跳过这些文件。
|
||||||
|
fileEncoding: 'utf-8' # 歌词文件的编码格式。
|
@ -1,8 +1,11 @@
|
|||||||
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.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using ZonyLrcTools.Cli.Config;
|
||||||
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||||
|
|
||||||
namespace ZonyLrcTools.Tests.Infrastructure.Lyric
|
namespace ZonyLrcTools.Tests.Infrastructure.Lyric
|
||||||
@ -84,5 +87,15 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
|
|||||||
var lyric = await _lyricDownloader.DownloadAsync("君への嘘", "VALSHE");
|
var lyric = await _lyricDownloader.DownloadAsync("君への嘘", "VALSHE");
|
||||||
lyric.ShouldNotBeEmpty();
|
lyric.ShouldNotBeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task DownloadAsync_Issue114_Test()
|
||||||
|
{
|
||||||
|
var options = ServiceProvider.GetRequiredService<IOptions<ToolOptions>>();
|
||||||
|
options.Value.Provider.Lyric.Config.IsOnlyOutputTranslation = true;
|
||||||
|
|
||||||
|
var lyric = await _lyricDownloader.DownloadAsync("Bones", "Image Dragons");
|
||||||
|
lyric.ToString().ShouldNotContain("Gimme, gimme, gimme some time to think");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user