mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-08-31 17:56:53 +00:00
feat: Use MusicDecrypto as a decryption driver.
This commit is contained in:
@@ -98,5 +98,12 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyrics
|
||||
var lyric = await _lyricsProvider.DownloadAsync("Bones", "Image Dragons");
|
||||
lyric.ToString().ShouldNotContain("Gimme, gimme, gimme some time to think");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DownloadAsync_Issue123_Test()
|
||||
{
|
||||
var lyric = await _lyricsProvider.DownloadAsync("橄榄树", "苏曼");
|
||||
lyric.ToString().ShouldNotBeNullOrEmpty();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Common.MusicDecryption;
|
||||
|
||||
@@ -10,26 +10,13 @@ namespace ZonyLrcTools.Tests.Infrastructure.MusicDecryption
|
||||
public class NcmMusicDecryptorTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task ConvertMusic_Test()
|
||||
public async Task ConvertMusicAsync_Test()
|
||||
{
|
||||
var decryptor = ServiceProvider.GetRequiredService<IMusicDecryptor>();
|
||||
var ncmFilePath = Path.Combine(Directory.GetCurrentDirectory(), "MusicFiles", "Loren Gray - Queen.ncm");
|
||||
|
||||
await using var fs = File.Open(Path.Combine(Directory.GetCurrentDirectory(), "MusicFiles", "Loren Gray - Queen.ncm"), FileMode.Open);
|
||||
using var reader = new BinaryReader(fs);
|
||||
var response = await decryptor.ConvertMusic(reader.ReadBytes((int) fs.Length));
|
||||
|
||||
var musicFilePath = Path.Combine(Directory.GetCurrentDirectory(),
|
||||
"MusicFiles",
|
||||
$"Loren Gray - Queen.{((JObject) response.ExtensionObjects["JSON"]).SelectToken("$.format").Value<string>()}");
|
||||
|
||||
if (File.Exists(musicFilePath))
|
||||
{
|
||||
File.Delete(musicFilePath);
|
||||
}
|
||||
|
||||
await using var musicFileStream = File.Create(musicFilePath);
|
||||
await musicFileStream.WriteAsync(response.Data);
|
||||
await musicFileStream.FlushAsync();
|
||||
var result = await decryptor.ConvertMusicAsync(ncmFilePath);
|
||||
result.IsSuccess.ShouldBeTrue();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user