From 69567de9a2b950cb1704f93ddb1588d85af1c956 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 4 Jun 2014 21:54:40 -0700 Subject: [PATCH] Some additional release group parsing tests --- .../ParserTests/ReleaseGroupParserFixture.cs | 4 ++++ src/NzbDrone.Core/Parser/Parser.cs | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs index d147bc47b..06a95be1b 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ReleaseGroupParserFixture.cs @@ -20,6 +20,10 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("The.Walking.Dead.S04E13.720p.WEB-DL.AAC2.0.H.264-Cyphanix", "Cyphanix")] [TestCase("Arrow.S02E01.720p.WEB-DL.DD5.1.H.264.mkv", "DRONE")] [TestCase("Series Title S01E01 Episode Title", "DRONE")] + [TestCase("The Colbert Report - 2014-06-02 - Thomas Piketty.mkv", "DRONE")] + [TestCase("Real Time with Bill Maher S12E17 May 23, 2014.mp4", "DRONE")] + [TestCase("Reizen Waes - S01E08 - Transistrië, Zuid-Ossetië en Abchazië SDTV.avi", "DRONE")] + [TestCase("Simpsons 10x11 - Wild Barts Cant Be Broken [rl].avi", "DRONE")] public void should_parse_release_group(string title, string expected) { Parser.Parser.ParseReleaseGroup(title).Should().Be(expected); diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 528b6ae27..f9345db2b 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -284,18 +284,22 @@ namespace NzbDrone.Core.Parser title = title.TrimEnd("-RP"); - string group; var matches = ReleaseGroupRegex.Matches(title); + if (matches.Count != 0) { - group = matches.OfType().Last().Groups["releasegroup"].Value; - } - else - { - return defaultReleaseGroup; + var group = matches.OfType().Last().Groups["releasegroup"].Value; + int groupIsNumeric; + + if (Int32.TryParse(group, out groupIsNumeric)) + { + return defaultReleaseGroup; + } + + return group; } - return group; + return defaultReleaseGroup; } public static string RemoveFileExtension(string title)