1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-30 20:05:41 +00:00
Radarr/NzbDrone.Core/DecisionEngine/Specifications/AllowedReleaseGroupSpecification.cs

48 lines
1.4 KiB
C#
Raw Normal View History

using System;
2013-04-17 03:52:43 +00:00
using System.Linq;
using NLog;
2013-02-24 06:48:52 +00:00
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications
{
2013-04-07 07:30:37 +00:00
public class AllowedReleaseGroupSpecification : IDecisionEngineSpecification
{
2013-02-24 06:48:52 +00:00
private readonly IConfigService _configService;
private readonly Logger _logger;
public AllowedReleaseGroupSpecification(IConfigService configService, Logger logger)
{
2013-02-24 06:48:52 +00:00
_configService = configService;
_logger = logger;
}
public string RejectionReason
{
get
{
return "Release group is blacklisted.";
}
}
public virtual bool IsSatisfiedBy(RemoteEpisode subject)
{
_logger.Trace("Beginning release group check for: {0}", subject);
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;
if (string.IsNullOrWhiteSpace(allowed))
return true;
2013-04-17 03:52:43 +00:00
var reportReleaseGroup = subject.Report.ReleaseGroup.ToLower();
2013-04-17 03:52:43 +00:00
return allowed.ToLower().Split(',').Any(allowedGroup => allowedGroup.Trim() == reportReleaseGroup);
}
}
}