diff options
| author | Niels van Velzen <nielsvanvelzen@users.noreply.github.com> | 2025-11-27 16:32:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-27 16:32:11 +0100 |
| commit | 8c02c3be9381ed81260537eab1f7c1e2b8048ffc (patch) | |
| tree | 570971f35750355f51b834fa1c5e8c554001f0d2 /Emby.Naming/TV/SeriesResolver.cs | |
| parent | 45669c9b30b6f24410ddb7b577bed7ca298d41a9 (diff) | |
| parent | 2508e8349be5b8052a68ad73316845f4668d4f43 (diff) | |
Merge pull request #14824 from CodyEngel/fix-numeric-titles
Fix TV Series parsing containing only numbers.
Diffstat (limited to 'Emby.Naming/TV/SeriesResolver.cs')
| -rw-r--r-- | Emby.Naming/TV/SeriesResolver.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Emby.Naming/TV/SeriesResolver.cs b/Emby.Naming/TV/SeriesResolver.cs index c955b8a0d..0b7309bae 100644 --- a/Emby.Naming/TV/SeriesResolver.cs +++ b/Emby.Naming/TV/SeriesResolver.cs @@ -18,6 +18,13 @@ namespace Emby.Naming.TV private static partial Regex SeriesNameRegex(); /// <summary> + /// Regex that matches titles with year in parentheses. Captures the title (which may be + /// numeric) before the year, i.e. turns "1923 (2022)" into "1923". + /// </summary> + [GeneratedRegex(@"(?<title>.+?)\s*\(\d{4}\)")] + private static partial Regex TitleWithYearRegex(); + + /// <summary> /// Resolve information about series from path. /// </summary> /// <param name="options"><see cref="NamingOptions"/> object passed to <see cref="SeriesPathParser"/>.</param> @@ -27,6 +34,20 @@ namespace Emby.Naming.TV { string seriesName = Path.GetFileName(path); + // First check if the filename matches a title with year pattern (handles numeric titles) + if (!string.IsNullOrEmpty(seriesName)) + { + var titleWithYearMatch = TitleWithYearRegex().Match(seriesName); + if (titleWithYearMatch.Success) + { + seriesName = titleWithYearMatch.Groups["title"].Value.Trim(); + return new SeriesInfo(path) + { + Name = seriesName + }; + } + } + SeriesPathParserResult result = SeriesPathParser.Parse(options, path); if (result.Success) { |
