Fixed: Reject full bluray disc releases

Closes #1995
Mark McDowall 7 years ago
parent 6bbdefb11e
commit d4e771117d
No known key found for this signature in database
GPG Key ID: D4CEFA9A718052E0

@ -19,7 +19,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
_remoteEpisode = new RemoteEpisode _remoteEpisode = new RemoteEpisode
{ {
Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent } Release = new ReleaseInfo
{
Title = "Series.title.s01e01",
DownloadProtocol = DownloadProtocol.Torrent
}
}; };
} }
@ -29,7 +33,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
} }
[Test] [Test]
public void should_return_true_if_no_container_specified() public void should_return_true_if_no_container_specified_and_does_not_match_disc_release_pattern()
{ {
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
} }
@ -69,5 +73,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
} }
[TestCase("How the Earth Was Made S02 Disc 1 1080i Blu-ray DTS-HD MA 2.0 AVC-TrollHD")]
[TestCase("The Universe S03 Disc 1 1080p Blu-ray LPCM 2.0 AVC-TrollHD")]
[TestCase("HELL ON WHEELS S02 1080P FULL BLURAY AVC DTS-HD MA 5 1")]
[TestCase("Game.of.Thrones.S06.2016.DISC.3.BluRay.1080p.AVC.Atmos.TrueHD7.1-MTeam")]
[TestCase("Game of Thrones S05 Disc 1 BluRay 1080p AVC Atmos TrueHD 7 1-MTeam")]
public void should_return_false_if_matches_disc_format(string title)
{
_remoteEpisode.Release.Title = title;
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
}
} }
} }

@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using NLog; using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
@ -8,8 +9,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
{ {
public class RawDiskSpecification : IDecisionEngineSpecification public class RawDiskSpecification : IDecisionEngineSpecification
{ {
private static readonly string[] _dvdContainerTypes = new[] { "vob", "iso" }; private static readonly Regex[] DiscRegex = new[]
{
new Regex(@"(?:dis[ck])(?:[-_. ]\d+[-_. ])(?:(?:(?:480|720|1080|2160)[ip]|)[-_. ])?(?:Blu\-?ray)", RegexOptions.Compiled | RegexOptions.IgnoreCase),
new Regex(@"(?:(?:480|720|1080|2160)[ip]|)[-_. ](?:full)[-_. ](?:Blu\-?ray)", RegexOptions.Compiled | RegexOptions.IgnoreCase)
};
private static readonly string[] _dvdContainerTypes = new[] { "vob", "iso" };
private static readonly string[] _blurayContainerTypes = new[] { "m2ts" }; private static readonly string[] _blurayContainerTypes = new[] { "m2ts" };
private readonly Logger _logger; private readonly Logger _logger;
@ -24,7 +30,21 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
{ {
if (subject.Release == null || subject.Release.Container.IsNullOrWhiteSpace()) if (subject.Release == null)
{
return Decision.Accept();
}
foreach (var regex in DiscRegex)
{
if (regex.IsMatch(subject.Release.Title))
{
_logger.Debug("Release contains raw Bluray, rejecting.");
return Decision.Reject("Raw Bluray release");
}
}
if (subject.Release.Container.IsNullOrWhiteSpace())
{ {
return Decision.Accept(); return Decision.Accept();
} }

Loading…
Cancel
Save