2013-03-07 00:19:49 +00:00
|
|
|
using System;
|
2013-04-17 03:52:43 +00:00
|
|
|
using System.Linq;
|
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-04-15 01:41:39 +00:00
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
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-15 01:41:39 +00:00
|
|
|
public virtual bool IsSatisfiedBy(RemoteEpisode 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?
|
|
|
|
|
2013-04-17 03:52:43 +00:00
|
|
|
var allowed = _configService.AllowedReleaseGroups;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(allowed))
|
|
|
|
return true;
|
|
|
|
|
2013-04-17 03:52:43 +00:00
|
|
|
var reportReleaseGroup = subject.Report.ReleaseGroup.ToLower();
|
2013-04-15 01:41:39 +00:00
|
|
|
|
2013-04-17 03:52:43 +00:00
|
|
|
return allowed.ToLower().Split(',').Any(allowedGroup => allowedGroup.Trim() == reportReleaseGroup);
|
2013-03-07 00:19:49 +00:00
|
|
|
}
|
2012-08-07 05:24:15 +00:00
|
|
|
}
|
|
|
|
}
|