From 28d27dca5c47b2eaf11cb3a37edaf5588b493592 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Sun, 26 Feb 2017 01:14:52 -0500 Subject: [PATCH] Add remux 1080p and 2160p as qualities (#900) * Add Remux 1080p and 2160p as qualities, includes Tests & migration * Whoops forgot to take this out --- .../ParserTests/QualityParserFixture.cs | 18 +++++++++++++ ...134_add_remux_qualities_for_the_wankers.cs | 24 +++++++++++++++++ src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + src/NzbDrone.Core/Parser/QualityParser.cs | 26 ++++++++++++------- src/NzbDrone.Core/Profiles/ProfileService.cs | 15 ++++++++--- src/NzbDrone.Core/Qualities/Quality.cs | 18 +++++++++---- 6 files changed, 84 insertions(+), 18 deletions(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/134_add_remux_qualities_for_the_wankers.cs diff --git a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs index 1881d0d31..fcf25f4b7 100644 --- a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs @@ -24,6 +24,8 @@ public class QualityParserFixture : CoreTest new object[] { Quality.Bluray720p }, new object[] { Quality.Bluray1080p }, new object[] { Quality.Bluray2160p }, + new object[] { Quality.Remux1080p }, + new object[] { Quality.Remux2160p }, }; public static object[] OtherSourceQualityParserCases = @@ -40,6 +42,8 @@ public class QualityParserFixture : CoreTest new object[] { "720p BluRay", Quality.Bluray720p }, new object[] { "1080p BluRay", Quality.Bluray1080p }, new object[] { "2160p BluRay", Quality.Bluray2160p }, + new object[] { "1080p Remux", Quality.Remux1080p }, + new object[] { "2160p Remux", Quality.Remux2160p }, }; [TestCase("S07E23 .avi ", false)] @@ -221,6 +225,20 @@ public void should_parse_bluray576p_quality(string title) ParseAndVerifyQuality(title, Quality.Bluray576p, false); } + [TestCase("Contract.to.Kill.2016.REMUX.1080p.BluRay.AVC.DTS-HD.MA.5.1-iFT")] + [TestCase("27.Dresses.2008.REMUX.1080p.Bluray.AVC.DTS-HR.MA.5.1-LEGi0N")] + public void should_parse_remux1080p_quality(string title) + { + ParseAndVerifyQuality(title, Quality.Remux1080p, false); + } + + [TestCase("Contract.to.Kill.2016.REMUX.2160p.BluRay.AVC.DTS-HD.MA.5.1-iFT")] + [TestCase("27.Dresses.2008.REMUX.2160p.Bluray.AVC.DTS-HR.MA.5.1-LEGi0N")] + public void should_parse_remux2160p_quality(string title) + { + ParseAndVerifyQuality(title, Quality.Remux2160p, false); + } + //[TestCase("POI S02E11 1080i HDTV DD5.1 MPEG2-TrollHD", false)] //[TestCase("How I Met Your Mother S01E18 Nothing Good Happens After 2 A.M. 720p HDTV DD5.1 MPEG2-TrollHD", false)] //[TestCase("The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", false)] diff --git a/src/NzbDrone.Core/Datastore/Migration/134_add_remux_qualities_for_the_wankers.cs b/src/NzbDrone.Core/Datastore/Migration/134_add_remux_qualities_for_the_wankers.cs new file mode 100644 index 000000000..a04790fd8 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/134_add_remux_qualities_for_the_wankers.cs @@ -0,0 +1,24 @@ +using System.Data; +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(134)] + public class add_remux_qualities_for_the_wankers : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.WithConnection(ConvertProfile); + } + + private void ConvertProfile(IDbConnection conn, IDbTransaction tran) + { + var updater = new ProfileUpdater70(conn, tran); + updater.SplitQualityAppend(19, 31); // Remux2160p AFTER Bluray2160p + updater.SplitQualityAppend(7, 30); // Remux1080p AFTER Bluray1080p + + updater.Commit(); + } + } +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index a2befbe20..b43b6f871 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -124,6 +124,7 @@ + diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index 2a115917c..93f706b3d 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -50,8 +50,8 @@ public class QualityParser private static readonly Regex HardcodedSubsRegex = new Regex(@"\b(?(\w+SUBS?)\b)|(?(HC))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); - private static readonly Regex RawHDRegex = new Regex(@"\b(?RawHD|1080i[-_. ]HDTV|Raw[-_. ]HD|MPEG[-_. ]?2)\b", - RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex RemuxRegex = new Regex(@"\b(?Remux)\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex ProperRegex = new Regex(@"\b(?proper|repack|rerip)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -95,16 +95,24 @@ public static QualityModel ParseQuality(string name) } } - //if (RawHDRegex.IsMatch(normalizedName)) - //{ - // result.Quality = Quality.RAWHD; - // return result; - //} - var sourceMatch = SourceRegex.Matches(normalizedName).OfType().LastOrDefault(); var resolution = ParseResolution(normalizedName); var codecRegex = CodecRegex.Match(normalizedName); - + + if (RemuxRegex.IsMatch(normalizedName)) + { + if (resolution == Resolution.R2160p) + { + result.Quality = Quality.Remux2160p; + return result; + } + + if (resolution == Resolution.R1080p) + { + result.Quality = Quality.Remux1080p; + return result; + } + } if (sourceMatch != null && sourceMatch.Success) { diff --git a/src/NzbDrone.Core/Profiles/ProfileService.cs b/src/NzbDrone.Core/Profiles/ProfileService.cs index 76cc85445..1ea9c2de8 100644 --- a/src/NzbDrone.Core/Profiles/ProfileService.cs +++ b/src/NzbDrone.Core/Profiles/ProfileService.cs @@ -107,6 +107,8 @@ public void Handle(ApplicationStartedEvent message) Quality.Bluray720p, Quality.Bluray1080p, Quality.Bluray2160p, + Quality.Remux1080p, + Quality.Remux2160p, Quality.BRDISK); AddDefaultProfile("SD", Quality.Bluray480p, @@ -130,12 +132,14 @@ public void Handle(ApplicationStartedEvent message) AddDefaultProfile("HD-1080p", Quality.Bluray1080p, Quality.HDTV1080p, Quality.WEBDL1080p, - Quality.Bluray1080p); + Quality.Bluray1080p, + Quality.Remux1080p); - AddDefaultProfile("Ultra-HD", Quality.Bluray2160p, + AddDefaultProfile("Ultra-HD", Quality.Remux2160p, Quality.HDTV2160p, Quality.WEBDL2160p, - Quality.Bluray2160p); + Quality.Bluray2160p, + Quality.Remux2160p); AddDefaultProfile("HD - 720p/1080p", Quality.Bluray720p, Quality.HDTV720p, @@ -143,7 +147,10 @@ public void Handle(ApplicationStartedEvent message) Quality.WEBDL720p, Quality.WEBDL1080p, Quality.Bluray720p, - Quality.Bluray1080p); + Quality.Bluray1080p, + Quality.Remux1080p, + Quality.Remux2160p + ); } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Qualities/Quality.cs b/src/NzbDrone.Core/Qualities/Quality.cs index bae08123e..b206290b5 100644 --- a/src/NzbDrone.Core/Qualities/Quality.cs +++ b/src/NzbDrone.Core/Qualities/Quality.cs @@ -88,6 +88,10 @@ public override bool Equals(object obj) public static Quality Bluray720p => new Quality(6, "Bluray-720p"); public static Quality Bluray1080p => new Quality(7, "Bluray-1080p"); public static Quality Bluray2160p => new Quality(19, "Bluray-2160p"); + + public static Quality Remux1080p => new Quality(30, "Remux-1080p"); + public static Quality Remux2160p => new Quality(31, "Remux-2160p"); + public static Quality BRDISK => new Quality(22, "BR-DISK"); // new // Others @@ -119,6 +123,8 @@ static Quality() Bluray720p, Bluray1080p, Bluray2160p, + Remux1080p, + Remux2160p, BRDISK, RAWHD }; @@ -153,13 +159,15 @@ static Quality() new QualityDefinition(Quality.HDTV1080p) { Weight = 17, MinSize = 0, MaxSize = 100 }, new QualityDefinition(Quality.WEBDL1080p) { Weight = 18, MinSize = 0, MaxSize = 100 }, new QualityDefinition(Quality.Bluray1080p) { Weight = 19, MinSize = 0, MaxSize = null }, + new QualityDefinition(Quality.Remux1080p) { Weight = 20, MinSize = 0, MaxSize = null }, - new QualityDefinition(Quality.HDTV2160p) { Weight = 20, MinSize = 0, MaxSize = null }, - new QualityDefinition(Quality.WEBDL2160p) { Weight = 21, MinSize = 0, MaxSize = null }, - new QualityDefinition(Quality.Bluray2160p) { Weight = 22, MinSize = 0, MaxSize = null }, + new QualityDefinition(Quality.HDTV2160p) { Weight = 21, MinSize = 0, MaxSize = null }, + new QualityDefinition(Quality.WEBDL2160p) { Weight = 22, MinSize = 0, MaxSize = null }, + new QualityDefinition(Quality.Bluray2160p) { Weight = 23, MinSize = 0, MaxSize = null }, + new QualityDefinition(Quality.Remux2160p) { Weight = 24, MinSize = 0, MaxSize = null }, - new QualityDefinition(Quality.BRDISK) { Weight = 23, MinSize = 0, MaxSize = null }, - new QualityDefinition(Quality.RAWHD) { Weight = 24, MinSize = 0, MaxSize = null } + new QualityDefinition(Quality.BRDISK) { Weight = 25, MinSize = 0, MaxSize = null }, + new QualityDefinition(Quality.RAWHD) { Weight = 26, MinSize = 0, MaxSize = null } }; }