fix: Fixed the issue with #82.

Reason may be that the song name has brackets, causing the search to
failure.
This commit is contained in:
real-zony 2022-09-22 15:06:54 +08:00
parent 83fcc91fb8
commit 87f6a98668
2 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using Newtonsoft.Json;
@ -53,6 +54,10 @@ namespace ZonyLrcTools.Cli.Infrastructure.Lyric.NetEase.JsonModel
public SongSearchRequest(string musicName, string artistName) : this()
{
// Remove all the brackets and the content inside them.
var regex = new Regex(@"\([^)]*\)");
musicName = regex.Replace(musicName, string.Empty);
SearchKey = HttpUtility.UrlEncode($"{musicName}+{artistName}", Encoding.UTF8);
}
}

View File

@ -39,7 +39,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyric
{
var lyric = await _lyricDownloader.DownloadAsync("シンデレラ (Giga First Night Remix)", "DECO 27 ギガP");
lyric.ShouldNotBeNull();
lyric.IsPruneMusic.ShouldBe(true);
lyric.IsPruneMusic.ShouldBe(false);
}
[Fact]