mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-24 16:51:58 +00:00
Reject non-english releases
NzbDrone, now with more rejection built in
This commit is contained in:
parent
7eb522f871
commit
f556f2aaf2
6 changed files with 119 additions and 2 deletions
|
@ -322,6 +322,7 @@ public void parse_series_name(string postTitle, string title)
|
|||
[TestCase("person.of.interest.1x19.ita.720p.bdmux.x264-novarip", LanguageType.Italian)]
|
||||
[TestCase("Salamander.S01E01.FLEMISH.HDTV.x264-BRiGAND", LanguageType.Flemish)]
|
||||
[TestCase("H.Polukatoikia.S03E13.Greek.PDTV.XviD-Ouzo", LanguageType.Greek)]
|
||||
[TestCase("Burn.Notice.S04E15.Brotherly.Love.GERMAN.DUBBED.WS.WEBRiP.XviD.REPACK-TVP", LanguageType.German)]
|
||||
public void parse_language(string postTitle, LanguageType language)
|
||||
{
|
||||
var result = Parser.ParseLanguage(postTitle);
|
||||
|
|
|
@ -56,6 +56,10 @@ public void Setup()
|
|||
Mocker.GetMock<CustomStartDateSpecification>()
|
||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<LanguageSpecification>()
|
||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
private void WithProfileNotAllowed()
|
||||
|
@ -100,6 +104,13 @@ private void WithAiredBeforeCustomStartDateCutoff()
|
|||
.Returns(false);
|
||||
}
|
||||
|
||||
private void WithLanguageNotWanted()
|
||||
{
|
||||
Mocker.GetMock<LanguageSpecification>()
|
||||
.Setup(c => c.IsSatisfiedBy(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_allowed_if_all_conditions_are_met()
|
||||
{
|
||||
|
@ -158,5 +169,13 @@ public void should_not_be_allowed_if_none_of_conditions_are_met()
|
|||
|
||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionType.QualityNotWanted);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_allowed_if_language_is_not_wanted()
|
||||
{
|
||||
WithLanguageNotWanted();
|
||||
|
||||
spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionType.LanguageNotWanted);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Providers.DecisionEngine;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class LanguageSpecificationFixture : CoreTest
|
||||
{
|
||||
private EpisodeParseResult parseResult;
|
||||
|
||||
private void WithEnglishRelease()
|
||||
{
|
||||
parseResult = Builder<EpisodeParseResult>
|
||||
.CreateNew()
|
||||
.With(p => p.Language = LanguageType.English)
|
||||
.Build();
|
||||
}
|
||||
|
||||
private void WithGermanRelease()
|
||||
{
|
||||
parseResult = Builder<EpisodeParseResult>
|
||||
.CreateNew()
|
||||
.With(p => p.Language = LanguageType.German)
|
||||
.Build();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_language_is_english()
|
||||
{
|
||||
WithEnglishRelease();
|
||||
|
||||
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_language_is_german()
|
||||
{
|
||||
WithGermanRelease();
|
||||
|
||||
Mocker.Resolve<LanguageSpecification>().IsSatisfiedBy(parseResult).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ public enum ReportRejectionType
|
|||
Skipped = 11,
|
||||
Failure = 12,
|
||||
ReleaseGroupNotWanted = 13,
|
||||
AiredAfterCustomStartDate = 14
|
||||
AiredAfterCustomStartDate = 14,
|
||||
LanguageNotWanted = 15
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,12 +14,14 @@ public class AllowedDownloadSpecification
|
|||
private readonly RetentionSpecification _retentionSpecification;
|
||||
private readonly AllowedReleaseGroupSpecification _allowedReleaseGroupSpecification;
|
||||
private readonly CustomStartDateSpecification _customStartDateSpecification;
|
||||
private readonly LanguageSpecification _languageSpecification;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification,
|
||||
UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification,
|
||||
AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification,
|
||||
AllowedReleaseGroupSpecification allowedReleaseGroupSpecification, CustomStartDateSpecification customStartDateSpecification)
|
||||
AllowedReleaseGroupSpecification allowedReleaseGroupSpecification, CustomStartDateSpecification customStartDateSpecification,
|
||||
LanguageSpecification languageSpecification)
|
||||
{
|
||||
_qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification;
|
||||
_upgradeDiskSpecification = upgradeDiskSpecification;
|
||||
|
@ -28,6 +30,7 @@ public AllowedDownloadSpecification(QualityAllowedByProfileSpecification quality
|
|||
_retentionSpecification = retentionSpecification;
|
||||
_allowedReleaseGroupSpecification = allowedReleaseGroupSpecification;
|
||||
_customStartDateSpecification = customStartDateSpecification;
|
||||
_languageSpecification = languageSpecification;
|
||||
}
|
||||
|
||||
public AllowedDownloadSpecification()
|
||||
|
@ -39,6 +42,7 @@ public virtual ReportRejectionType IsSatisfiedBy(EpisodeParseResult subject)
|
|||
if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.QualityNotWanted;
|
||||
if (!_customStartDateSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.AiredAfterCustomStartDate;
|
||||
if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.ExistingQualityIsEqualOrBetter;
|
||||
if (!_languageSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.LanguageNotWanted;
|
||||
if (!_retentionSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.Retention;
|
||||
if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.Size;
|
||||
if (!_allowedReleaseGroupSpecification.IsSatisfiedBy(subject)) return ReportRejectionType.ReleaseGroupNotWanted;
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
namespace NzbDrone.Core.Providers.DecisionEngine
|
||||
{
|
||||
public class LanguageSpecification
|
||||
{
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public LanguageSpecification(ConfigProvider configProvider)
|
||||
{
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public LanguageSpecification()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
logger.Trace("Checking if report meets language requirements. {0}", subject.Language);
|
||||
if (subject.Language != LanguageType.English)
|
||||
{
|
||||
logger.Trace("Report Language: {0} rejected because it is not english", subject.Language);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue