Minor improvements to season parsing from titles for AnimeBytes

pull/2171/head
Bogdan 9 months ago
parent 1a89a79b74
commit e092098101

@ -644,16 +644,16 @@ namespace NzbDrone.Core.Indexers.Definitions
private static int? ParseSeasonFromTitles(IReadOnlyCollection<string> titles) private static int? ParseSeasonFromTitles(IReadOnlyCollection<string> titles)
{ {
var advancedSeasonRegex = new Regex(@"(\d+)(st|nd|rd|th) Season", RegexOptions.Compiled | RegexOptions.IgnoreCase); var advancedSeasonRegex = new Regex(@"\b(?:(?<season>\d+)(?:st|nd|rd|th) Season|Season (?<season>\d+))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
var seasonCharactersRegex = new Regex(@"(I{2,})$", RegexOptions.Compiled); var seasonCharactersRegex = new Regex(@"(I{2,})$", RegexOptions.Compiled);
var seasonNumberRegex = new Regex(@"\b(?:S)?([2-9])$", RegexOptions.Compiled); var seasonNumberRegex = new Regex(@"\b(?<!Part[- ._])(?:S)?(?<season>[2-9])$", RegexOptions.Compiled);
foreach (var title in titles) foreach (var title in titles)
{ {
var advancedSeasonRegexMatch = advancedSeasonRegex.Match(title); var advancedSeasonRegexMatch = advancedSeasonRegex.Match(title);
if (advancedSeasonRegexMatch.Success) if (advancedSeasonRegexMatch.Success)
{ {
return ParseUtil.CoerceInt(advancedSeasonRegexMatch.Groups[1].Value); return ParseUtil.CoerceInt(advancedSeasonRegexMatch.Groups["season"].Value);
} }
var seasonCharactersRegexMatch = seasonCharactersRegex.Match(title); var seasonCharactersRegexMatch = seasonCharactersRegex.Match(title);
@ -665,7 +665,7 @@ namespace NzbDrone.Core.Indexers.Definitions
var seasonNumberRegexMatch = seasonNumberRegex.Match(title); var seasonNumberRegexMatch = seasonNumberRegex.Match(title);
if (seasonNumberRegexMatch.Success) if (seasonNumberRegexMatch.Success)
{ {
return ParseUtil.CoerceInt(seasonNumberRegexMatch.Groups[1].Value); return ParseUtil.CoerceInt(seasonNumberRegexMatch.Groups["season"].Value);
} }
} }

Loading…
Cancel
Save