mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-01 20:30:41 +00:00
Compare commits
2 Commits
ZonyLrcToo
...
dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e08d1c7f16 | ||
![]() |
c3d98d60b5 |
@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>4.0.1</Version>
|
||||
<Version>4.0.2</Version>
|
||||
<Authors>Zony(real-zony)</Authors>
|
||||
<RepositoryUrl>https://github.com/real-zony/ZonyLrcToolsX</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
@ -39,12 +39,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageVersion>
|
||||
<!-- Avalonia -->
|
||||
<PackageVersion Include="Avalonia" Version="11.0.11" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.0.11" />
|
||||
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.0.11" />
|
||||
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.0.11" />
|
||||
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.0.11" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.0.11" />
|
||||
<PackageVersion Include="Ude.NetStandard" Version="1.2.0" />
|
||||
<PackageVersion Include="YamlDotNet" Version="16.2.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -14,6 +14,7 @@
|
||||
<PackageReference Include="Serilog.Sinks.Console"/>
|
||||
<PackageReference Include="Serilog.Sinks.File"/>
|
||||
<PackageReference Include="System.Text.Encoding.CodePages"/>
|
||||
<PackageReference Include="Ude.NetStandard"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,3 +1,5 @@
|
||||
using System.Text;
|
||||
using Ude;
|
||||
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
|
||||
|
||||
namespace ZonyLrcTools.Common.MusicScanner;
|
||||
@ -13,11 +15,15 @@ public class CsvFileMusicScanner : ITransientDependency
|
||||
/// <param name="csvFilePath">CSV 文件的路径。</param>
|
||||
/// <param name="outputDirectory">歌词文件的输出目录。</param>
|
||||
/// <param name="pattern">输出的歌词文件格式,默认是 "{Artist} - {Title}.lrc" 的形式。</param>
|
||||
public async Task<List<MusicInfo>> GetMusicInfoFromCsvFileAsync(string csvFilePath, string outputDirectory, string pattern)
|
||||
public async Task<List<MusicInfo>> GetMusicInfoFromCsvFileAsync(string csvFilePath, string outputDirectory,
|
||||
string pattern)
|
||||
{
|
||||
var csvFileContent = await File.ReadAllTextAsync(csvFilePath);
|
||||
var csvFileLines = csvFileContent.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return csvFileLines.Skip(1).Select(line => GetMusicInfoFromCsvFileLine(line, outputDirectory, pattern)).ToList();
|
||||
var encoding = DetectFileEncoding(csvFilePath);
|
||||
|
||||
var csvFileContent = await File.ReadAllTextAsync(csvFilePath, encoding);
|
||||
var csvFileLines = csvFileContent.Split([Environment.NewLine], StringSplitOptions.RemoveEmptyEntries);
|
||||
return csvFileLines.Skip(1).Select(line => GetMusicInfoFromCsvFileLine(line, outputDirectory, pattern))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private MusicInfo GetMusicInfoFromCsvFileLine(string csvFileLine, string outputDirectory, string pattern)
|
||||
@ -29,4 +35,19 @@ public class CsvFileMusicScanner : ITransientDependency
|
||||
var musicInfo = new MusicInfo(fakeFilePath, name, artist);
|
||||
return musicInfo;
|
||||
}
|
||||
|
||||
private Encoding DetectFileEncoding(string filePath)
|
||||
{
|
||||
using var fileStream = File.OpenRead(filePath);
|
||||
var detector = new CharsetDetector();
|
||||
detector.Feed(fileStream);
|
||||
detector.DataEnd();
|
||||
|
||||
if (detector.Charset != null)
|
||||
{
|
||||
return Encoding.GetEncoding(detector.Charset);
|
||||
}
|
||||
|
||||
return Encoding.Default;
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@
|
||||
<PackageReference Include="Polly"/>
|
||||
<PackageReference Include="QRCoder"/>
|
||||
<PackageReference Include="TagLibSharp"/>
|
||||
<PackageReference Include="Ude.NetStandard" />
|
||||
<PackageReference Include="YamlDotNet" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -116,7 +116,8 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyrics
|
||||
[Fact]
|
||||
public async Task DownloadAsync_Source_Null_Test()
|
||||
{
|
||||
var lyric = await _lyricsProvider.DownloadAsync("Concerto for Piano and Orchestra No. 12 in A major, K414 - 1. Allegro",
|
||||
var lyric = await _lyricsProvider.DownloadAsync(
|
||||
"Concerto for Piano and Orchestra No. 12 in A major, K414 - 1. Allegro",
|
||||
"Wolfgang Amadeus Mozart");
|
||||
|
||||
lyric.IsPruneMusic.ShouldBeTrue();
|
||||
@ -143,5 +144,12 @@ namespace ZonyLrcTools.Tests.Infrastructure.Lyrics
|
||||
var lyric = await _lyricsProvider.DownloadAsync("Your Heart Is A Muscle (2012)", "Carly Rae Jepsen");
|
||||
lyric.IsPruneMusic.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DownloadAsync_Issue_156_Test()
|
||||
{
|
||||
var lyric = await _lyricsProvider.DownloadAsync("你说(demo)", "枯木逢春");
|
||||
lyric.IsPruneMusic.ShouldBeFalse();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,4 +4,4 @@ Enhancement: None
|
||||
|
||||
Fixed Bugs:
|
||||
|
||||
- 修复了 #159/#155 的问题。
|
||||
- 修复了 #156 的问题。
|
Loading…
x
Reference in New Issue
Block a user