New: Ability to set minimum seeders on a per indexer basis

This commit is contained in:
Qstick 2017-10-25 22:30:31 -04:00
parent 28d5fbe409
commit 5bee842b26
14 changed files with 116 additions and 55 deletions

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -1,6 +1,5 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
using System.Text.RegularExpressions;
@ -16,13 +15,13 @@ namespace NzbDrone.Core.Indexers.Gazelle
}
}
public class GazelleSettings : IIndexerSettings
public class GazelleSettings : ITorrentIndexerSettings
{
private static readonly GazelleSettingsValidator Validator = new GazelleSettingsValidator();
public GazelleSettings()
{
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
}
public string AuthKey;
@ -37,6 +36,9 @@ namespace NzbDrone.Core.Indexers.Gazelle
[FieldDefinition(2, Label = "Password", Type = FieldType.Password, HelpText = "Password")]
public string Password { get; set; }
[FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -2,7 +2,6 @@ using System.Text.RegularExpressions;
using FluentValidation;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.IPTorrents
@ -21,17 +20,21 @@ namespace NzbDrone.Core.Indexers.IPTorrents
}
}
public class IPTorrentsSettings : IIndexerSettings
public class IPTorrentsSettings : ITorrentIndexerSettings
{
private static readonly IPTorrentsSettingsValidator Validator = new IPTorrentsSettingsValidator();
public IPTorrentsSettings()
{
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
}
[FieldDefinition(0, Label = "Feed URL", HelpText = "The full RSS feed url generated by IPTorrents, using only the categories you selected (HD, SD, x264, etc ...)")]
public string BaseUrl { get; set; }
[FieldDefinition(1, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -0,0 +1,7 @@
namespace NzbDrone.Core.Indexers
{
public interface ITorrentIndexerSettings : IIndexerSettings
{
int MinimumSeeders { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace NzbDrone.Core.Indexers
{
public static class IndexerDefaults
{
public const int MINIMUM_SEEDERS = 1;
}
}

View File

@ -5,7 +5,6 @@ using FluentValidation;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Newznab
@ -75,6 +74,9 @@ namespace NzbDrone.Core.Indexers.Newznab
[FieldDefinition(4, Label = "Additional Parameters", HelpText = "Additional Newznab parameters", Advanced = true)]
public string AdditionalParameters { get; set; }
// Field 5 is used by TorznabSettings MinimumSeeders
// If you need to add another field here, update TorznabSettings as well and this comment
public virtual NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -1,6 +1,5 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
using System.Text.RegularExpressions;
namespace NzbDrone.Core.Indexers.Nyaa
@ -14,7 +13,7 @@ namespace NzbDrone.Core.Indexers.Nyaa
}
}
public class NyaaSettings : IIndexerSettings
public class NyaaSettings : ITorrentIndexerSettings
{
private static readonly NyaaSettingsValidator Validator = new NyaaSettingsValidator();
@ -22,6 +21,7 @@ namespace NzbDrone.Core.Indexers.Nyaa
{
BaseUrl = "https://www.nyaa.se";
AdditionalParameters = "&cats=1_37&filter=1";
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
}
[FieldDefinition(0, Label = "Website URL")]
@ -30,6 +30,9 @@ namespace NzbDrone.Core.Indexers.Nyaa
[FieldDefinition(1, Label = "Additional Parameters", Advanced = true, HelpText = "Please note if you change the category you will have to add required/restricted rules about the subgroups to avoid foreign language releases.")]
public string AdditionalParameters { get; set; }
[FieldDefinition(2, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -1,6 +1,5 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Rarbg
@ -13,7 +12,7 @@ namespace NzbDrone.Core.Indexers.Rarbg
}
}
public class RarbgSettings : IIndexerSettings
public class RarbgSettings : ITorrentIndexerSettings
{
private static readonly RarbgSettingsValidator Validator = new RarbgSettingsValidator();
@ -21,6 +20,7 @@ namespace NzbDrone.Core.Indexers.Rarbg
{
BaseUrl = "https://torrentapi.org";
RankedOnly = false;
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
}
[FieldDefinition(0, Label = "API URL", HelpText = "URL to Rarbg api, not the website.")]
@ -32,6 +32,9 @@ namespace NzbDrone.Core.Indexers.Rarbg
[FieldDefinition(2, Type = FieldType.Captcha, Label = "CAPTCHA Token", HelpText = "CAPTCHA Clearance token used to handle CloudFlare Anti-DDOS measures on shared-ip VPNs.")]
public string CaptchaToken { get; set; }
[FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -1,6 +1,5 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.TorrentRss
@ -13,7 +12,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
}
}
public class TorrentRssIndexerSettings : IIndexerSettings
public class TorrentRssIndexerSettings : ITorrentIndexerSettings
{
private static readonly TorrentRssIndexerSettingsValidator validator = new TorrentRssIndexerSettingsValidator();
@ -21,6 +20,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
{
BaseUrl = string.Empty;
AllowZeroSize = false;
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
}
[FieldDefinition(0, Label = "Full RSS Feed URL")]
@ -32,6 +32,9 @@ namespace NzbDrone.Core.Indexers.TorrentRss
[FieldDefinition(2, Type = FieldType.Checkbox, Label = "Allow Zero Size", HelpText="Enabling this will allow you to use feeds that don't specify release size, but be careful, size related checks will not be performed.")]
public bool AllowZeroSize { get; set; }
[FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(validator.Validate(this));

View File

@ -1,6 +1,5 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Torrentleech
@ -14,13 +13,14 @@ namespace NzbDrone.Core.Indexers.Torrentleech
}
}
public class TorrentleechSettings : IIndexerSettings
public class TorrentleechSettings : ITorrentIndexerSettings
{
private static readonly TorrentleechSettingsValidator Validator = new TorrentleechSettingsValidator();
public TorrentleechSettings()
{
BaseUrl = "http://rss.torrentleech.org";
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
}
[FieldDefinition(0, Label = "Website URL")]
@ -29,6 +29,9 @@ namespace NzbDrone.Core.Indexers.Torrentleech
[FieldDefinition(1, Label = "API Key")]
public string ApiKey { get; set; }
[FieldDefinition(2, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -3,6 +3,7 @@ using System.Text.RegularExpressions;
using FluentValidation;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Validation;
@ -46,10 +47,18 @@ namespace NzbDrone.Core.Indexers.Torznab
}
}
public class TorznabSettings : NewznabSettings
public class TorznabSettings : NewznabSettings, ITorrentIndexerSettings
{
private static readonly TorznabSettingsValidator Validator = new TorznabSettingsValidator();
public TorznabSettings()
{
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
}
[FieldDefinition(5, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get; set; }
public override NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View File

@ -1,7 +1,6 @@
using System.Text.RegularExpressions;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Waffles
@ -16,13 +15,14 @@ namespace NzbDrone.Core.Indexers.Waffles
}
}
public class WafflesSettings : IIndexerSettings
public class WafflesSettings : ITorrentIndexerSettings
{
private static readonly WafflesSettingsValidator Validator = new WafflesSettingsValidator();
public WafflesSettings()
{
BaseUrl = "https://www.waffles.ch";
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
}
[FieldDefinition(0, Label = "Website URL")]
@ -34,6 +34,9 @@ namespace NzbDrone.Core.Indexers.Waffles
[FieldDefinition(2, Label = "RSS Passkey")]
public string RssPasskey { get; set; }
[FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get; set; }
public NzbDroneValidationResult Validate()
{

View File

@ -220,7 +220,7 @@
<Compile Include="DecisionEngine\Specifications\Search\SeasonMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\ArtistSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\SingleAlbumSearchMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\TorrentSeedingSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\TorrentSeedingSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\SameTracksGrabSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\RawDiskSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" />
@ -495,6 +495,8 @@
<Compile Include="Indexers\Gazelle\GazelleRequestGenerator.cs" />
<Compile Include="Indexers\Gazelle\GazelleSettings.cs" />
<Compile Include="Indexers\IIndexerSettings.cs" />
<Compile Include="Indexers\IndexerDefaults.cs" />
<Compile Include="Indexers\ITorrentIndexerSettings.cs" />
<Compile Include="Indexers\Waffles\WafflesRssParser.cs" />
<Compile Include="Indexers\Waffles\Waffles.cs" />
<Compile Include="Indexers\Waffles\WafflesRequestGenerator.cs" />