2017-08-14 02:58:42 +00:00
|
|
|
|
using NLog;
|
2014-12-03 01:18:17 +00:00
|
|
|
|
using NzbDrone.Core.Indexers;
|
|
|
|
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
using NzbDrone.Core.Profiles.Delay;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.DecisionEngine.Specifications
|
|
|
|
|
{
|
|
|
|
|
public class ProtocolSpecification : IDecisionEngineSpecification
|
|
|
|
|
{
|
|
|
|
|
private readonly IDelayProfileService _delayProfileService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public ProtocolSpecification(IDelayProfileService delayProfileService,
|
|
|
|
|
Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_delayProfileService = delayProfileService;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 06:54:15 +00:00
|
|
|
|
public RejectionType Type => RejectionType.Permanent;
|
2014-12-03 01:18:17 +00:00
|
|
|
|
|
2017-08-14 02:58:42 +00:00
|
|
|
|
public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria)
|
2014-12-03 01:18:17 +00:00
|
|
|
|
{
|
2017-08-14 02:58:42 +00:00
|
|
|
|
var delayProfile = _delayProfileService.BestForTags(subject.Artist.Tags);
|
2014-12-03 01:18:17 +00:00
|
|
|
|
|
|
|
|
|
if (subject.Release.DownloadProtocol == DownloadProtocol.Usenet && !delayProfile.EnableUsenet)
|
|
|
|
|
{
|
2017-08-14 02:58:42 +00:00
|
|
|
|
_logger.Debug("[{0}] Usenet is not enabled for this artist", subject.Release.Title);
|
|
|
|
|
return Decision.Reject("Usenet is not enabled for this artist");
|
2014-12-03 01:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (subject.Release.DownloadProtocol == DownloadProtocol.Torrent && !delayProfile.EnableTorrent)
|
|
|
|
|
{
|
2017-08-14 02:58:42 +00:00
|
|
|
|
_logger.Debug("[{0}] Torrent is not enabled for this artist", subject.Release.Title);
|
|
|
|
|
return Decision.Reject("Torrent is not enabled for this artist");
|
2014-12-03 01:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Decision.Accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|