New: Parse UK date based release format

Closes #7695
This commit is contained in:
Mark McDowall 2025-03-23 10:21:15 -07:00
parent 94f64435f5
commit ffb16eaa8d
No known key found for this signature in database
2 changed files with 50 additions and 1 deletions

View file

@ -108,5 +108,20 @@ namespace NzbDrone.Core.Test.ParserTests
{
Parser.Parser.ParseTitle(postTitle).Should().BeNull();
}
[TestCase("Series 5th Mar 2025 1080 (Deep61)", "Series", 2025, 3, 5)]
[TestCase("Series 31st Jan 2025 1080 (Deep61)", "Series", 2025, 1, 31)]
[TestCase("Series 23rd Feb 2024 (Deep61)", "Series", 2024, 2, 23)]
public void should_parse_daily_episode_using_short_month_format(string postTitle, string title, int year, int month, int day)
{
var result = Parser.Parser.ParseTitle(postTitle);
var airDate = new DateTime(year, month, day);
result.Should().NotBeNull();
result.SeriesTitle.Should().Be(title);
result.AirDate.Should().Be(airDate.ToString(Episode.AIR_DATE_FORMAT));
result.EpisodeNumbers.Should().BeEmpty();
result.AbsoluteEpisodeNumbers.Should().BeEmpty();
result.FullSeason.Should().BeFalse();
}
}
}

View file

@ -394,9 +394,13 @@ namespace NzbDrone.Core.Parser
new Regex(@"^(?:\[(?<subgroup>.+?)\][-_. ]?)?(?<title>.+?)(?:(?:_|-|\s|\.)+(?:e|ep)(?<absoluteepisode>(\d{3}|\d{4})(\.\d{1,2})?))+[-_. ].*?(?<hash>[(\[]\w{8}[)\]])?$",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
// Daily episodes that use short month format instead of number
new Regex(@"^(?<title>.+?)[-_. ]+(?<airday>[1-2]\d|3[01]|[1-9])(?:th|st|rd)[-_. ](?<shortairmonth>jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[-_. ](?<airyear>19[4-9]\d|20\d\d)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
// Supports 1103/1113 naming
new Regex(@"^(?<title>.+?)?(?:(?:[-_. ](?<![()\[!]))*(?<!\d{1,2}-)(?<season>(?<!\d+|\(|\[|e|x)\d{2})(?<episode>(?<!e|x)(?:[1-9][0-9]|[0][1-9])(?!p|i|\d+|\)|\]|\W\d+|\W(?:e|ep|x)\d+)))+([-_. ]+|$)(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
RegexOptions.IgnoreCase | RegexOptions.Compiled),
// Dutch/Flemish release titles
new Regex(@"^(?<title>.+?)[-_. ](?:Se\.(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:(?:[-_ ]?afl\.)(?<episode>\d{1,3}(?!\d+))(?:(?:[-]|[-_ ]en[-_ ])(?<episode>\d{1,3}(?!\d+)))*))",
@ -592,6 +596,22 @@ namespace NzbDrone.Core.Parser
private static readonly Regex MultiRegex = new(@"[_. ](?<multi>multi)[_. ]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Dictionary<string, int> ShortMonths = new()
{
{ "jan", 1 },
{ "feb", 2 },
{ "mar", 3 },
{ "apr", 4 },
{ "may", 5 },
{ "jun", 6 },
{ "jul", 7 },
{ "aug", 8 },
{ "sep", 9 },
{ "oct", 10 },
{ "nov", 11 },
{ "dec", 12 },
};
public static ParsedEpisodeInfo ParsePath(string path)
{
var fileInfo = new FileInfo(path);
@ -1187,6 +1207,20 @@ namespace NzbDrone.Core.Parser
airmonth = ambiguousAirMonth;
airday = ambiguousAirDay;
}
else if (matchCollection[0].Groups["shortairmonth"].Success)
{
var shortMonthValue = matchCollection[0].Groups["shortairmonth"].Value;
if (ShortMonths.TryGetValue(shortMonthValue.ToLowerInvariant(), out var shortMonth))
{
airmonth = shortMonth;
airday = Convert.ToInt32(matchCollection[0].Groups["airday"].Value);
}
else
{
throw new InvalidDateException("Unable to determine air month from month: {0}", shortMonthValue);
}
}
else
{
airmonth = Convert.ToInt32(matchCollection[0].Groups["airmonth"].Value);