You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.7 KiB
58 lines
1.7 KiB
12 years ago
|
using System;
|
||
|
using System.Linq;
|
||
|
using NLog;
|
||
|
using NzbDrone.Core.Configuration;
|
||
|
using NzbDrone.Core.Model;
|
||
|
using NzbDrone.Core.Parser;
|
||
|
using NzbDrone.Core.Parser.Model;
|
||
|
|
||
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||
|
{
|
||
12 years ago
|
public class NotRestrictedReleaseSpecification : IDecisionEngineSpecification
|
||
12 years ago
|
{
|
||
|
private readonly IConfigService _configService;
|
||
|
private readonly Logger _logger;
|
||
|
|
||
12 years ago
|
public NotRestrictedReleaseSpecification(IConfigService configService, Logger logger)
|
||
12 years ago
|
{
|
||
|
_configService = configService;
|
||
|
_logger = logger;
|
||
|
}
|
||
|
|
||
|
public string RejectionReason
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return "Contrains restricted term.";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
|
||
|
{
|
||
12 years ago
|
_logger.Trace("Checking if release contains any restricted terms: {0}", subject);
|
||
12 years ago
|
|
||
12 years ago
|
var restrictionsString = _configService.ReleaseRestrictions;
|
||
12 years ago
|
|
||
|
if (String.IsNullOrWhiteSpace(restrictionsString))
|
||
|
{
|
||
|
_logger.Trace("No restrictions configured, allowing: {0}", subject);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
var restrictions = restrictionsString.Split('\n');
|
||
|
|
||
|
foreach (var restriction in restrictions)
|
||
|
{
|
||
12 years ago
|
if (subject.Report.Title.ToLowerInvariant().Contains(restriction.ToLowerInvariant()))
|
||
12 years ago
|
{
|
||
|
_logger.Trace("{0} is restricted: {1}", subject, restriction);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
_logger.Trace("No restrictions apply, allowing: {0}", subject);
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|