Fixed: More restrictive repeated multi-episode parsing to avoid false positives

Closes #4716
pull/4777/head
Mark McDowall 3 years ago
parent 7b7da9c1b2
commit d600e2e3fb

@ -16,8 +16,6 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Series.Title.S07E22E23.720p.HDTV.X264-DIMENSION", "Series Title", 7, new[] { 22, 23 })] [TestCase("Series.Title.S07E22E23.720p.HDTV.X264-DIMENSION", "Series Title", 7, new[] { 22, 23 })]
[TestCase("Series Title - S07E22 - S07E23 - And Lots of Security.. [HDTV-720p].mkv", "Series Title", 7, new[] { 22, 23 })] [TestCase("Series Title - S07E22 - S07E23 - And Lots of Security.. [HDTV-720p].mkv", "Series Title", 7, new[] { 22, 23 })]
[TestCase("S03E01.S03E02.720p.HDTV.X264-DIMENSION", "", 3, new[] { 1, 2 })] [TestCase("S03E01.S03E02.720p.HDTV.X264-DIMENSION", "", 3, new[] { 1, 2 })]
[TestCase("Series Title - S07E22 - 7x23 - And Lots of Development.. [HDTV-720p].mkv", "Series Title", 7, new[] { 22, 23 })]
[TestCase("S07E22 - 7x23 - And Lots of Development.. [HDTV-720p].mkv", "", 7, new[] { 22, 23 })]
[TestCase("2x04x05.720p.BluRay-FUTV", "", 2, new[] { 4, 5 })] [TestCase("2x04x05.720p.BluRay-FUTV", "", 2, new[] { 4, 5 })]
[TestCase("S02E04E05.720p.BluRay-FUTV", "", 2, new[] { 4, 5 })] [TestCase("S02E04E05.720p.BluRay-FUTV", "", 2, new[] { 4, 5 })]
[TestCase("S02E03-04-05.720p.BluRay-FUTV", "", 2, new[] { 3, 4, 5 })] [TestCase("S02E03-04-05.720p.BluRay-FUTV", "", 2, new[] { 3, 4, 5 })]

@ -144,6 +144,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Series Title - [02x01] - Episode 1", "Series Title", 2, 1)] [TestCase("Series Title - [02x01] - Episode 1", "Series Title", 2, 1)]
[TestCase("Series.Title.Of.S01E01.xyz", "Series Title Of", 1, 1)] [TestCase("Series.Title.Of.S01E01.xyz", "Series Title Of", 1, 1)]
[TestCase("[RlsGrp] Series Title - S01E27 - 24-Hour", "Series Title", 1, 27)] [TestCase("[RlsGrp] Series Title - S01E27 - 24-Hour", "Series Title", 1, 27)]
[TestCase("Series Title - S02E01 1920x910", "Series Title", 2, 1)]
//[TestCase("", "", 0, 0)] //[TestCase("", "", 0, 0)]
public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber) public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber)
{ {

@ -46,7 +46,11 @@ namespace NzbDrone.Core.Parser
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Multi-Part episodes without a title (S01E05.S01E06) //Multi-Part episodes without a title (S01E05.S01E06)
new Regex(@"^(?:\W*S?(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:(?:[ex]){1,2}(?<episode>\d{1,3}(?!\d+)))+){2,}", new Regex(@"^(?:\W*S(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:e{1,2}(?<episode>\d{1,3}(?!\d+)))+){2,}",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Multi-Part episodes without a title (1x05.1x06)
new Regex(@"^(?:\W*(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:x{1,2}(?<episode>\d{1,3}(?!\d+)))+){2,}",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Episodes without a title, Multi (S01E04E05, 1x04x05, etc) //Episodes without a title, Multi (S01E04E05, 1x04x05, etc)
@ -101,8 +105,12 @@ namespace NzbDrone.Core.Parser
new Regex(@"^\[(?<subgroup>.+?)\][-_. ]?(?<title>.+?)[-_. ]+\(?(?:[-_. ]?#?(?<absoluteepisode>\d{2,3}(\.\d{1,2})?(?!\d+|-[a-z]+)))+\)?(?:[-_. ]+(?<special>special|ova|ovd))?.*?(?<hash>\[\w{8}\])?(?:$|\.mkv)", new Regex(@"^\[(?<subgroup>.+?)\][-_. ]?(?<title>.+?)[-_. ]+\(?(?:[-_. ]?#?(?<absoluteepisode>\d{2,3}(\.\d{1,2})?(?!\d+|-[a-z]+)))+\)?(?:[-_. ]+(?<special>special|ova|ovd))?.*?(?<hash>\[\w{8}\])?(?:$|\.mkv)",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Multi-episode Repeated (S01E05 - S01E06, 1x05 - 1x06, etc) //Multi-episode Repeated (S01E05 - S01E06)
new Regex(@"^(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+S?(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:(?:[ex]|[-_. ]e){1,2}(?<episode>\d{1,3}(?!\d+)))+){2,}", new Regex(@"^(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+S(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:(?:e|[-_. ]e){1,2}(?<episode>\d{1,3}(?!\d+)))+){2,}",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Multi-episode Repeated (1x05 - 1x06)
new Regex(@"^(?<title>.+?)(?:(?:[-_\W](?<![()\[!]))+(?<season>(?<!\d+)(?:\d{1,2}|\d{4})(?!\d+))(?:x{1,2}(?<episode>\d{1,3}(?!\d+)))+){2,}",
RegexOptions.IgnoreCase | RegexOptions.Compiled), RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Single episodes with a title (S01E05, 1x05, etc) and trailing info in slashes //Single episodes with a title (S01E05, 1x05, etc) and trailing info in slashes

Loading…
Cancel
Save