diff --git a/src/ZonyLrcTools.Common/Lyrics/ILyricsItemCollectionFactory.cs b/src/ZonyLrcTools.Common/Lyrics/ILyricsItemCollectionFactory.cs
index 4cc5ad6..f5877c2 100644
--- a/src/ZonyLrcTools.Common/Lyrics/ILyricsItemCollectionFactory.cs
+++ b/src/ZonyLrcTools.Common/Lyrics/ILyricsItemCollectionFactory.cs
@@ -18,6 +18,6 @@ namespace ZonyLrcTools.Common.Lyrics
/// 原始歌词数据。
/// 翻译歌词数据。
/// 构建完成的 对象。
- LyricsItemCollection Build(string sourceLyric, string translationLyric);
+ LyricsItemCollection Build(string sourceLyric, string? translationLyric);
}
}
\ No newline at end of file
diff --git a/src/ZonyLrcTools.Common/Lyrics/LyricsItemCollectionFactory.cs b/src/ZonyLrcTools.Common/Lyrics/LyricsItemCollectionFactory.cs
index 64b0836..a248322 100644
--- a/src/ZonyLrcTools.Common/Lyrics/LyricsItemCollectionFactory.cs
+++ b/src/ZonyLrcTools.Common/Lyrics/LyricsItemCollectionFactory.cs
@@ -30,7 +30,7 @@ namespace ZonyLrcTools.Common.Lyrics
return lyric;
}
- public LyricsItemCollection Build(string sourceLyric, string translationLyric)
+ public LyricsItemCollection Build(string sourceLyric, string? translationLyric)
{
var lyric = new LyricsItemCollection(_options.Provider.Lyric.Config);
if (string.IsNullOrEmpty(sourceLyric))
diff --git a/src/ZonyLrcTools.Common/Lyrics/Providers/KuWo/JsonModel/GetLyricsResponse.cs b/src/ZonyLrcTools.Common/Lyrics/Providers/KuWo/JsonModel/GetLyricsResponse.cs
index 03f4de6..1805174 100644
--- a/src/ZonyLrcTools.Common/Lyrics/Providers/KuWo/JsonModel/GetLyricsResponse.cs
+++ b/src/ZonyLrcTools.Common/Lyrics/Providers/KuWo/JsonModel/GetLyricsResponse.cs
@@ -15,7 +15,7 @@ public class GetLyricsResponse
public class GetLyricsResponseInnerData
{
- [JsonProperty("lrclist")] public ICollection Lyrics { get; set; }
+ [JsonProperty("lrclist")] public ICollection? Lyrics { get; set; }
}
public class GetLyricsItem
diff --git a/src/ZonyLrcTools.Common/Lyrics/Providers/KuWo/KuWoLyricsProvider.cs b/src/ZonyLrcTools.Common/Lyrics/Providers/KuWo/KuWoLyricsProvider.cs
index e101b58..9d15c46 100644
--- a/src/ZonyLrcTools.Common/Lyrics/Providers/KuWo/KuWoLyricsProvider.cs
+++ b/src/ZonyLrcTools.Common/Lyrics/Providers/KuWo/KuWoLyricsProvider.cs
@@ -60,6 +60,11 @@ public class KuWoLyricsProvider : LyricsProvider
await ValueTask.CompletedTask;
var lyricsResponse = (GetLyricsResponse)lyricsObject;
+ if (lyricsResponse.Data.Lyrics == null)
+ {
+ return new LyricsItemCollection(null);
+ }
+
var items = lyricsResponse.Data.Lyrics.Select(l =>
{
var position = double.Parse(l.Position);
diff --git a/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/JsonModel/GetLyricResponse.cs b/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/JsonModel/GetLyricResponse.cs
index 1461b5a..4bb851f 100644
--- a/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/JsonModel/GetLyricResponse.cs
+++ b/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/JsonModel/GetLyricResponse.cs
@@ -20,7 +20,7 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.NetEase.JsonModel
/// 如果存在翻译歌词,则本项内容为翻译歌词。
///
[JsonProperty("tlyric")]
- public InnerLyric TranslationLyric { get; set; }
+ public InnerLyric? TranslationLyric { get; set; }
///
/// 如果存在罗马音歌词,则本项内容为罗马音歌词。
diff --git a/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/JsonModel/SongSearchResponse.cs b/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/JsonModel/SongSearchResponse.cs
index 67150d5..314e810 100644
--- a/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/JsonModel/SongSearchResponse.cs
+++ b/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/JsonModel/SongSearchResponse.cs
@@ -10,11 +10,6 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.NetEase.JsonModel
public int GetFirstMatchSongId(string songName, long? duration)
{
- if (Items == null || Items.SongItems == null)
- {
- Console.Write("xx");
- }
-
var perfectMatch = Items.SongItems.FirstOrDefault(x => x.Name == songName);
if (perfectMatch != null)
{
diff --git a/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/NetEaseLyricsProvider.cs b/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/NetEaseLyricsProvider.cs
index 8e52774..36f597f 100644
--- a/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/NetEaseLyricsProvider.cs
+++ b/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/NetEaseLyricsProvider.cs
@@ -76,7 +76,7 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.NetEase
return _lyricsItemCollectionFactory.Build(
json.OriginalLyric.Text,
- json.TranslationLyric.Text);
+ json.TranslationLyric?.Text);
}
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricsProviderArgs args)
diff --git a/tests/ZonyLrcTools.Tests/Infrastructure/Lyrics/KuWoLyricsProviderTests.cs b/tests/ZonyLrcTools.Tests/Infrastructure/Lyrics/KuWoLyricsProviderTests.cs
index 258234a..d24a198 100644
--- a/tests/ZonyLrcTools.Tests/Infrastructure/Lyrics/KuWoLyricsProviderTests.cs
+++ b/tests/ZonyLrcTools.Tests/Infrastructure/Lyrics/KuWoLyricsProviderTests.cs
@@ -25,4 +25,13 @@ public class KuWoLyricsProviderTests : TestBase
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBeFalse();
}
+
+ [Fact]
+ public async Task DownloadAsync_Source_Null_Test()
+ {
+ var lyric = await _kuwoLyricsProvider.DownloadAsync("Concerto for Piano and Orchestra No. 12 in A major, K414 - 1. Allegro",
+ "Wolfgang Amadeus Mozart");
+
+ lyric.IsPruneMusic.ShouldBeTrue();
+ }
}
\ No newline at end of file
diff --git a/tests/ZonyLrcTools.Tests/Infrastructure/Lyrics/NetEaseLyricsProviderTests.cs b/tests/ZonyLrcTools.Tests/Infrastructure/Lyrics/NetEaseLyricsProviderTests.cs
index 04f7b0f..656f4e7 100644
--- a/tests/ZonyLrcTools.Tests/Infrastructure/Lyrics/NetEaseLyricsProviderTests.cs
+++ b/tests/ZonyLrcTools.Tests/Infrastructure/Lyrics/NetEaseLyricsProviderTests.cs
@@ -120,5 +120,14 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyrics
var result = await Should.ThrowAsync(_lyricsProvider.DownloadAsync("創世記", "りりィ").AsTask);
result.ErrorCode.ShouldBe(ErrorCodes.NoMatchingSong);
}
+
+ [Fact]
+ public async Task DownloadAsync_Source_Null_Test()
+ {
+ var lyric = await _lyricsProvider.DownloadAsync("Concerto for Piano and Orchestra No. 12 in A major, K414 - 1. Allegro",
+ "Wolfgang Amadeus Mozart");
+
+ lyric.IsPruneMusic.ShouldBeTrue();
+ }
}
}
\ No newline at end of file