diff --git a/src/ZonyLrcTools.Cli/Config/LyricOption.cs b/src/ZonyLrcTools.Cli/Config/LyricOption.cs
index 6bb756f..812b019 100644
--- a/src/ZonyLrcTools.Cli/Config/LyricOption.cs
+++ b/src/ZonyLrcTools.Cli/Config/LyricOption.cs
@@ -36,4 +36,9 @@ public class LyricConfigOption
/// 歌词文件的编码格式。
///
public string FileEncoding { get; set; } = "utf-8";
+
+ ///
+ /// 是否只输出翻译歌词。
+ ///
+ public bool IsOnlyOutputTranslation { get; set; } = false;
}
\ No newline at end of file
diff --git a/src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricItemCollectionFactory.cs b/src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricItemCollectionFactory.cs
index 861d482..259a01e 100644
--- a/src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricItemCollectionFactory.cs
+++ b/src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricItemCollectionFactory.cs
@@ -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;
}
diff --git a/src/ZonyLrcTools.Cli/config.yaml b/src/ZonyLrcTools.Cli/config.yaml
index 58955f1..380d93c 100644
--- a/src/ZonyLrcTools.Cli/config.yaml
+++ b/src/ZonyLrcTools.Cli/config.yaml
@@ -41,8 +41,9 @@ globalOption:
priority: 3
# 歌词下载的一些共有配置参数。
config:
- isOneLine: true # 双语歌词是否合并为一行展示。
- lineBreak: "\n" # 换行符的类型,记得使用双引号指定。
- isEnableTranslation: true # 是否启用翻译歌词。
- isSkipExistLyricFiles: false # 如果歌词文件已经存在,是否跳过这些文件。
- fileEncoding: 'utf-8' # 歌词文件的编码格式。
\ No newline at end of file
+ isOneLine: true # 双语歌词是否合并为一行展示。
+ lineBreak: "\n" # 换行符的类型,记得使用双引号指定。
+ isEnableTranslation: true # 是否启用翻译歌词。
+ isOnlyOutputTranslation: false # 是否只输出翻译歌词。
+ isSkipExistLyricFiles: false # 如果歌词文件已经存在,是否跳过这些文件。
+ fileEncoding: 'utf-8' # 歌词文件的编码格式。
\ No newline at end of file
diff --git a/tests/ZonyLrcTools.Tests/Infrastructure/Lyric/NetEaseLyricDownloaderTests.cs b/tests/ZonyLrcTools.Tests/Infrastructure/Lyric/NetEaseLyricDownloaderTests.cs
index 11d3ef7..c5cab07 100644
--- a/tests/ZonyLrcTools.Tests/Infrastructure/Lyric/NetEaseLyricDownloaderTests.cs
+++ b/tests/ZonyLrcTools.Tests/Infrastructure/Lyric/NetEaseLyricDownloaderTests.cs
@@ -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>();
+ 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");
+ }
}
}
\ No newline at end of file