2013-03-07 00:19:49 +00:00
|
|
|
using System;
|
2012-08-07 05:24:15 +00:00
|
|
|
using NLog;
|
2013-02-24 06:48:52 +00:00
|
|
|
using NzbDrone.Core.Configuration;
|
2012-08-07 05:24:15 +00:00
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
2013-03-07 00:19:49 +00:00
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
2012-08-07 05:24:15 +00:00
|
|
|
{
|
2013-04-07 07:30:37 +00:00
|
|
|
public class AllowedReleaseGroupSpecification : IDecisionEngineSpecification
|
2012-08-07 05:24:15 +00:00
|
|
|
{
|
2013-02-24 06:48:52 +00:00
|
|
|
private readonly IConfigService _configService;
|
2013-03-07 00:19:49 +00:00
|
|
|
private readonly Logger _logger;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
2013-03-07 00:19:49 +00:00
|
|
|
public AllowedReleaseGroupSpecification(IConfigService configService, Logger logger)
|
2012-08-07 05:24:15 +00:00
|
|
|
{
|
2013-02-24 06:48:52 +00:00
|
|
|
_configService = configService;
|
2013-03-07 00:19:49 +00:00
|
|
|
_logger = logger;
|
2012-08-07 05:24:15 +00:00
|
|
|
}
|
|
|
|
|
2013-03-07 00:19:49 +00:00
|
|
|
|
|
|
|
public string RejectionReason
|
2012-08-07 05:24:15 +00:00
|
|
|
{
|
2013-03-07 00:19:49 +00:00
|
|
|
get
|
|
|
|
{
|
|
|
|
return "Release group is blacklisted.";
|
|
|
|
}
|
2012-08-07 05:24:15 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 19:01:24 +00:00
|
|
|
public virtual bool IsSatisfiedBy(IndexerParseResult subject)
|
2012-08-07 05:24:15 +00:00
|
|
|
{
|
2013-03-07 00:19:49 +00:00
|
|
|
_logger.Trace("Beginning release group check for: {0}", subject);
|
2012-08-07 05:24:15 +00:00
|
|
|
|
2013-03-18 15:25:36 +00:00
|
|
|
//Todo: Make this use NzbRestrictions - How should whitelist be used? Will it override blacklist or vice-versa?
|
|
|
|
|
|
|
|
//var allowed = _configService.AllowedReleaseGroups;
|
|
|
|
var allowed = "";
|
2012-08-07 05:24:15 +00:00
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(allowed))
|
|
|
|
return true;
|
|
|
|
|
2013-03-07 00:19:49 +00:00
|
|
|
foreach (var group in allowed.Trim(',', ' ').Split(','))
|
2012-08-07 05:24:15 +00:00
|
|
|
{
|
|
|
|
if (subject.ReleaseGroup.Equals(group.Trim(' '), StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
{
|
2013-03-07 00:19:49 +00:00
|
|
|
_logger.Trace("Item: {0}'s release group is wanted: {1}", subject, subject.ReleaseGroup);
|
2012-08-07 05:24:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2013-03-07 00:19:49 +00:00
|
|
|
|
|
|
|
_logger.Trace("Item: {0}'s release group is not wanted: {1}", subject, subject.ReleaseGroup);
|
2012-08-07 05:24:15 +00:00
|
|
|
return false;
|
2013-03-07 00:19:49 +00:00
|
|
|
}
|
2012-08-07 05:24:15 +00:00
|
|
|
}
|
|
|
|
}
|