diff --git a/Learn.sln.DotSettings.user b/Learn.sln.DotSettings.user
index f19465e..42cc868 100644
--- a/Learn.sln.DotSettings.user
+++ b/Learn.sln.DotSettings.user
@@ -2,5 +2,6 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
\ No newline at end of file
diff --git a/Parsers/ItemFields.cs b/Parsers/ItemFields.cs
index 73bef91..fe433a5 100644
--- a/Parsers/ItemFields.cs
+++ b/Parsers/ItemFields.cs
@@ -45,7 +45,6 @@ public static class ItemFields
public static string Key_Episode => "Episode";
public static string Key_Year => "Year";
- public static string Key_EpisodeNum => "EpisodeNum";
public static string Key_TMDBID => "TMDBID";
public static ItemType Type(this Item item)
diff --git a/Parsers/RawParser.cs b/Parsers/RawParser.cs
index c7b2419..5e219cb 100644
--- a/Parsers/RawParser.cs
+++ b/Parsers/RawParser.cs
@@ -19,9 +19,18 @@ public class RawParser(Configs configs) : ItemParser
var result = parts.ToList();
foreach (var regex in config.TokenFilterRules.Regexes)
{
- result.RemoveAll(part => string.IsNullOrEmpty(part.Trim()) || Regex.Match(part.Trim(), regex).Success);
+ result = result.Select(part =>
+ {
+ var match = Regex.Match(part.Trim(), regex);
+ if (match.Success)
+ {
+ return part.Replace(match.Value, "").Trim();
+ }
+
+ return part.Trim();
+ }).ToList();
}
- return result;
+ return result.Where(part => !string.IsNullOrEmpty(part)).ToList();
}
private List GetParts(Item item)
diff --git a/Parsers/TMDBParser.cs b/Parsers/TMDBParser.cs
index b361506..ac71df8 100644
--- a/Parsers/TMDBParser.cs
+++ b/Parsers/TMDBParser.cs
@@ -20,7 +20,7 @@ public class TMDBParser(Configs configs) : ItemParser
private TMDbClient _client;
- private async Task QueryTMDB(string title)
+ private async Task QueryTMDB(string title, int year)
{
if (string.IsNullOrEmpty(title)) return null;
@@ -29,7 +29,7 @@ public class TMDBParser(Configs configs) : ItemParser
return result;
}
- var results = (await GetTMDbClient().SearchTvShowAsync(title, language: "zh-CN")).Results;
+ var results = (await GetTMDbClient().SearchTvShowAsync(title, language: "zh-CN", firstAirDateYear:year)).Results;
result = results.FirstOrDefault();
_cache[title] = result;
return result;
@@ -58,34 +58,40 @@ public class TMDBParser(Configs configs) : ItemParser
public async Task Parse(TreeNode node)
{
- // if (!node.TryGetValue(ItemFields.Key_RawTitle, out var rawTitle, out _))
- // {
- // if (!DoRawParse(node))
- // {
- // return false;
- // }
- // node.TryGetValue(ItemFields.Key_RawTitle, out rawTitle, out _);
- // }
- //
- // if (string.IsNullOrEmpty(rawTitle))
- // {
- // return false;
- // }
- //
- // var result = await QueryTMDB(rawTitle);
- // if (result == null)
- // {
- // GD.PrintErr($"找不到对应的TV:{rawTitle}");
- // return false;
- // }
- //
- // if (result.FirstAirDate != null)
- // {
- // node.Info.SetYear(result.FirstAirDate.Value.Year);
- // }
- //
- // node.Info.SetTitleIfNotExist(result.Name);
- //
- // return true;
+ if (node.TryGetValue(ItemFields.Key_Title, out _, out _)) return;
+
+ if (!node.TryGetValue(ItemFields.Key_RawTitle, out var rawTitle, out _))
+ {
+ return;
+ }
+
+ if (string.IsNullOrEmpty(rawTitle))
+ {
+ return ;
+ }
+
+ int year = 0;
+ if (node.TryGetValue(ItemFields.Key_Year, out var yearStr, out _))
+ {
+ if (int.TryParse(yearStr, out var yearValue))
+ {
+ year = yearValue;
+ }
+ }
+
+ var result = await QueryTMDB(rawTitle, year);
+ if (result == null)
+ {
+ GD.PrintErr($"找不到对应的TV:{rawTitle}");
+ return;
+ }
+
+ if (result.FirstAirDate != null)
+ {
+ node.Info.Info[ItemFields.Key_Year] = result.FirstAirDate.Value.Year.ToString();
+ }
+
+ node.Info.Info[ItemFields.Key_Title] = result.Name;
+ node.Info.Info[ItemFields.Key_TMDBID] = result.Id.ToString();
}
}
\ No newline at end of file