Sonarr/NzbDrone.Core/DecisionEngine/AllowedReleaseGroupSpecific...

48 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Linq;
using NLog;
2013-02-24 06:48:52 +00:00
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
2013-02-19 02:19:38 +00:00
namespace NzbDrone.Core.DecisionEngine
{
public class AllowedReleaseGroupSpecification
{
2013-02-24 06:48:52 +00:00
private readonly IConfigService _configService;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
2013-02-24 06:48:52 +00:00
public AllowedReleaseGroupSpecification(IConfigService configService)
{
2013-02-24 06:48:52 +00:00
_configService = configService;
}
public AllowedReleaseGroupSpecification()
{
}
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
logger.Trace("Beginning release group check for: {0}", subject);
2013-02-24 06:48:52 +00:00
var allowed = _configService.AllowedReleaseGroups;
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;
}
}
}