mirror of
https://github.com/Readarr/Readarr
synced 2026-05-03 02:01:42 +02:00
42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
using NLog;
|
|
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;
|
|
}
|
|
|
|
public RejectionType Type => RejectionType.Permanent;
|
|
|
|
public virtual Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria)
|
|
{
|
|
var delayProfile = _delayProfileService.BestForTags(subject.Artist.Tags);
|
|
|
|
if (subject.Release.DownloadProtocol == DownloadProtocol.Usenet && !delayProfile.EnableUsenet)
|
|
{
|
|
_logger.Debug("[{0}] Usenet is not enabled for this artist", subject.Release.Title);
|
|
return Decision.Reject("Usenet is not enabled for this artist");
|
|
}
|
|
|
|
if (subject.Release.DownloadProtocol == DownloadProtocol.Torrent && !delayProfile.EnableTorrent)
|
|
{
|
|
_logger.Debug("[{0}] Torrent is not enabled for this artist", subject.Release.Title);
|
|
return Decision.Reject("Torrent is not enabled for this artist");
|
|
}
|
|
|
|
return Decision.Accept();
|
|
}
|
|
}
|
|
}
|