diff --git a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs index 0b4a71cf2..bc55dd784 100644 --- a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs @@ -16,12 +16,26 @@ namespace NzbDrone.Core.Test.ParserTests new object[] { Quality.DVD }, new object[] { Quality.WEBDL480p }, new object[] { Quality.HDTV720p }, + new object[] { Quality.HDTV1080p }, new object[] { Quality.WEBDL720p }, new object[] { Quality.WEBDL1080p }, new object[] { Quality.Bluray720p }, new object[] { Quality.Bluray1080p } }; + public static object[] OtherSourceQualityParserCases = + { + new object[] { "SD TV", Quality.SDTV }, + new object[] { "SD DVD", Quality.DVD }, + new object[] { "480p WEB-DL", Quality.WEBDL480p }, + new object[] { "HD TV", Quality.HDTV720p }, + new object[] { "1080p HD TV", Quality.HDTV1080p }, + new object[] { "720p WEB-DL", Quality.WEBDL720p }, + new object[] { "1080p WEB-DL", Quality.WEBDL1080p }, + new object[] { "720p BluRay", Quality.Bluray720p }, + new object[] { "1080p BluRay", Quality.Bluray1080p } + }; + [TestCase("S07E23 .avi ", false)] [TestCase("The.Shield.S01E13.x264-CtrlSD", false)] [TestCase("Nikita S02E01 HDTV XviD 2HD", false)] @@ -64,7 +78,8 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("Elementary.S01E10.The.Leviathan.480p.WEB-DL.x264-mSD", false)] [TestCase("Glee.S04E10.Glee.Actually.480p.WEB-DL.x264-mSD", false)] - [TestCase("The.Big.Bang.Theory.S06E11.The.Santa.Simulation.480p.WEB-DL.x264-mSD", false)] + [TestCase("The.Big.Bang.Theory.S06E11.The.Santa.Simulation.480p.WEB-DL.x264-mSD", false)] + [TestCase("Da.Vincis.Demons.S02E04.480p.WEB.DL.nSD.x264-NhaNc3", false)] public void should_parse_webdl480p_quality(string title, bool proper) { ParseAndVerifyQuality(title, Quality.WEBDL480p, proper); @@ -105,6 +120,7 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("S07E23 - [WEBDL].mkv ", false)] [TestCase("Fringe S04E22 720p WEB-DL DD5.1 H264-EbP.mkv", false)] [TestCase("House.S04.720p.Web-Dl.Dd5.1.h264-P2PACK", false)] + [TestCase("Da.Vincis.Demons.S02E04.720p.WEB.DL.nSD.x264-NhaNc3", false)] public void should_parse_webdl720p_quality(string title, bool proper) { ParseAndVerifyQuality(title, Quality.WEBDL720p, proper); @@ -164,6 +180,18 @@ namespace NzbDrone.Core.Test.ParserTests result.Quality.Should().Be(quality); } + [Test, TestCaseSource("OtherSourceQualityParserCases")] + public void should_parse_quality_from_other_source(string qualityString, Quality quality) + { + foreach (var c in new char[] { '-', '.', ' ', '_' }) + { + var title = String.Format("My series S01E01 {0}", qualityString.Replace(' ', c)); + + ParseAndVerifyQuality(title, quality, false); + } + } + + private void ParseAndVerifyQuality(string title, Quality quality, bool proper) { var result = Parser.QualityParser.ParseQuality(title); diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index e8b6e5d5b..66da37c71 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -14,12 +14,12 @@ namespace NzbDrone.Core.Parser private static readonly Regex SourceRegex = new Regex(@"\b(?: (?BluRay)| - (?WEB-DL|WEBDL|WEB\sDL|WEB\-DL|WebRip)| + (?WEB[-_. ]DL|WEBDL|WebRip)| (?HDTV)| (?BDRiP)| (?BRRip)| (?DVD|DVDRip|NTSC|PAL|xvidvd)| - (?WS\sDSR|WS_DSR|WS\.DSR|DSR)| + (?WS[-_. ]DSR|DSR)| (?PDTV)| (?SDTV) )\b", @@ -37,6 +37,8 @@ namespace NzbDrone.Core.Parser private static readonly Regex CodecRegex = new Regex(@"\b(?:(?x264)|(?h264)|(?XvidHD)|(?Xvid)|(?divx))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex OtherSourceRegex = new Regex(@"(?HD[-_. ]TV)|(?SD[-_. ]TV)", RegexOptions.Compiled | RegexOptions.IgnoreCase); + public static QualityModel ParseQuality(string name) { Logger.Debug("Trying to parse quality for {0}", name); @@ -191,6 +193,13 @@ namespace NzbDrone.Core.Parser result.Quality = Quality.Bluray1080p; } + var otherSourceMatch = OtherSourceMatch(normalizedName); + + if (otherSourceMatch != Quality.Unknown) + { + result.Quality = otherSourceMatch; + } + //Based on extension if (result.Quality == Quality.Unknown && !name.ContainsInvalidPathChars()) { @@ -220,6 +229,17 @@ namespace NzbDrone.Core.Parser return Resolution.Unknown; } + + private static Quality OtherSourceMatch(string name) + { + var match = OtherSourceRegex.Match(name); + + if (!match.Success) return Quality.Unknown; + if (match.Groups["sdtv"].Success) return Quality.SDTV; + if (match.Groups["hdtv"].Success) return Quality.HDTV720p; + + return Quality.Unknown; + } } public enum Resolution