1
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /wd/media/tv:/data/media/tv:rw
|
||||
- /wd/media/anime:/data/media/anime:rw
|
||||
- /wd/media/music:/data/media/music:rw
|
||||
- /wd/media/others/anime:/data/media/anime-other:rw
|
||||
- /wd/apps/vols/nas_robot:/app/data:rw
|
||||
- /wd:/host/wd:ro
|
||||
|
||||
@@ -88,4 +88,39 @@ public class JobTriggerController : BaseController
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string MusicTagAsync()
|
||||
{
|
||||
var musicPath = "/data/media/music";
|
||||
List<string> musicType = ["mp3", "flac", "m4a", "wav", "ape", "ogg", "wma", "alac", "aac", "dsd"];
|
||||
|
||||
// 递归获取所有音乐文件
|
||||
var files = Directory.GetFiles(musicPath, "*.*", SearchOption.AllDirectories)
|
||||
.Where(f => musicType.Contains(Path.GetExtension(f).TrimStart('.').ToLower()))
|
||||
.ToList();
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
_logger.LogInformation("Processing music file: {file}", file);
|
||||
|
||||
try
|
||||
{
|
||||
var fileTag = TagLib.File.Create(file);
|
||||
var artist = fileTag.Tag.FirstPerformer ?? "未知艺术家";
|
||||
var album = fileTag.Tag.Album ?? "未知专辑";
|
||||
var title = fileTag.Tag.Title ?? Path.GetFileNameWithoutExtension(file);
|
||||
var year = fileTag.Tag.Year > 0 ? fileTag.Tag.Year.ToString() : "未知年份";
|
||||
var genre = fileTag.Tag.FirstGenre ?? "未知风格";
|
||||
_logger.LogInformation("Tag info - Artist: {artist}, Album: {album}, Title: {title}, Year: {year}, Genre: {genre}", artist, album, title, year, genre);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,6 @@ namespace WebApi.Controllers;
|
||||
|
||||
public class NotifyController : BaseController
|
||||
{
|
||||
public NotifyController()
|
||||
{
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Radarr()
|
||||
{
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0"/>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="taglib-sharp-netstandard2.0" Version="2.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user