mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-06 21:56:53 +00:00
Use YAML as configuration file; fix a download failure issue with QQ Music. (Reason: QQ Music API changed)
This commit is contained in:
@@ -9,8 +9,7 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
/// 根据指定的歌曲数据构建新的 <see cref="LyricItemCollection"/> 实例。
|
||||
/// </summary>
|
||||
/// <param name="sourceLyric">原始歌词数据。</param>
|
||||
/// <param name="translateLyric">翻译歌词数据。</param>
|
||||
/// <returns>构建完成的 <see cref="LyricItemCollection"/> 对象。</returns>
|
||||
LyricItemCollection Build(string sourceLyric, string translateLyric = null);
|
||||
LyricItemCollection Build(string sourceLyric);
|
||||
}
|
||||
}
|
@@ -16,9 +16,9 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
/// </summary>
|
||||
public bool IsPruneMusic => Count == 0;
|
||||
|
||||
public LyricItemCollectionOption Option { get; private set; }
|
||||
public LyricConfigOption Option { get; private set; }
|
||||
|
||||
public LyricItemCollection(LyricItemCollectionOption option)
|
||||
public LyricItemCollection(LyricConfigOption option)
|
||||
{
|
||||
Option = option;
|
||||
}
|
||||
@@ -33,7 +33,6 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
var option = left.Option;
|
||||
var newCollection = new LyricItemCollection(option);
|
||||
var indexDiff = left.Count - right.Count;
|
||||
|
||||
if (!option.IsOneLine)
|
||||
{
|
||||
left.ForEach(item => newCollection.Add(item));
|
||||
|
@@ -17,9 +17,9 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
_options = options.Value;
|
||||
}
|
||||
|
||||
public LyricItemCollection Build(string sourceLyric, string translateLyric = null)
|
||||
public LyricItemCollection Build(string sourceLyric)
|
||||
{
|
||||
var items = new LyricItemCollection(_options.LyricOption);
|
||||
var items = new LyricItemCollection(_options.Provider.Lyric.Config);
|
||||
if (string.IsNullOrEmpty(sourceLyric))
|
||||
{
|
||||
return items;
|
||||
|
@@ -1,17 +0,0 @@
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
{
|
||||
public class LyricItemCollectionOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 双语歌词是否合并为一行。
|
||||
/// </summary>
|
||||
public bool IsOneLine { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 换行符格式,取值来自 <see cref="LineBreakType"/> 常量类。
|
||||
/// </summary>
|
||||
public string LineBreak { get; set; } = LineBreakType.Windows;
|
||||
|
||||
public static readonly LyricItemCollectionOption NullInstance = new();
|
||||
}
|
||||
}
|
28
src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricOption.cs
Normal file
28
src/ZonyLrcTools.Cli/Infrastructure/Lyric/LyricOption.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||
|
||||
public class LyricOption
|
||||
{
|
||||
public IEnumerable<LyricProviderOption> Plugin { get; set; }
|
||||
|
||||
public LyricConfigOption Config { get; set; }
|
||||
}
|
||||
|
||||
public class LyricConfigOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 双语歌词是否合并为一行。
|
||||
/// </summary>
|
||||
public bool IsOneLine { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 换行符格式,取值来自 <see cref="LineBreakType"/> 常量类。
|
||||
/// </summary>
|
||||
public string LineBreak { get; set; } = LineBreakType.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用歌词翻译功能。
|
||||
/// </summary>
|
||||
public bool IsEnableTranslation { get; set; } = false;
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
namespace ZonyLrcTools.Cli.Infrastructure.Lyric
|
||||
{
|
||||
public class LyricDownloaderOption
|
||||
public class LyricProviderOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 歌词下载器的唯一标识。
|
@@ -61,7 +61,7 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric.NetEase
|
||||
var json = JsonConvert.DeserializeObject<GetLyricResponse>(Encoding.UTF8.GetString(data));
|
||||
if (json?.OriginalLyric == null)
|
||||
{
|
||||
return new LyricItemCollection(LyricItemCollectionOption.NullInstance);
|
||||
return new LyricItemCollection(null);
|
||||
}
|
||||
|
||||
if (json.OriginalLyric.Text.Contains("纯音乐,请欣赏"))
|
||||
@@ -70,8 +70,7 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric.NetEase
|
||||
}
|
||||
|
||||
return _lyricItemCollectionFactory.Build(
|
||||
json.OriginalLyric.Text,
|
||||
json.TranslationLyric?.Text);
|
||||
json.OriginalLyric.Text);
|
||||
}
|
||||
|
||||
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricDownloaderArgs args)
|
||||
|
@@ -6,70 +6,32 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric.QQMusic.JsonModel
|
||||
{
|
||||
public class SongSearchRequest
|
||||
{
|
||||
[JsonProperty("ct")] public int UnknownParameter1 { get; set; }
|
||||
|
||||
[JsonProperty("qqmusic_ver")] public int ClientVersion { get; set; }
|
||||
|
||||
[JsonProperty("new_json")] public int UnknownParameter2 { get; set; }
|
||||
|
||||
[JsonProperty("remoteplace")] public string RemotePlace { get; set; }
|
||||
|
||||
[JsonProperty("t")] public int UnknownParameter3 { get; set; }
|
||||
|
||||
[JsonProperty("aggr")] public int UnknownParameter4 { get; set; }
|
||||
|
||||
[JsonProperty("cr")] public int UnknownParameter5 { get; set; }
|
||||
|
||||
[JsonProperty("catZhida")] public int UnknownParameter6 { get; set; }
|
||||
|
||||
[JsonProperty("lossless")] public int LossLess { get; set; }
|
||||
|
||||
[JsonProperty("flag_qc")] public int UnknownParameter7 { get; set; }
|
||||
|
||||
[JsonProperty("p")] public int Page { get; set; }
|
||||
|
||||
[JsonProperty("n")] public int Limit { get; set; }
|
||||
|
||||
[JsonProperty("w")] public string Keyword { get; set; }
|
||||
|
||||
[JsonProperty("g_tk")] public int UnknownParameter8 { get; set; }
|
||||
|
||||
[JsonProperty("hostUin")] public int UnknownParameter9 { get; set; }
|
||||
|
||||
[JsonProperty("format")] public string ResultFormat { get; set; }
|
||||
|
||||
[JsonProperty("inCharset")] public string InCharset { get; set; }
|
||||
|
||||
[JsonProperty("outCharset")] public string OutCharset { get; set; }
|
||||
|
||||
[JsonProperty("notice")] public int UnknownParameter10 { get; set; }
|
||||
|
||||
[JsonProperty("platform")] public string Platform { get; set; }
|
||||
|
||||
[JsonProperty("needNewCode")] public int UnknownParameter11 { get; set; }
|
||||
|
||||
protected SongSearchRequest()
|
||||
{
|
||||
UnknownParameter1 = 24;
|
||||
ClientVersion = 1298;
|
||||
UnknownParameter2 = 1;
|
||||
RemotePlace = "txt.yqq.song";
|
||||
UnknownParameter3 = 0;
|
||||
UnknownParameter4 = 1;
|
||||
UnknownParameter5 = 1;
|
||||
UnknownParameter6 = 1;
|
||||
LossLess = 0;
|
||||
UnknownParameter7 = 0;
|
||||
Page = 1;
|
||||
Limit = 5;
|
||||
UnknownParameter8 = 5381;
|
||||
UnknownParameter9 = 0;
|
||||
ResultFormat = "json";
|
||||
InCharset = "utf8";
|
||||
OutCharset = "utf8";
|
||||
UnknownParameter10 = 0;
|
||||
Platform = "yqq";
|
||||
UnknownParameter11 = 0;
|
||||
}
|
||||
|
||||
public SongSearchRequest(string musicName, string artistName) : this()
|
||||
|
@@ -22,11 +22,6 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric.QQMusic.JsonModel
|
||||
|
||||
public class QQMusicInnerSongItem
|
||||
{
|
||||
[JsonProperty("mid")] public string SongId { get; set; }
|
||||
}
|
||||
|
||||
public class AlbumInfo
|
||||
{
|
||||
[JsonProperty("id")] public long Id { get; set; }
|
||||
[JsonProperty("songmid")] public string SongId { get; set; }
|
||||
}
|
||||
}
|
@@ -65,7 +65,7 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric.QQMusic
|
||||
var sourceLyric = HttpUtility.HtmlDecode(HttpUtility.HtmlDecode(lyricJsonObj.SelectToken("$.lyric").Value<string>()));
|
||||
var translateLyric = HttpUtility.HtmlDecode(HttpUtility.HtmlDecode(lyricJsonObj.SelectToken("$.trans").Value<string>()));
|
||||
|
||||
return _lyricItemCollectionFactory.Build(sourceLyric, translateLyric);
|
||||
return _lyricItemCollectionFactory.Build(sourceLyric);
|
||||
}
|
||||
|
||||
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricDownloaderArgs args)
|
||||
|
Reference in New Issue
Block a user