New: Improved parsing of season and episode inside square brackets

Closes #3618
pull/3902/head
Mark McDowall 4 years ago
parent 91b2fe8dcb
commit 84747792ff

@ -67,6 +67,9 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("The.Name.of.the.Rose.S01E05-6.PL.1080p.WEBRip.x264-666", "The Name of the Rose", 1, new[] { 5, 6 })]
[TestCase("Series Title - S15E06-07 - City Sushi HDTV-720p", "Series Title", 15, new[] { 6, 7 })]
[TestCase("Series Title - S01E01-02-03 - Episode Title HDTV-720p", "Series Title", 1, new[] { 1, 2, 3 })]
[TestCase("Series Title - [02x01x02] - Episode 1", "Series Title", 2, new [] { 1, 2})]
[TestCase("Series Title - [02x01-x02] - Episode 1", "Series Title", 2, new [] { 1, 2})]
[TestCase("Series Title - [02x01-02] - Episode 1", "Series Title", 2, new [] { 1, 2})]
//[TestCase("", "", , new [] { })]
public void should_parse_multiple_episodes(string postTitle, string title, int season, int[] episodes)
{

@ -141,6 +141,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Series.Title.S01EP01.English.AC3.DL.1080p.BluRay-Sonarr", "Series Title", 1, 1)]
[TestCase("tvs-amgo-dd51-dl-7p-azhd-x264-103", "tvs-amgo-dd51-dl-7p-azhd", 1, 3)]
[TestCase("Series Title - S01E01 [AC3 5.1 Castellano][www.descargas2020.org]", "Series Title", 1, 1)]
[TestCase("Series Title - [02x01] - Episode 1", "Series Title", 2, 1)]
//[TestCase("", "", 0, 0)]
public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber)
{

@ -205,6 +205,12 @@ namespace NzbDrone.Core.Parser
new Regex(@"^(?<title>.+?)(?:_|-|\s|\.)+S(?<season>\d{2}(?!\d+))(\W-\W)E(?<episode>(?<!\d+)\d{2}(?!\d+))(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
// Season and episode numbers in square brackets (single and mult-episode)
// Series Title - [02x01] - Episode 1
// Series Title - [02x01x02] - Episode 1
new Regex(@"^(?<title>.+?)?(?:[-_\W](?<![()\[!]))+\[(?<season>(?<!\d+)\d{1,2})(?:(?:-|x){1,2}(?<episode>\d{2}))+\].+?(?:\.|$)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
// Anime - Title with season number - Absolute Episode Number (Title S01 - EP14)
new Regex(@"^(?<title>.+?S\d{1,2})[-_. ]{3,}(?:EP)?(?<absoluteepisode>\d{2,3}(\.\d{1,2})?(?!\d+|[-]))",
RegexOptions.IgnoreCase | RegexOptions.Compiled),

Loading…
Cancel
Save