更新 ChineseNfoRegistry 类,优化季节 NFO 文件处理逻辑,移除不必要的文件创建步骤,增强季号验证和处理的准确性。
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Successful in 12s
Docker Build & Deploy / Deploy to Production (push) Failing after 4s

This commit is contained in:
孙诚
2025-04-22 17:33:44 +08:00
parent cb41791656
commit 90ccaba1a3

View File

@@ -122,47 +122,20 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
continue; continue;
} }
var seasonNfos = Directory.GetFiles(Path.GetDirectoryName(tv) ?? string.Empty, "season.nfo", SearchOption.AllDirectories); var sseasons = Directory.GetDirectories(Path.GetDirectoryName(tv) ?? string.Empty, "Season *", SearchOption.AllDirectories);
var sseasonsNumbers = sseasons.Select(x => x.Split("Season ", StringSplitOptions.None)[1]).Select(int.Parse).ToList();
// 如果seasonNfos为空则创建 foreach (var seasonNumber in sseasonsNumbers)
if (seasonNfos.Length == 0)
{ {
var sseasons = Directory.GetDirectories(Path.GetDirectoryName(tv) ?? string.Empty, "Season *", SearchOption.AllDirectories); ctn.seasonNfoPath = Path.Combine(Path.GetDirectoryName(tv) ?? string.Empty, $"Season {seasonNumber}", "season.nfo");
var sseasonsNumbers = sseasons.Select(x => x.Split("Season ", StringSplitOptions.None)[1]).Select(int.Parse).ToList(); if (File.Exists(ctn.seasonNfoPath) && await HandleSeason() == false)
foreach (var seasonNumber in sseasonsNumbers)
{
var seasonNfo = Path.Combine(Path.GetDirectoryName(tv) ?? string.Empty, $"Season {seasonNumber}", "season.nfo");
await File.WriteAllTextAsync(seasonNfo, string.Format(
"""
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<season>
<plot></plot>
<outline></outline>
<lockdata></lockdata>
<seasonnumber>{0}</seasonnumber>
</season>
"""
, seasonNumber)
);
seasonNfos = seasonNfos.Append(seasonNfo).ToArray();
}
}
foreach (var season in seasonNfos)
{
ctn.seasonNfoPath = season;
if (await HandleSeason() == false)
{ {
continue; continue;
} }
var episodeNfos = Directory var episodeNfos = Directory
.GetFiles(Path.GetDirectoryName(season) ?? string.Empty, "*.nfo", SearchOption.AllDirectories) .GetFiles(Path.GetDirectoryName(ctn.seasonNfoPath) ?? string.Empty, "*.nfo", SearchOption.AllDirectories)
.Where(x => !x.EndsWith("season.nfo")) .Where(x => !x.EndsWith("season.nfo"))
.ToList(); .ToList();