更新 ChineseNfoRegistry 类,优化季节 NFO 文件处理逻辑,移除不必要的文件创建步骤,增强季号验证和处理的准确性。
This commit is contained in:
@@ -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();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user