2012-08-07 08:24:15 +03:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
2013-02-19 05:19:38 +03:00
|
|
|
namespace NzbDrone.Core.DecisionEngine
|
2012-08-07 08:24:15 +03:00
|
|
|
{
|
|
|
|
public class AllowedReleaseGroupSpecification
|
|
|
|
{
|
|
|
|
private readonly ConfigProvider _configProvider;
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
public AllowedReleaseGroupSpecification(ConfigProvider configProvider)
|
|
|
|
{
|
|
|
|
_configProvider = configProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AllowedReleaseGroupSpecification()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
|
|
|
{
|
|
|
|
logger.Trace("Beginning release group check for: {0}", subject);
|
|
|
|
|
|
|
|
var allowed = _configProvider.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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|