2013-03-07 03:19:49 +03:00
|
|
|
using System;
|
2013-04-17 06:52:43 +03:00
|
|
|
using System.Linq;
|
2012-08-07 08:24:15 +03:00
|
|
|
using NLog;
|
2013-02-24 09:48:52 +03:00
|
|
|
using NzbDrone.Core.Configuration;
|
2012-08-07 08:24:15 +03:00
|
|
|
using NzbDrone.Core.Model;
|
2013-04-15 04:41:39 +03:00
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
2012-08-07 08:24:15 +03:00
|
|
|
|
2013-03-07 03:19:49 +03:00
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
2012-08-07 08:24:15 +03:00
|
|
|
{
|
2013-04-07 10:30:37 +03:00
|
|
|
public class AllowedReleaseGroupSpecification : IDecisionEngineSpecification
|
2012-08-07 08:24:15 +03:00
|
|
|
{
|
2013-02-24 09:48:52 +03:00
|
|
|
private readonly IConfigService _configService;
|
2013-03-07 03:19:49 +03:00
|
|
|
private readonly Logger _logger;
|
2012-08-07 08:24:15 +03:00
|
|
|
|
2013-03-07 03:19:49 +03:00
|
|
|
public AllowedReleaseGroupSpecification(IConfigService configService, Logger logger)
|
2012-08-07 08:24:15 +03:00
|
|
|
{
|
2013-02-24 09:48:52 +03:00
|
|
|
_configService = configService;
|
2013-03-07 03:19:49 +03:00
|
|
|
_logger = logger;
|
2012-08-07 08:24:15 +03:00
|
|
|
}
|
|
|
|
|
2013-03-07 03:19:49 +03:00
|
|
|
|
|
|
|
public string RejectionReason
|
2012-08-07 08:24:15 +03:00
|
|
|
{
|
2013-03-07 03:19:49 +03:00
|
|
|
get
|
|
|
|
{
|
|
|
|
return "Release group is blacklisted.";
|
|
|
|
}
|
2012-08-07 08:24:15 +03:00
|
|
|
}
|
|
|
|
|
2013-04-15 04:41:39 +03:00
|
|
|
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
|
2012-08-07 08:24:15 +03:00
|
|
|
{
|
2013-03-07 03:19:49 +03:00
|
|
|
_logger.Trace("Beginning release group check for: {0}", subject);
|
2012-08-07 08:24:15 +03:00
|
|
|
|
2013-03-18 18:25:36 +03:00
|
|
|
//Todo: Make this use NzbRestrictions - How should whitelist be used? Will it override blacklist or vice-versa?
|
|
|
|
|
2013-04-17 06:52:43 +03:00
|
|
|
var allowed = _configService.AllowedReleaseGroups;
|
2012-08-07 08:24:15 +03:00
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(allowed))
|
|
|
|
return true;
|
|
|
|
|
2013-04-17 06:52:43 +03:00
|
|
|
var reportReleaseGroup = subject.Report.ReleaseGroup.ToLower();
|
2013-04-15 04:41:39 +03:00
|
|
|
|
2013-04-17 06:52:43 +03:00
|
|
|
return allowed.ToLower().Split(',').Any(allowedGroup => allowedGroup.Trim() == reportReleaseGroup);
|
2013-03-07 03:19:49 +03:00
|
|
|
}
|
2012-08-07 08:24:15 +03:00
|
|
|
}
|
|
|
|
}
|