mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-01 12:11:13 +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>
|
||||
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))
|
||||
{
|
||||
var translatedLyric = InternalBuildLyricObject(new LyricItemCollection(_options.Provider.Lyric.Config), translationLyric);
|
||||
if (_options.Provider.Lyric.Config.IsOnlyOutputTranslation)
|
||||
{
|
||||
return translatedLyric;
|
||||
}
|
||||
|
||||
return lyric + translatedLyric;
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,9 @@ globalOption:
|
||||
priority: 3
|
||||
# 歌词下载的一些共有配置参数。
|
||||
config:
|
||||
isOneLine: true # 双语歌词是否合并为一行展示。
|
||||
lineBreak: "\n" # 换行符的类型,记得使用双引号指定。
|
||||
isEnableTranslation: true # 是否启用翻译歌词。
|
||||
isSkipExistLyricFiles: false # 如果歌词文件已经存在,是否跳过这些文件。
|
||||
fileEncoding: 'utf-8' # 歌词文件的编码格式。
|
||||
isOneLine: true # 双语歌词是否合并为一行展示。
|
||||
lineBreak: "\n" # 换行符的类型,记得使用双引号指定。
|
||||
isEnableTranslation: true # 是否启用翻译歌词。
|
||||
isOnlyOutputTranslation: false # 是否只输出翻译歌词。
|
||||
isSkipExistLyricFiles: false # 如果歌词文件已经存在,是否跳过这些文件。
|
||||
fileEncoding: 'utf-8' # 歌词文件的编码格式。
|
@ -1,8 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Config;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Lyric
|
||||
@ -84,5 +87,15 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
|
||||
var lyric = await _lyricDownloader.DownloadAsync("君への嘘", "VALSHE");
|
||||
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