diff --git a/src/NzbDrone.Core.Test/ParserTests/SingleEpisodeParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/SingleEpisodeParserFixture.cs index 58d61da30..b3cd15d59 100644 --- a/src/NzbDrone.Core.Test/ParserTests/SingleEpisodeParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/SingleEpisodeParserFixture.cs @@ -129,6 +129,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Jeopardy - 2016x231", "Jeopardy", 2016, 231)] [TestCase("Shortland.Street.S26E022.HDTV.x264-FiHTV", "Shortland Street", 26, 22)] [TestCase("Super.Potatoes.S01.Ep06.1080p.BluRay.DTS.x264-MiR", "Super Potatoes", 1, 6)] + [TestCase("Room 104 - S01E07 The Missionaries [SDTV]", "Room 104", 1, 7)] //[TestCase("", "", 0, 0)] public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber) { diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 8c21c5e90..3f49248d2 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -262,6 +262,9 @@ namespace NzbDrone.Core.Parser private static readonly Regex CleanTorrentSuffixRegex = new Regex(@"\[(?:ettv|rartv|rarbg|cttv)\]$", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex CleanQualityBracketsRegex = new Regex(@"\[[a-z0-9 ._-]+\]$", + RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex ReleaseGroupRegex = new Regex(@"-(?[a-z0-9]+)(? + { + if (QualityParser.ParseQualityName(m.Value).Quality != Qualities.Quality.Unknown) + { + return string.Empty; + } + + return m.Value; + }); + var airDateMatch = AirDateRegex.Match(simpleTitle); if (airDateMatch.Success) { diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index f3a7126da..3d217605a 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -57,6 +57,29 @@ namespace NzbDrone.Core.Parser Logger.Debug("Trying to parse quality for {0}", name); name = name.Trim(); + + var result = ParseQualityName(name); + + //Based on extension + if (result.Quality == Quality.Unknown && !name.ContainsInvalidPathChars()) + { + try + { + result.Quality = MediaFileExtensions.GetQualityForExtension(Path.GetExtension(name)); + result.QualitySource = QualitySource.Extension; + } + catch (ArgumentException) + { + //Swallow exception for cases where string contains illegal + //path characters. + } + } + + return result; + } + + public static QualityModel ParseQualityName(string name) + { var normalizedName = name.Replace('_', ' ').Trim().ToLower(); var result = ParseQualityModifiers(name, normalizedName); @@ -298,21 +321,6 @@ namespace NzbDrone.Core.Parser result.Quality = otherSourceMatch; } - //Based on extension - if (result.Quality == Quality.Unknown && !name.ContainsInvalidPathChars()) - { - try - { - result.Quality = MediaFileExtensions.GetQualityForExtension(Path.GetExtension(name)); - result.QualitySource = QualitySource.Extension; - } - catch (ArgumentException) - { - //Swallow exception for cases where string contains illegal - //path characters. - } - } - return result; }