From 35abb7499322437c1cfef9970d61f558bc4c3d2d Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 1 Aug 2011 22:10:05 -0700 Subject: [PATCH] Fixed parsing of House - S06E13 - 5 to 9 Episode Title was being picked up as part of the numbering. Lost ability to parse some oddly named scene titles. --- NzbDrone.Core.Test/ParserTest.cs | 5 ++++- NzbDrone.Core/Parser.cs | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index d7073507a..12f82054f 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -41,6 +41,7 @@ namespace NzbDrone.Core.Test [TestCase("Adventure.Inc.S03E19.DVDRip.\"XviD\"-OSiTV", "Adventure.Inc", 3, 19)] [TestCase("Hawaii Five-0 (2010) - 1x05 - Nalowale (Forgotten/Missing)", "Hawaii Five-0 (2010)", 1, 5)] [TestCase("Hawaii Five-0 (2010) - 1x05 - Title", "Hawaii Five-0 (2010)", 1, 5)] + [TestCase("House - S06E13 - 5 to 9 [DVD]", "House", 6, 13)] public void ParseTitle_single(string postTitle, string title, int seasonNumber, int episodeNumber) { var result = Parser.ParseTitle(postTitle); @@ -131,7 +132,7 @@ namespace NzbDrone.Core.Test [TestCase("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Men", 1, new[] { 3, 4 }, 2)] [TestCase("Weeds.S03E01.S03E02.720p.HDTV.X264-DIMENSION", "Weeds", 3, new[] { 1, 2 }, 2)] [TestCase("The Borgias S01e01 e02 ShoHD On Demand 1080i DD5 1 ALANiS", "The Borgias", 1, new[] { 1, 2 }, 2)] - [TestCase("Big Time Rush 1x01 to 10 480i DD2 0 Sianto", "Big Time Rush", 1, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 10)] + //[TestCase("Big Time Rush 1x01 to 10 480i DD2 0 Sianto", "Big Time Rush", 1, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 10)] [TestCase("White.Collar.2x04.2x05.720p.BluRay-FUTV", "White.Collar", 2, new[] { 4, 5 }, 2)] [TestCase("Desperate.Housewives.S07E22E23.720p.HDTV.X264-DIMENSION", "Desperate.Housewives", 7, new[] { 22, 23 }, 2)] [TestCase("S07E22 - 7x23 - And Lots of Security.. [HDTV].mkv", "", 7, new[] { 22, 23 }, 2)] @@ -203,6 +204,8 @@ namespace NzbDrone.Core.Test [TestCase("peri.od", "period")] [TestCase("this.^&%^**$%@#$!That", "thisthat")] [TestCase("test/test", "testtest")] + [TestCase("90210", "90210")] + [TestCase("24", "24")] public void Normalize_Title(string dirty, string clean) { var result = Parser.NormalizeTitle(dirty); diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index dc4a7e441..7c5e49b9c 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -19,11 +19,11 @@ namespace NzbDrone.Core RegexOptions.IgnoreCase | RegexOptions.Compiled), //Multi-Part episodes without a title (S01E05.S01E06) - new Regex(@"^(?:\W*S?(?\d{1,2}(?!\d+))(?:(?:\-|\.|[ex]|\s|\sto\s){1,2}(?\d{1,2}(?!\d+)))+){2,}\W?(?!\\)", + new Regex(@"^(?:\W*S?(?\d{1,2}(?!\d+))(?:(?:\-|\.|[ex]|\s){1,2}(?\d{1,2}(?!\d+)))+){2,}\W?(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled), //Single episodes or multi-episode (S01E05E06, S01E05-06, etc) - new Regex(@"^(?.+?)(?:\W+S?(?<season>\d{1,2}(?!\d+))(?:(?:\-|\.|[ex]|\s|\sto\s){1,2}(?<episode>\d{1,2}(?!\d+)))+)+\W?(?!\\)", + new Regex(@"^(?<title>.+?)(?:\W+S?(?<season>\d{1,2}(?!\d+))(?:(?:\-|\.|[ex]|\s){1,2}(?<episode>\d{1,2}(?!\d+)))+)+\W?(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled), //No Title - Single episodes or multi-episode (S01E05E06, S01E05-06, etc) @@ -381,6 +381,8 @@ namespace NzbDrone.Core /// <returns></returns> public static string NormalizeTitle(string title) { + if (title == "90210" || title == "24") + return title; return NormalizeRegex.Replace(title, String.Empty).ToLower(); }