refactor: Renamed Lyric to Lyrics.

This commit is contained in:
real-zony 2022-10-23 12:42:46 +08:00
parent 895f68184d
commit 3e27e18098
17 changed files with 94 additions and 88 deletions

View File

@ -27,7 +27,7 @@ namespace ZonyLrcTools.Cli.Commands.SubCommand
private readonly ILogger<DownloadCommand> _logger;
private readonly IFileScanner _fileScanner;
private readonly ITagLoader _tagLoader;
private readonly IEnumerable<ILyricDownloader> _lyricDownloaderList;
private readonly IEnumerable<ILyricsProvider> _lyricDownloaderList;
private readonly IEnumerable<IAlbumDownloader> _albumDownloaderList;
private readonly GlobalOptions _options;
@ -36,7 +36,7 @@ namespace ZonyLrcTools.Cli.Commands.SubCommand
IFileScanner fileScanner,
IOptions<GlobalOptions> options,
ITagLoader tagLoader,
IEnumerable<ILyricDownloader> lyricDownloaderList,
IEnumerable<ILyricsProvider> lyricDownloaderList,
IEnumerable<IAlbumDownloader> albumDownloaderList)
{
_logger = logger;
@ -143,7 +143,7 @@ namespace ZonyLrcTools.Cli.Commands.SubCommand
return result.ToImmutableList();
}
private IEnumerable<ILyricDownloader> GetLyricDownloaderList()
private IEnumerable<ILyricsProvider> GetLyricDownloaderList()
{
var downloader = _options.Provider.Lyric.Plugin
.Where(op => op.Priority != -1)
@ -172,9 +172,9 @@ namespace ZonyLrcTools.Cli.Commands.SubCommand
_logger.LogInformation($"歌词数据下载完成,成功: {musicInfos.Count(m => m.IsSuccessful)} 失败{musicInfos.Count(m => m.IsSuccessful == false)}。");
}
private async Task DownloadLyricTaskLogicAsync(IEnumerable<ILyricDownloader> downloaderList, MusicInfo info)
private async Task DownloadLyricTaskLogicAsync(IEnumerable<ILyricsProvider> downloaderList, MusicInfo info)
{
async Task InternalDownloadLogicAsync(ILyricDownloader downloader)
async Task InternalDownloadLogicAsync(ILyricsProvider downloader)
{
try
{

View File

@ -0,0 +1,6 @@
namespace ZonyLrcTools.Common.Lyrics;
public interface ILyricsDownloader
{
}

View File

@ -3,7 +3,7 @@ namespace ZonyLrcTools.Common.Lyrics
/// <summary>
/// 构建 <see cref="LyricItemCollection"/> 对象的工厂。
/// </summary>
public interface ILyricItemCollectionFactory
public interface ILyricsItemCollectionFactory
{
/// <summary>
/// 根据指定的歌曲数据构建新的 <see cref="LyricItemCollection"/> 实例。

View File

@ -3,7 +3,7 @@ namespace ZonyLrcTools.Common.Lyrics
/// <summary>
/// 歌词数据下载器,用于匹配并下载歌曲的歌词。
/// </summary>
public interface ILyricDownloader
public interface ILyricsProvider
{
/// <summary>
/// 下载歌词数据。

View File

@ -1,6 +1,6 @@
namespace ZonyLrcTools.Common.Lyrics
{
public interface ILyricTextResolver
public interface ILyricsTextResolver
{
LyricItemCollection Resolve(string lyricText);
}

View File

@ -3,7 +3,7 @@ namespace ZonyLrcTools.Common.Lyrics
/// <summary>
/// 定义了程序默认提供的歌词下载器。
/// </summary>
public static class InternalLyricDownloaderNames
public static class InternalLyricsProviderNames
{
/// <summary>
/// 网易云音乐歌词下载器。

View File

@ -5,9 +5,9 @@ using ZonyLrcTools.Common.Infrastructure.Extensions;
namespace ZonyLrcTools.Common.Lyrics
{
/// <summary>
/// 歌词数据,包含多条歌词行对象(<see cref="LyricItem"/>)。
/// 歌词数据,包含多条歌词行对象(<see cref="LyricsItem"/>)。
/// </summary>
public class LyricItemCollection : List<LyricItem>
public class LyricItemCollection : List<LyricsItem>
{
/// <summary>
/// 是否为纯音乐,当没有任何歌词数据的时候,属性值为 True。

View File

@ -5,7 +5,7 @@ namespace ZonyLrcTools.Common.Lyrics
/// <summary>
/// 歌词的行对象,是 <see cref="LyricItemCollection"/> 的最小单位。。
/// </summary>
public class LyricItem : IComparable<LyricItem>
public class LyricsItem : IComparable<LyricsItem>
{
/// <summary>
/// 原始时间轴,格式类似于 [01:55.12]。
@ -33,10 +33,10 @@ namespace ZonyLrcTools.Common.Lyrics
public double SortScore => Minute * 60 + Second;
/// <summary>
/// 构建新的 <see cref="LyricItem"/> 对象。
/// 构建新的 <see cref="LyricsItem"/> 对象。
/// </summary>
/// <param name="lyricText">原始的 Lyric 歌词。</param>
public LyricItem(string lyricText)
public LyricsItem(string lyricText)
{
var timeline = new Regex(@"\[\d+:\d+.\d+\]").Match(lyricText)
.Value.Replace("]", string.Empty)
@ -50,19 +50,19 @@ namespace ZonyLrcTools.Common.Lyrics
}
/// <summary>
/// 构造新的 <see cref="LyricItem"/> 对象。
/// 构造新的 <see cref="LyricsItem"/> 对象。
/// </summary>
/// <param name="minute">歌词所在的时间(分)。</param>
/// <param name="second">歌词所在的时间(秒)。</param>
/// <param name="lyricText">歌词文本数据。</param>
public LyricItem(int minute, double second, string lyricText)
public LyricsItem(int minute, double second, string lyricText)
{
Minute = minute;
Second = second;
LyricText = lyricText;
}
public int CompareTo(LyricItem other)
public int CompareTo(LyricsItem other)
{
if (SortScore > other.SortScore)
{
@ -77,32 +77,32 @@ namespace ZonyLrcTools.Common.Lyrics
return 0;
}
public static bool operator >(LyricItem left, LyricItem right)
public static bool operator >(LyricsItem left, LyricsItem right)
{
return left.SortScore > right.SortScore;
}
public static bool operator <(LyricItem left, LyricItem right)
public static bool operator <(LyricsItem left, LyricsItem right)
{
return left.SortScore < right.SortScore;
}
public static bool operator ==(LyricItem left, LyricItem right)
public static bool operator ==(LyricsItem left, LyricsItem right)
{
return (int?)left?.SortScore == (int?)right?.SortScore;
}
public static bool operator !=(LyricItem item1, LyricItem item2)
public static bool operator !=(LyricsItem item1, LyricsItem item2)
{
return !(item1 == item2);
}
public static LyricItem operator +(LyricItem src, LyricItem dist)
public static LyricsItem operator +(LyricsItem src, LyricsItem dist)
{
return new LyricItem(src.Minute, src.Second, $"{src.LyricText} {dist.LyricText}");
return new LyricsItem(src.Minute, src.Second, $"{src.LyricText} {dist.LyricText}");
}
protected bool Equals(LyricItem other)
protected bool Equals(LyricsItem other)
{
return LyricText == other.LyricText && Minute == other.Minute && Second.Equals(other.Second);
}
@ -112,7 +112,7 @@ namespace ZonyLrcTools.Common.Lyrics
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((LyricItem)obj);
return Equals((LyricsItem)obj);
}
public override int GetHashCode()

View File

@ -6,13 +6,13 @@ using ZonyLrcTools.Common.Infrastructure.DependencyInject;
namespace ZonyLrcTools.Common.Lyrics
{
/// <summary>
/// <see cref="ILyricItemCollectionFactory"/> 的默认实现。
/// <see cref="ILyricsItemCollectionFactory"/> 的默认实现。
/// </summary>
public class LyricItemCollectionFactory : ILyricItemCollectionFactory, ITransientDependency
public class LyricsItemCollectionFactory : ILyricsItemCollectionFactory, ITransientDependency
{
private readonly GlobalOptions _options;
public LyricItemCollectionFactory(IOptions<GlobalOptions> options)
public LyricsItemCollectionFactory(IOptions<GlobalOptions> options)
{
_options = options.Value;
}
@ -59,7 +59,7 @@ namespace ZonyLrcTools.Common.Lyrics
var regex = new Regex(@"\[\d+:\d+.\d+\].+\n?");
foreach (Match match in regex.Matches(sourceText))
{
lyric.Add(new LyricItem(match.Value));
lyric.Add(new LyricsItem(match.Value));
}
return lyric;

View File

@ -6,7 +6,7 @@ namespace ZonyLrcTools.Common.Lyrics
/// <summary>
/// 歌词下载器的基类,定义了歌词下载器的常规逻辑。
/// </summary>
public abstract class LyricDownloader : ILyricDownloader, ITransientDependency
public abstract class LyricsProvider : ILyricsProvider, ITransientDependency
{
public abstract string DownloaderName { get; }
@ -19,7 +19,7 @@ namespace ZonyLrcTools.Common.Lyrics
/// <returns>下载完成的歌曲数据。</returns>
public virtual async ValueTask<LyricItemCollection> DownloadAsync(string songName, string artist, long? duration = null)
{
var args = new LyricDownloaderArgs(songName, artist, duration ?? 0);
var args = new LyricsProviderArgs(songName, artist, duration ?? 0);
await ValidateAsync(args);
var downloadDataBytes = await DownloadDataAsync(args);
return await GenerateLyricAsync(downloadDataBytes, args);
@ -29,7 +29,7 @@ namespace ZonyLrcTools.Common.Lyrics
/// 通用的验证逻辑,验证基本参数是否正确。
/// </summary>
/// <param name="args">歌词下载时需要的参数信息。</param>
protected virtual ValueTask ValidateAsync(LyricDownloaderArgs args)
protected virtual ValueTask ValidateAsync(LyricsProviderArgs args)
{
if (string.IsNullOrEmpty(args.SongName))
{
@ -47,12 +47,12 @@ namespace ZonyLrcTools.Common.Lyrics
/// <summary>
/// 根据指定的歌曲参数,下载歌词数据。
/// </summary>
protected abstract ValueTask<byte[]> DownloadDataAsync(LyricDownloaderArgs args);
protected abstract ValueTask<byte[]> DownloadDataAsync(LyricsProviderArgs args);
/// <summary>
/// 根据指定的歌词二进制数据,生成歌词数据。
/// </summary>
/// <param name="data">歌词的原始二进制数据。</param>
protected abstract ValueTask<LyricItemCollection> GenerateLyricAsync(byte[] data, LyricDownloaderArgs args);
protected abstract ValueTask<LyricItemCollection> GenerateLyricAsync(byte[] data, LyricsProviderArgs args);
}
}

View File

@ -1,6 +1,6 @@
namespace ZonyLrcTools.Common.Lyrics
{
public class LyricDownloaderArgs
public class LyricsProviderArgs
{
public string SongName { get; set; }
@ -8,7 +8,7 @@ namespace ZonyLrcTools.Common.Lyrics
public long Duration { get; set; }
public LyricDownloaderArgs(string songName, string artist, long duration)
public LyricsProviderArgs(string songName, string artist, long duration)
{
SongName = songName;
Artist = artist;

View File

@ -8,28 +8,28 @@ using ZonyLrcTools.Common.Lyrics.Providers.KuGou.JsonModel;
namespace ZonyLrcTools.Common.Lyrics.Providers.KuGou
{
public class KuGourLyricDownloader : LyricDownloader
public class KuGourLyricsProvider : LyricsProvider
{
public override string DownloaderName => InternalLyricDownloaderNames.KuGou;
public override string DownloaderName => InternalLyricsProviderNames.KuGou;
private readonly IWarpHttpClient _warpHttpClient;
private readonly ILyricItemCollectionFactory _lyricItemCollectionFactory;
private readonly ILyricsItemCollectionFactory _lyricsItemCollectionFactory;
private readonly GlobalOptions _options;
private const string KuGouSearchMusicUrl = @"https://songsearch.kugou.com/song_search_v2";
private const string KuGouGetLyricAccessKeyUrl = @"http://lyrics.kugou.com/search";
private const string KuGouGetLyricUrl = @"http://lyrics.kugou.com/download";
public KuGourLyricDownloader(IWarpHttpClient warpHttpClient,
ILyricItemCollectionFactory lyricItemCollectionFactory,
public KuGourLyricsProvider(IWarpHttpClient warpHttpClient,
ILyricsItemCollectionFactory lyricsItemCollectionFactory,
IOptions<GlobalOptions> options)
{
_warpHttpClient = warpHttpClient;
_lyricItemCollectionFactory = lyricItemCollectionFactory;
_lyricsItemCollectionFactory = lyricsItemCollectionFactory;
_options = options.Value;
}
protected override async ValueTask<byte[]> DownloadDataAsync(LyricDownloaderArgs args)
protected override async ValueTask<byte[]> DownloadDataAsync(LyricsProviderArgs args)
{
var searchResult = await _warpHttpClient.GetAsync<SongSearchResponse>(KuGouSearchMusicUrl,
new SongSearchRequest(args.SongName, args.Artist, _options.Provider.Lyric.GetLyricProviderOption(DownloaderName).Depth));
@ -47,7 +47,7 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.KuGou
return Encoding.UTF8.GetBytes(lyricResponse);
}
protected override async ValueTask<LyricItemCollection> GenerateLyricAsync(byte[] data, LyricDownloaderArgs args)
protected override async ValueTask<LyricItemCollection> GenerateLyricAsync(byte[] data, LyricsProviderArgs args)
{
await ValueTask.CompletedTask;
var lyricJsonObj = JObject.Parse(Encoding.UTF8.GetString(data));
@ -57,10 +57,10 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.KuGou
}
var lyricText = Encoding.UTF8.GetString(Convert.FromBase64String(lyricJsonObj.SelectToken("$.content").Value<string>()));
return _lyricItemCollectionFactory.Build(lyricText);
return _lyricsItemCollectionFactory.Build(lyricText);
}
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricDownloaderArgs args)
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricsProviderArgs args)
{
if (response.ErrorCode != 0 && response.Status != 1 || response.Data.List == null)
{

View File

@ -9,12 +9,12 @@ using ZonyLrcTools.Common.Lyrics.Providers.NetEase.JsonModel;
namespace ZonyLrcTools.Common.Lyrics.Providers.NetEase
{
public class NetEaseLyricDownloader : LyricDownloader
public class NetEaseLyricsProvider : LyricsProvider
{
public override string DownloaderName => InternalLyricDownloaderNames.NetEase;
public override string DownloaderName => InternalLyricsProviderNames.NetEase;
private readonly IWarpHttpClient _warpHttpClient;
private readonly ILyricItemCollectionFactory _lyricItemCollectionFactory;
private readonly ILyricsItemCollectionFactory _lyricsItemCollectionFactory;
private readonly GlobalOptions _options;
private const string NetEaseSearchMusicUrl = @"https://music.163.com/api/search/get/web";
@ -23,16 +23,16 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.NetEase
private const string NetEaseRequestReferer = @"https://music.163.com";
private const string NetEaseRequestContentType = @"application/x-www-form-urlencoded";
public NetEaseLyricDownloader(IWarpHttpClient warpHttpClient,
ILyricItemCollectionFactory lyricItemCollectionFactory,
public NetEaseLyricsProvider(IWarpHttpClient warpHttpClient,
ILyricsItemCollectionFactory lyricsItemCollectionFactory,
IOptions<GlobalOptions> options)
{
_warpHttpClient = warpHttpClient;
_lyricItemCollectionFactory = lyricItemCollectionFactory;
_lyricsItemCollectionFactory = lyricsItemCollectionFactory;
_options = options.Value;
}
protected override async ValueTask<byte[]> DownloadDataAsync(LyricDownloaderArgs args)
protected override async ValueTask<byte[]> DownloadDataAsync(LyricsProviderArgs args)
{
var searchResult = await _warpHttpClient.PostAsync<SongSearchResponse>(
NetEaseSearchMusicUrl,
@ -57,7 +57,7 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.NetEase
return Encoding.UTF8.GetBytes(lyricResponse);
}
protected override async ValueTask<LyricItemCollection> GenerateLyricAsync(byte[] data, LyricDownloaderArgs args)
protected override async ValueTask<LyricItemCollection> GenerateLyricAsync(byte[] data, LyricsProviderArgs args)
{
await ValueTask.CompletedTask;
@ -72,12 +72,12 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.NetEase
return new LyricItemCollection(null);
}
return _lyricItemCollectionFactory.Build(
return _lyricsItemCollectionFactory.Build(
json.OriginalLyric?.Text,
json.TranslationLyric?.Text);
}
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricDownloaderArgs args)
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricsProviderArgs args)
{
if (response?.StatusCode != SongSearchResponseStatusCode.Success)
{

View File

@ -7,12 +7,12 @@ using ZonyLrcTools.Common.Lyrics.Providers.QQMusic.JsonModel;
namespace ZonyLrcTools.Common.Lyrics.Providers.QQMusic
{
public class QQLyricDownloader : LyricDownloader
public class QQLyricsProvider : LyricsProvider
{
public override string DownloaderName => InternalLyricDownloaderNames.QQ;
public override string DownloaderName => InternalLyricsProviderNames.QQ;
private readonly IWarpHttpClient _warpHttpClient;
private readonly ILyricItemCollectionFactory _lyricItemCollectionFactory;
private readonly ILyricsItemCollectionFactory _lyricsItemCollectionFactory;
// private const string QQSearchMusicUrl = @"https://c.y.qq.com/soso/fcgi-bin/client_search_cp";
private const string QQSearchMusicUrl = @"https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg";
@ -20,14 +20,14 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.QQMusic
private const string QQMusicRequestReferer = @"https://y.qq.com/";
public QQLyricDownloader(IWarpHttpClient warpHttpClient,
ILyricItemCollectionFactory lyricItemCollectionFactory)
public QQLyricsProvider(IWarpHttpClient warpHttpClient,
ILyricsItemCollectionFactory lyricsItemCollectionFactory)
{
_warpHttpClient = warpHttpClient;
_lyricItemCollectionFactory = lyricItemCollectionFactory;
_lyricsItemCollectionFactory = lyricsItemCollectionFactory;
}
protected override async ValueTask<byte[]> DownloadDataAsync(LyricDownloaderArgs args)
protected override async ValueTask<byte[]> DownloadDataAsync(LyricsProviderArgs args)
{
var searchResult = await _warpHttpClient.GetAsync<SongSearchResponse>(
QQSearchMusicUrl,
@ -42,7 +42,7 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.QQMusic
return Encoding.UTF8.GetBytes(lyricJsonString);
}
protected override async ValueTask<LyricItemCollection> GenerateLyricAsync(byte[] data, LyricDownloaderArgs args)
protected override async ValueTask<LyricItemCollection> GenerateLyricAsync(byte[] data, LyricsProviderArgs args)
{
await ValueTask.CompletedTask;
@ -56,17 +56,17 @@ namespace ZonyLrcTools.Common.Lyrics.Providers.QQMusic
if (lyricJsonString.Contains("此歌曲为没有填词的纯音乐,请您欣赏"))
{
return _lyricItemCollectionFactory.Build(null);
return _lyricsItemCollectionFactory.Build(null);
}
var lyricJsonObj = JObject.Parse(lyricJsonString);
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 _lyricsItemCollectionFactory.Build(sourceLyric, translateLyric);
}
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricDownloaderArgs args)
protected virtual void ValidateSongSearchResponse(SongSearchResponse response, LyricsProviderArgs args)
{
if (response is not { StatusCode: 0 } || response.Data.Song.SongItems == null)
{

View File

@ -9,18 +9,18 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
{
public class KuGouLyricDownloaderTests : TestBase
{
private readonly ILyricDownloader _lyricDownloader;
private readonly ILyricsProvider _lyricsProvider;
public KuGouLyricDownloaderTests()
{
_lyricDownloader = GetService<IEnumerable<ILyricDownloader>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.KuGou);
_lyricsProvider = GetService<IEnumerable<ILyricsProvider>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricsProviderNames.KuGou);
}
[Fact]
public async Task DownloadAsync_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("东方红", null);
var lyric = await _lyricsProvider.DownloadAsync("东方红", null);
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
}

View File

@ -12,18 +12,18 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
{
public class NetEaseLyricDownloaderTests : TestBase
{
private readonly ILyricDownloader _lyricDownloader;
private readonly ILyricsProvider _lyricsProvider;
public NetEaseLyricDownloaderTests()
{
_lyricDownloader = GetService<IEnumerable<ILyricDownloader>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.NetEase);
_lyricsProvider = GetService<IEnumerable<ILyricsProvider>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricsProviderNames.NetEase);
}
[Fact]
public async Task DownloadAsync_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("Hollow", "Janet Leon");
var lyric = await _lyricsProvider.DownloadAsync("Hollow", "Janet Leon");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
}
@ -31,7 +31,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
[Fact]
public async Task DownloadAsync_Issue_75_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("Daybreak", "samfree,初音ミク");
var lyric = await _lyricsProvider.DownloadAsync("Daybreak", "samfree,初音ミク");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
lyric.ToString().Contains("惑う心繋ぎ止める").ShouldBeTrue();
@ -40,7 +40,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
[Fact]
public async Task DownloadAsync_Issue_82_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("シンデレラ (Giga First Night Remix)", "DECO 27 ギガP");
var lyric = await _lyricsProvider.DownloadAsync("シンデレラ (Giga First Night Remix)", "DECO 27 ギガP");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
}
@ -48,7 +48,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
[Fact]
public async Task DownloadAsync_Issue84_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("太空彈", "01");
var lyric = await _lyricsProvider.DownloadAsync("太空彈", "01");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
}
@ -58,7 +58,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
[Fact]
public async Task DownloadAsync_Issue85_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("Looking at Me", "Sabrina Carpenter");
var lyric = await _lyricsProvider.DownloadAsync("Looking at Me", "Sabrina Carpenter");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBeFalse();
@ -68,7 +68,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
[Fact]
public async Task DownloaderAsync_Issue88_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("茫茫草原", "姚璎格");
var lyric = await _lyricsProvider.DownloadAsync("茫茫草原", "姚璎格");
lyric.ShouldNotBeNull();
}
@ -76,7 +76,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
[Fact]
public async Task UnknownIssue_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("主題歌Arrietty's Song", "Cécile Corbel");
var lyric = await _lyricsProvider.DownloadAsync("主題歌Arrietty's Song", "Cécile Corbel");
lyric.ShouldNotBeNull();
}
@ -84,7 +84,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
[Fact]
public async Task DownloaderAsync_Issue101_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("君への嘘", "VALSHE");
var lyric = await _lyricsProvider.DownloadAsync("君への嘘", "VALSHE");
lyric.ShouldNotBeEmpty();
}
@ -94,7 +94,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
var options = ServiceProvider.GetRequiredService<IOptions<GlobalOptions>>();
options.Value.Provider.Lyric.Config.IsOnlyOutputTranslation = true;
var lyric = await _lyricDownloader.DownloadAsync("Bones", "Image Dragons");
var lyric = await _lyricsProvider.DownloadAsync("Bones", "Image Dragons");
lyric.ToString().ShouldNotContain("Gimme, gimme, gimme some time to think");
}
}

View File

@ -9,18 +9,18 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
{
public class QQLyricDownloaderTests : TestBase
{
private readonly ILyricDownloader _lyricDownloader;
private readonly ILyricsProvider _lyricsProvider;
public QQLyricDownloaderTests()
{
_lyricDownloader = GetService<IEnumerable<ILyricDownloader>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.QQ);
_lyricsProvider = GetService<IEnumerable<ILyricsProvider>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricsProviderNames.QQ);
}
[Fact]
public async Task DownloadAsync_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("东风破", "周杰伦");
var lyric = await _lyricsProvider.DownloadAsync("东风破", "周杰伦");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
}
@ -30,7 +30,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
[Fact]
public async Task DownloadAsync_Issue85_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("Looking at Me", "Sabrina Carpenter");
var lyric = await _lyricsProvider.DownloadAsync("Looking at Me", "Sabrina Carpenter");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBeFalse();