fix: 优化网易云歌词匹配机制,增强准确度。

Closes #75
This commit is contained in:
real-zony
2021-06-05 11:52:34 +08:00
parent 2ea5754e3e
commit 5520162a4c
6 changed files with 42 additions and 20 deletions

View File

@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit;
using ZonyLrcTools.Cli.Infrastructure.Lyric;
@@ -10,14 +9,18 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
{
public class KuGouLyricDownloaderTests : TestBase
{
private readonly ILyricDownloader _lyricDownloader;
public KuGouLyricDownloaderTests()
{
_lyricDownloader = GetService<IEnumerable<ILyricDownloader>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.KuGou);
}
[Fact]
public async Task DownloadAsync_Test()
{
var downloaderList = ServiceProvider.GetRequiredService<IEnumerable<ILyricDownloader>>();
var kuGouDownloader = downloaderList.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.KuGou);
kuGouDownloader.ShouldNotBeNull();
var lyric = await kuGouDownloader.DownloadAsync("东方红", null);
var lyric = await _lyricDownloader.DownloadAsync("东方红", null);
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
}

View File

@@ -10,16 +10,29 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
{
public class NetEaseLyricDownloaderTests : TestBase
{
private readonly ILyricDownloader _lyricDownloader;
public NetEaseLyricDownloaderTests()
{
_lyricDownloader = GetService<IEnumerable<ILyricDownloader>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.NetEase);
}
[Fact]
public async Task DownloadAsync_Test()
{
var downloaderList = ServiceProvider.GetRequiredService<IEnumerable<ILyricDownloader>>();
var netEaseDownloader = downloaderList.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.NetEase);
netEaseDownloader.ShouldNotBeNull();
var lyric = await netEaseDownloader.DownloadAsync("Hollow", "Janet Leon");
var lyric = await _lyricDownloader.DownloadAsync("Hollow", "Janet Leon");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
}
[Fact]
public async Task DownloadAsync_Issue_75_Test()
{
var lyric = await _lyricDownloader.DownloadAsync("Daybreak", "samfree,初音ミク");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
lyric.ToString().Contains("惑う心繋ぎ止める").ShouldBeTrue();
}
}
}

View File

@@ -10,14 +10,18 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
{
public class QQLyricDownloaderTests : TestBase
{
private readonly ILyricDownloader _lyricDownloader;
public QQLyricDownloaderTests()
{
_lyricDownloader = GetService<IEnumerable<ILyricDownloader>>()
.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.QQ);
}
[Fact]
public async Task DownloadAsync_Test()
{
var downloaderList = ServiceProvider.GetRequiredService<IEnumerable<ILyricDownloader>>();
var qqDownloader = downloaderList.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.QQ);
qqDownloader.ShouldNotBeNull();
var lyric = await qqDownloader.DownloadAsync("Hollow", "Janet Leon");
var lyric = await _lyricDownloader.DownloadAsync("Hollow", "Janet Leon");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(false);
}