From 9e6b32ca3ec1f16e54803f6419365b1c68ea18e0 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 6 Dec 2022 23:10:25 -0800 Subject: [PATCH] New: Parsing of 4K GM-TEAM releases --- .../ParserTests/QualityParserFixture.cs | 1 + src/NzbDrone.Core/Parser/QualityParser.cs | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs index ccf1c3855..d5a3ca020 100644 --- a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs @@ -172,6 +172,7 @@ public void should_parse_hdtv1080p_quality(string title, bool proper) [TestCase("My Title - S01E01 - EpTitle [HEVC 4k DTSHD-MA-6ch]", false)] [TestCase("My Title - S01E01 - EpTitle [HEVC-4k DTSHD-MA-6ch]", false)] [TestCase("My Title - S01E01 - EpTitle [4k HEVC DTSHD-MA-6ch]", false)] + [TestCase("[GM-Team][国漫][诛仙][Series Title][2022][19][HEVC][GB][4K]", false)] public void should_parse_hdtv2160p_quality(string title, bool proper) { ParseAndVerifyQuality(title, Quality.HDTV2160p, proper); diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index 4641646a0..6671324cd 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -49,8 +49,8 @@ public class QualityParser private static readonly Regex ResolutionRegex = new Regex(@"\b(?:(?360p)|(?480p|640x480|848x480)|(?540p)|(?576p)|(?720p|1280x720|960p)|(?1080p|1920x1080|1440p|FHD|1080i|4kto1080p)|(?2160p|3840x2160|4k[-_. ](?:UHD|HEVC|BD|H265)|(?:UHD|HEVC|BD|H265)[-_. ]4k))\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); - // Handle cases where no resolution is in the release name; assume if UHD then 4k - private static readonly Regex ImpliedResolutionRegex = new Regex(@"\b(?UHD)\b", + // Handle cases where no resolution is in the release name (assume if UHD then 4k) or resolution is non-standard + private static readonly Regex AlternativeResolutionRegex = new Regex(@"\b(?UHD)\b|(?\[4K\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex CodecRegex = new Regex(@"\b(?:(?x264)|(?h264)|(?XvidHD)|(?Xvid)|(?divx))\b", @@ -558,10 +558,9 @@ public static QualityModel ParseQualityName(string name) private static Resolution ParseResolution(string name) { var match = ResolutionRegex.Match(name); + var alternativeMatch = AlternativeResolutionRegex.Match(name); - var matchimplied = ImpliedResolutionRegex.Match(name); - - if (!match.Success & !matchimplied.Success) + if (!match.Success & !alternativeMatch.Success) { return Resolution.Unknown; } @@ -601,7 +600,7 @@ private static Resolution ParseResolution(string name) return Resolution.R2160p; } - if (matchimplied.Groups["R2160p"].Success) + if (alternativeMatch.Groups["R2160p"].Success) { return Resolution.R2160p; }