2012-08-07 05:24:15 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
2013-02-24 06:48:52 +00:00
|
|
|
|
using NzbDrone.Core.Configuration;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
|
2013-02-19 02:19:38 +00:00
|
|
|
|
namespace NzbDrone.Core.DecisionEngine
|
2012-08-07 05:24:15 +00:00
|
|
|
|
{
|
|
|
|
|
public class AllowedReleaseGroupSpecification
|
|
|
|
|
{
|
2013-02-24 06:48:52 +00:00
|
|
|
|
private readonly IConfigService _configService;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
2013-02-24 06:48:52 +00:00
|
|
|
|
public AllowedReleaseGroupSpecification(IConfigService configService)
|
2012-08-07 05:24:15 +00:00
|
|
|
|
{
|
2013-02-24 06:48:52 +00:00
|
|
|
|
_configService = configService;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2012-08-07 05:24:15 +00:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|