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