|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
@ -25,24 +26,33 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|
|
|
|
{
|
|
|
|
|
var torrentInfo = subject.Release;
|
|
|
|
|
|
|
|
|
|
if (torrentInfo == null || torrentInfo.IndexerSettings == null)
|
|
|
|
|
|
|
|
|
|
IIndexerSettings indexerSettings = null;
|
|
|
|
|
try {
|
|
|
|
|
indexerSettings = _indexerFactory.Get(subject.Release.IndexerId)?.Settings as IIndexerSettings;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
return Decision.Accept();
|
|
|
|
|
_logger.Debug("Indexer with id {0} does not exist, skipping required indexer flags specs.", subject.Release.IndexerId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var torrentIndexerSettings = torrentInfo.IndexerSettings as ITorrentIndexerSettings;
|
|
|
|
|
if (torrentInfo == null || indexerSettings == null)
|
|
|
|
|
{
|
|
|
|
|
return Decision.Accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (torrentIndexerSettings != null)
|
|
|
|
|
if (indexerSettings is ITorrentIndexerSettings torrentIndexerSettings)
|
|
|
|
|
{
|
|
|
|
|
var requiredFlags = torrentIndexerSettings.RequiredFlags;
|
|
|
|
|
var requiredFlag = (IndexerFlags) 0;
|
|
|
|
|
|
|
|
|
|
if (requiredFlags == null || requiredFlags.Count() == 0)
|
|
|
|
|
var enumerable = requiredFlags.ToList();
|
|
|
|
|
if (requiredFlags == null || !enumerable.Any())
|
|
|
|
|
{
|
|
|
|
|
return Decision.Accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var flag in requiredFlags)
|
|
|
|
|
|
|
|
|
|
foreach (var flag in enumerable)
|
|
|
|
|
{
|
|
|
|
|
if (torrentInfo.IndexerFlags.HasFlag((IndexerFlags)flag))
|
|
|
|
|
{
|
|
|
|
@ -50,7 +60,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|
|
|
|
}
|
|
|
|
|
requiredFlag |= (IndexerFlags)flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Debug("None of the required indexer flags {0} where found. Found flags: {1}", requiredFlag, torrentInfo.IndexerFlags);
|
|
|
|
|
return Decision.Reject("None of the required indexer flags {0} where found. Found flags: {1}", requiredFlag, torrentInfo.IndexerFlags);
|
|
|
|
|
}
|
|
|
|
|