mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-04 20:46:54 +00:00
feat: Completed KuWo lyric source.
This commit is contained in:
@@ -9,7 +9,7 @@ globalOption:
|
||||
isEnable: false # 是否启用代理。
|
||||
ip: 127.0.0.1 # 代理服务 IP 地址。
|
||||
port: 4780 # 代理服务端口号。
|
||||
updateUrl: https://api.zony.me/lrc-tools/update # 更新检查地址。
|
||||
updateUrl: https://api.myzony.com/lrc-tools/update # 更新检查地址。
|
||||
|
||||
# 下载器的相关参数配置。
|
||||
provider:
|
||||
|
@@ -6,13 +6,18 @@ public class GetLyricsResponse
|
||||
{
|
||||
[JsonProperty("status")] public int Status { get; set; }
|
||||
|
||||
[JsonProperty("lrclist")] public ICollection<GetLyricsItem> Lyrics { get; set; }
|
||||
[JsonProperty("data")] public GetLyricsResponseInnerData Data { get; set; }
|
||||
|
||||
[JsonProperty("msg")] public string? ErrorMessage { get; set; }
|
||||
|
||||
[JsonProperty("msgs")] public string? ErrorMessage2 { get; set; }
|
||||
}
|
||||
|
||||
public class GetLyricsResponseInnerData
|
||||
{
|
||||
[JsonProperty("lrclist")] public ICollection<GetLyricsItem> Lyrics { get; set; }
|
||||
}
|
||||
|
||||
public class GetLyricsItem
|
||||
{
|
||||
[JsonProperty("lineLyric")] public string Text { get; set; }
|
||||
|
@@ -55,16 +55,33 @@ public class KuWoLyricsProvider : LyricsProvider
|
||||
});
|
||||
}
|
||||
|
||||
protected override ValueTask<LyricsItemCollection> GenerateLyricAsync(object lyricsObject, LyricsProviderArgs args)
|
||||
protected override async ValueTask<LyricsItemCollection> GenerateLyricAsync(object lyricsObject, LyricsProviderArgs args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
await ValueTask.CompletedTask;
|
||||
|
||||
var lyricsResponse = (GetLyricsResponse)lyricsObject;
|
||||
var items = lyricsResponse.Data.Lyrics.Select(l =>
|
||||
{
|
||||
var position = double.Parse(l.Position);
|
||||
var positionSpan = TimeSpan.FromSeconds(position);
|
||||
return new LyricsItem(positionSpan.Minutes, double.Parse($"{positionSpan.Seconds}.{positionSpan.Milliseconds}"), l.Text);
|
||||
});
|
||||
|
||||
var lyricsItemCollection = new LyricsItemCollection(_options.Provider.Lyric.Config);
|
||||
lyricsItemCollection.AddRange(items);
|
||||
return lyricsItemCollection;
|
||||
}
|
||||
|
||||
protected void ValidateSongSearchResponse(SongSearchResponse response, LyricsProviderArgs args)
|
||||
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricsProviderArgs args)
|
||||
{
|
||||
if (response.Code != 200)
|
||||
{
|
||||
throw new ErrorCodeException(ErrorCodes.TheReturnValueIsIllegal, response.ErrorMessage, args);
|
||||
}
|
||||
|
||||
if (response.InnerData.SongItems.Count == 0)
|
||||
{
|
||||
throw new ErrorCodeException(ErrorCodes.NoMatchingSong, attachObj: args);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user