From c7d445d1c1beb453f2ec4d351cfeddb5090e1271 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 23 Jul 2016 21:32:07 +0200 Subject: [PATCH] New: Added raw DVD check for BTN to prevent those pesky VIDEO_TS downloads. fixes #r1377 --- .../DvdSpecificationFixture.cs | 74 +++++++++++++++++++ .../BroadcastheNetFixture.cs | 6 ++ .../NzbDrone.Core.Test.csproj | 1 + .../Specifications/DvdSpecification.cs | 38 ++++++++++ .../BroadcastheNet/BroadcastheNetParser.cs | 6 ++ src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs | 6 ++ 7 files changed, 132 insertions(+) create mode 100644 src/NzbDrone.Core.Test/DecisionEngineTests/DvdSpecificationFixture.cs create mode 100644 src/NzbDrone.Core/DecisionEngine/Specifications/DvdSpecification.cs diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/DvdSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/DvdSpecificationFixture.cs new file mode 100644 index 000000000..209917502 --- /dev/null +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/DvdSpecificationFixture.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.DecisionEngine.Specifications; +using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Profiles; +using NzbDrone.Core.Qualities; +using NzbDrone.Core.Tv; +using NzbDrone.Core.DecisionEngine; + +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Indexers; + +namespace NzbDrone.Core.Test.DecisionEngineTests +{ + [TestFixture] + + public class DvdSpecificationFixture : CoreTest + { + private RemoteEpisode _remoteEpisode; + + [SetUp] + public void Setup() + { + _remoteEpisode = new RemoteEpisode + { + Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent } + }; + } + + private void WithContainer(string container) + { + _remoteEpisode.Release.Container = container; + } + + [Test] + public void should_return_true_if_no_container_specified() + { + Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + } + + [Test] + public void should_return_true_if_mkv() + { + WithContainer("MKV"); + Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue(); + } + + [Test] + public void should_return_false_if_vob() + { + WithContainer("VOB"); + Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + } + + [Test] + public void should_return_false_if_iso() + { + WithContainer("ISO"); + Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + } + + [Test] + public void should_compare_case_insensitive() + { + WithContainer("vob"); + Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse(); + } + + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/IndexerTests/BroadcastheNetTests/BroadcastheNetFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/BroadcastheNetTests/BroadcastheNetFixture.cs index 0945eef82..a22ba44e3 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/BroadcastheNetTests/BroadcastheNetFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/BroadcastheNetTests/BroadcastheNetFixture.cs @@ -56,6 +56,12 @@ namespace NzbDrone.Core.Test.IndexerTests.BroadcastheNetTests torrentInfo.MagnetUrl.Should().BeNullOrEmpty(); torrentInfo.Peers.Should().Be(40+9); torrentInfo.Seeders.Should().Be(40); + + torrentInfo.Origin.Should().Be("Scene"); + torrentInfo.Source.Should().Be("HDTV"); + torrentInfo.Container.Should().Be("MP4"); + torrentInfo.Codec.Should().Be("x264"); + torrentInfo.Resolution.Should().Be("SD"); } private void VerifyBackOff() diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 6ec1b76fa..f4e45987d 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -156,6 +156,7 @@ + diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/DvdSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/DvdSpecification.cs new file mode 100644 index 000000000..d265b2813 --- /dev/null +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/DvdSpecification.cs @@ -0,0 +1,38 @@ +using System.Linq; +using NLog; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.DecisionEngine.Specifications +{ + public class DvdSpecification : IDecisionEngineSpecification + { + private static readonly string[] _dvdContainerTypes = new[] { "vob", "iso" }; + + private readonly Logger _logger; + + public DvdSpecification(Logger logger) + { + _logger = logger; + } + + public RejectionType Type { get { return RejectionType.Permanent; } } + + public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria) + { + if (subject.Release == null || subject.Release.Container.IsNullOrWhiteSpace()) + { + return Decision.Accept(); + } + + if (_dvdContainerTypes.Contains(subject.Release.Container.ToLower())) + { + _logger.Debug("Release contains raw DVD, rejecting."); + return Decision.Reject("Raw DVD release"); + } + + return Decision.Accept(); + } + } +} diff --git a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs index 35b2ed8f1..9d126da54 100644 --- a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs +++ b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetParser.cs @@ -76,6 +76,12 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet torrentInfo.Seeders = torrent.Seeders; torrentInfo.Peers = torrent.Leechers + torrent.Seeders; + torrentInfo.Origin = torrent.Origin; + torrentInfo.Source = torrent.Source; + torrentInfo.Container = torrent.Container; + torrentInfo.Codec = torrent.Codec; + torrentInfo.Resolution = torrent.Resolution; + results.Add(torrentInfo); } diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 8167afd3e..23856c85f 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -333,6 +333,7 @@ + diff --git a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs index 6846dc882..7c1680196 100644 --- a/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ReleaseInfo.cs @@ -19,6 +19,12 @@ namespace NzbDrone.Core.Parser.Model public int TvRageId { get; set; } public DateTime PublishDate { get; set; } + public string Origin { get; set; } + public string Source { get; set; } + public string Container { get; set; } + public string Codec { get; set; } + public string Resolution { get; set; } + public int Age { get