parent
28d5fbe409
commit
5bee842b26
@ -1,37 +0,0 @@
|
|||||||
using NLog;
|
|
||||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
|
||||||
using NzbDrone.Core.Parser.Model;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
|
||||||
{
|
|
||||||
public class TorrentSeedingSpecification : IDecisionEngineSpecification
|
|
||||||
{
|
|
||||||
private readonly Logger _logger;
|
|
||||||
|
|
||||||
public TorrentSeedingSpecification(Logger logger)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpecificationPriority Priority => SpecificationPriority.Default;
|
|
||||||
public RejectionType Type => RejectionType.Permanent;
|
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria)
|
|
||||||
{
|
|
||||||
var torrentInfo = remoteAlbum.Release as TorrentInfo;
|
|
||||||
|
|
||||||
if (torrentInfo == null)
|
|
||||||
{
|
|
||||||
return Decision.Accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (torrentInfo.Seeders != null && torrentInfo.Seeders < 1)
|
|
||||||
{
|
|
||||||
_logger.Debug("Not enough seeders. ({0})", torrentInfo.Seeders);
|
|
||||||
return Decision.Reject("Not enough seeders. ({0})", torrentInfo.Seeders);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Decision.Accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,51 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Common.Reflection;
|
||||||
|
using NzbDrone.Core.Indexers;
|
||||||
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
||||||
|
{
|
||||||
|
public class TorrentSeedingSpecification : IDecisionEngineSpecification
|
||||||
|
{
|
||||||
|
private readonly IndexerFactory _indexerFactory;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
public TorrentSeedingSpecification(IndexerFactory indexerFactory, Logger logger)
|
||||||
|
{
|
||||||
|
_indexerFactory = indexerFactory;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpecificationPriority Priority => SpecificationPriority.Default;
|
||||||
|
public RejectionType Type => RejectionType.Permanent;
|
||||||
|
|
||||||
|
|
||||||
|
public Decision IsSatisfiedBy(RemoteAlbum remoteAlbum, SearchCriteriaBase searchCriteria)
|
||||||
|
{
|
||||||
|
var torrentInfo = remoteAlbum.Release as TorrentInfo;
|
||||||
|
|
||||||
|
if (torrentInfo == null)
|
||||||
|
{
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
var indexer = _indexerFactory.Get(torrentInfo.IndexerId);
|
||||||
|
var torrentIndexerSettings = indexer.Settings as ITorrentIndexerSettings;
|
||||||
|
|
||||||
|
if (torrentIndexerSettings != null)
|
||||||
|
{
|
||||||
|
var minimumSeeders = torrentIndexerSettings.MinimumSeeders;
|
||||||
|
|
||||||
|
if (torrentInfo.Seeders.HasValue && torrentInfo.Seeders.Value < minimumSeeders)
|
||||||
|
{
|
||||||
|
_logger.Debug("Not enough seeders: {0}. Minimum seeders: {1}", torrentInfo.Seeders, minimumSeeders);
|
||||||
|
return Decision.Reject("Not enough seeders: {0}. Minimum seeders: {1}", torrentInfo.Seeders, minimumSeeders);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace NzbDrone.Core.Indexers
|
||||||
|
{
|
||||||
|
public interface ITorrentIndexerSettings : IIndexerSettings
|
||||||
|
{
|
||||||
|
int MinimumSeeders { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace NzbDrone.Core.Indexers
|
||||||
|
{
|
||||||
|
public static class IndexerDefaults
|
||||||
|
{
|
||||||
|
public const int MINIMUM_SEEDERS = 1;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue