sonarr-repo-only/NzbDrone.Core/DecisionEngine/Specifications/AllowedReleaseGroupSpecific...

54 lines
1.6 KiB
C#
Raw Normal View History

using System;
using NLog;
2013-02-24 06:48:52 +00:00
using NzbDrone.Core.Configuration;
using NzbDrone.Core.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(IndexerParseResult 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?
//var allowed = _configService.AllowedReleaseGroups;
2013-04-12 23:28:05 +00:00
const string allowed = "";
if (string.IsNullOrWhiteSpace(allowed))
return true;
foreach (var group in allowed.Trim(',', ' ').Split(','))
{
if (subject.ReleaseGroup.Equals(group.Trim(' '), StringComparison.CurrentCultureIgnoreCase))
{
_logger.Trace("Item: {0}'s release group is wanted: {1}", subject, subject.ReleaseGroup);
return true;
}
}
_logger.Trace("Item: {0}'s release group is not wanted: {1}", subject, subject.ReleaseGroup);
return false;
}
}
}