From 8f1f96a5737c146084ec5f109fd0c4b924216881 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 16 Dec 2012 01:08:02 -0800 Subject: [PATCH] Fixed: WEBDL-480p being detected as WEBDL-720p Fixed Newznab DNS hostname test, finally! --- .../ParserFixture/QualityParserTests.cs | 9 +++++++-- .../ProviderTests/NewznabProviderTest.cs | 5 +++-- .../ProviderTests/QualityTypeProviderTest.cs | 5 +++-- NzbDrone.Core/Parser.cs | 15 ++++++++++++++- NzbDrone.Core/Repository/Quality/QualityTypes.cs | 6 ++++-- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/NzbDrone.Core.Test/ParserFixture/QualityParserTests.cs b/NzbDrone.Core.Test/ParserFixture/QualityParserTests.cs index 7726ac4cb..5b8334e79 100644 --- a/NzbDrone.Core.Test/ParserFixture/QualityParserTests.cs +++ b/NzbDrone.Core.Test/ParserFixture/QualityParserTests.cs @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.ParserFixture new object[] { "Pawn Stars S04E87 REPACK 720p HDTV x264 aAF", QualityTypes.HDTV, true }, new object[] { "The Real Housewives of Vancouver S01E04 DSR x264 2HD", QualityTypes.SDTV, false }, new object[] { "Vanguard S01E04 Mexicos Death Train DSR x264 MiNDTHEGAP", QualityTypes.SDTV, false }, - new object[] { "Vanguard S01E04 Mexicos Death Train 720 WEB DL", QualityTypes.WEBDL720p, false }, + new object[] { "Vanguard S01E04 Mexicos Death Train 720p WEB DL", QualityTypes.WEBDL720p, false }, new object[] { "Hawaii Five 0 S02E21 720p WEB DL DD5 1 H 264", QualityTypes.WEBDL720p, false }, new object[] { "Castle S04E22 720p WEB DL DD5 1 H 264 NFHD", QualityTypes.WEBDL720p, false }, new object[] { "Fringe S04E22 720p WEB-DL DD5.1 H264-EbP.mkv", QualityTypes.WEBDL720p, false }, @@ -70,15 +70,20 @@ namespace NzbDrone.Core.Test.ParserFixture new object[] { "Criminal.Minds.S08E01.1080p.WEB-DL.DD5.1.H264-NFHD", QualityTypes.WEBDL1080p, false }, new object[] { "Its.Always.Sunny.in.Philadelphia.S08E01.1080p.WEB-DL.proper.AAC2.0.H.264", QualityTypes.WEBDL1080p, true }, new object[] { "Two and a Half Men S10E03 1080p WEB DL DD5 1 H 264 REPACK NFHD", QualityTypes.WEBDL1080p, true }, - new object[] { "Glee.S04E09.Swan.Song.1080p.WEB-DL.DD5.1.H.264-ECI", QualityTypes.WEBDL1080p, false } + new object[] { "Glee.S04E09.Swan.Song.1080p.WEB-DL.DD5.1.H.264-ECI", QualityTypes.WEBDL1080p, false }, + new object[] { "Elementary.S01E10.The.Leviathan.480p.WEB-DL.x264-mSD", QualityTypes.WEBDL480p, false }, + new object[] { "Glee.S04E10.Glee.Actually.480p.WEB-DL.x264-mSD", QualityTypes.WEBDL480p, false }, + new object[] { "The.Big.Bang.Theory.S06E11.The.Santa.Simulation.480p.WEB-DL.x264-mSD", QualityTypes.WEBDL480p, false } }; public static object[] SelfQualityParserCases = { new object[] { QualityTypes.SDTV }, new object[] { QualityTypes.DVD }, + new object[] { QualityTypes.WEBDL480p }, new object[] { QualityTypes.HDTV }, new object[] { QualityTypes.WEBDL720p }, + new object[] { QualityTypes.WEBDL1080p }, new object[] { QualityTypes.Bluray720p }, new object[] { QualityTypes.Bluray1080p } }; diff --git a/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs index ea296922d..64a9292bb 100644 --- a/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/NewznabProviderTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Sockets; using FizzWare.NBuilder; using FluentAssertions; using Moq; @@ -304,10 +305,10 @@ namespace NzbDrone.Core.Test.ProviderTests } [Test] - [ExpectedException("System.Net.Sockets.SocketException")] public void CheckHostname_should_log_error_and_throw_exception_if_dnsHostname_is_invalid() { - Mocker.Resolve().CheckHostname("http://BadName"); + Assert.Throws(() => Mocker.Resolve().CheckHostname("http://BadName")); + ExceptionVerification.ExpectedErrors(1); } } diff --git a/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs index 6a76de3cd..5135342fe 100644 --- a/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/QualityTypeProviderTest.cs @@ -29,9 +29,10 @@ namespace NzbDrone.Core.Test.ProviderTests //Assert var types = Mocker.Resolve().All(); - types.Should().HaveCount(7); + types.Should().HaveCount(8); types.Should().Contain(e => e.Name == "SDTV" && e.QualityTypeId == 1); types.Should().Contain(e => e.Name == "DVD" && e.QualityTypeId == 2); + types.Should().Contain(e => e.Name == "WEBDL-480p" && e.QualityTypeId == 8); types.Should().Contain(e => e.Name == "HDTV" && e.QualityTypeId == 4); types.Should().Contain(e => e.Name == "WEBDL-720p" && e.QualityTypeId == 5); types.Should().Contain(e => e.Name == "WEBDL-1080p" && e.QualityTypeId == 3); @@ -54,7 +55,7 @@ namespace NzbDrone.Core.Test.ProviderTests //Assert var types = Mocker.Resolve().All(); - types.Should().HaveCount(7); + types.Should().HaveCount(8); } [Test] diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index ea1890f49..44dc8128b 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -295,7 +295,20 @@ namespace NzbDrone.Core result.Quality = QualityTypes.WEBDL1080p; return result; } - result.Quality = QualityTypes.WEBDL720p; + + if (normalizedName.Contains("720p")) + { + result.Quality = QualityTypes.WEBDL720p; + return result; + } + + if(name.Contains("[WEBDL]")) + { + result.Quality = QualityTypes.WEBDL720p; + return result; + } + + result.Quality = QualityTypes.WEBDL480p; return result; } if (normalizedName.Contains("x264") || normalizedName.Contains("h264") || normalizedName.Contains("720p")) diff --git a/NzbDrone.Core/Repository/Quality/QualityTypes.cs b/NzbDrone.Core/Repository/Quality/QualityTypes.cs index e77c3f2cb..e055de8a4 100644 --- a/NzbDrone.Core/Repository/Quality/QualityTypes.cs +++ b/NzbDrone.Core/Repository/Quality/QualityTypes.cs @@ -94,11 +94,12 @@ namespace NzbDrone.Core.Repository.Quality public static QualityTypes Unknown = new QualityTypes { Id = 0, Name = "Unknown", Weight = 0 }; public static QualityTypes SDTV = new QualityTypes {Id = 1, Name = "SDTV", Weight = 1}; - public static QualityTypes DVD = new QualityTypes { Id = 2, Name = "DVD", Weight = 2 }; + public static QualityTypes WEBDL480p = new QualityTypes { Id = 8, Name = "WEBDL-480p", Weight = 2 }; + public static QualityTypes DVD = new QualityTypes { Id = 2, Name = "DVD", Weight = 3 }; public static QualityTypes HDTV = new QualityTypes { Id = 4, Name = "HDTV", Weight = 4 }; public static QualityTypes WEBDL720p = new QualityTypes { Id = 5, Name = "WEBDL-720p", Weight = 5 }; - public static QualityTypes WEBDL1080p = new QualityTypes { Id = 3, Name = "WEBDL-1080p", Weight = 7 }; public static QualityTypes Bluray720p = new QualityTypes { Id = 6, Name = "Bluray720p", Weight = 6 }; + public static QualityTypes WEBDL1080p = new QualityTypes { Id = 3, Name = "WEBDL-1080p", Weight = 7 }; public static QualityTypes Bluray1080p = new QualityTypes { Id = 7, Name = "Bluray1080p", Weight = 8 }; public static List All() @@ -107,6 +108,7 @@ namespace NzbDrone.Core.Repository.Quality { Unknown, SDTV, + WEBDL480p, DVD, HDTV, WEBDL720p,