Quality parsing improvements

Fixed: Parsing quality in filename from other applications
Fixed: Parsing WEB.DL as WEB-DL
This commit is contained in:
Mark McDowall
2014-06-16 07:57:55 -07:00
parent 590a39a47e
commit df1283c0a5
2 changed files with 51 additions and 3 deletions
@@ -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);