From cd310626e9e369151ead3702bfcaa6ab9cdc63b7 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Fri, 6 Jan 2017 14:38:52 +0100 Subject: [PATCH] Parser now recognizes Hardcoded subs. By default these releases are rejected. However, they can still be manually downloaded. --- .../DecisionEngine/DownloadDecisionMaker.cs | 15 ++++++++++++--- src/NzbDrone.Core/Parser/QualityParser.cs | 18 ++++++++++++++++++ src/NzbDrone.Core/Qualities/QualityModel.cs | 1 + 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 198756c9f..5d8ee991b 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -81,9 +81,18 @@ namespace NzbDrone.Core.DecisionEngine } else { - remoteEpisode.DownloadAllowed = true; - //decision = GetDecisionForReport(remoteEpisode, searchCriteria); TODO: Rewrite this for movies! - decision = new DownloadDecision(remoteEpisode); + if (parsedEpisodeInfo.Quality.HardcodedSubs.IsNotNullOrWhiteSpace()) + { + remoteEpisode.DownloadAllowed = true; + decision = new DownloadDecision(remoteEpisode, new Rejection("Hardcoded subs found: " + parsedEpisodeInfo.Quality.HardcodedSubs)); + } + else + { + remoteEpisode.DownloadAllowed = true; + //decision = GetDecisionForReport(remoteEpisode, searchCriteria); TODO: Rewrite this for movies! + decision = new DownloadDecision(remoteEpisode); + } + } } } diff --git a/src/NzbDrone.Core/Parser/QualityParser.cs b/src/NzbDrone.Core/Parser/QualityParser.cs index 7154cd3fd..696b979fb 100644 --- a/src/NzbDrone.Core/Parser/QualityParser.cs +++ b/src/NzbDrone.Core/Parser/QualityParser.cs @@ -28,6 +28,8 @@ namespace NzbDrone.Core.Parser )\b", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); + private static readonly Regex HardcodedSubsRegex = new Regex(@"\b(?(\w+SUB))|(?(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); @@ -59,6 +61,19 @@ namespace NzbDrone.Core.Parser name = name.Trim(); var normalizedName = name.Replace('_', ' ').Trim().ToLower(); var result = ParseQualityModifiers(name, normalizedName); + var subMatch = HardcodedSubsRegex.Matches(normalizedName).OfType().LastOrDefault(); + + if (subMatch != null && subMatch.Success) + { + if (subMatch.Groups["hcsub"].Success) + { + result.HardcodedSubs = subMatch.Groups["hcsub"].Value; + } + else if (subMatch.Groups["hc"].Success) + { + result.HardcodedSubs = "Generic Hardcoded Subs"; + } + } if (RawHDRegex.IsMatch(normalizedName)) { @@ -69,6 +84,7 @@ namespace NzbDrone.Core.Parser var sourceMatch = SourceRegex.Matches(normalizedName).OfType().LastOrDefault(); var resolution = ParseResolution(normalizedName); var codecRegex = CodecRegex.Match(normalizedName); + if (sourceMatch != null && sourceMatch.Success) { @@ -201,6 +217,8 @@ namespace NzbDrone.Core.Parser } } + + //Anime Bluray matching if (AnimeBlurayRegex.Match(normalizedName).Success) diff --git a/src/NzbDrone.Core/Qualities/QualityModel.cs b/src/NzbDrone.Core/Qualities/QualityModel.cs index a483d22c2..2ecc3cb6f 100644 --- a/src/NzbDrone.Core/Qualities/QualityModel.cs +++ b/src/NzbDrone.Core/Qualities/QualityModel.cs @@ -8,6 +8,7 @@ namespace NzbDrone.Core.Qualities { public Quality Quality { get; set; } public Revision Revision { get; set; } + public string HardcodedSubs { get; set; } [JsonIgnore] public QualitySource QualitySource { get; set; }