mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Added: Allow minimum seeders to be set on a per indexer basis. Pulled from Sonarr Upstream (#1624)
This commit is contained in:
parent
a460e89a8d
commit
9f4ce50dd6
@ -0,0 +1,111 @@
|
|||||||
|
using FizzWare.NBuilder;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.DecisionEngine.Specifications.Search;
|
||||||
|
using NzbDrone.Core.Indexers;
|
||||||
|
using NzbDrone.Core.Indexers.TorrentRss;
|
||||||
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TorrentSeedingSpecificationFixture : TestBase<TorrentSeedingSpecification>
|
||||||
|
{
|
||||||
|
private Series _series;
|
||||||
|
private RemoteEpisode _remoteEpisode;
|
||||||
|
private IndexerDefinition _indexerDefinition;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
_series = Builder<Series>.CreateNew().With(s => s.Id = 1).Build();
|
||||||
|
|
||||||
|
_remoteEpisode = new RemoteEpisode
|
||||||
|
{
|
||||||
|
Series = _series,
|
||||||
|
Release = new TorrentInfo
|
||||||
|
{
|
||||||
|
IndexerId = 1,
|
||||||
|
Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp",
|
||||||
|
Seeders = 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_indexerDefinition = new IndexerDefinition
|
||||||
|
{
|
||||||
|
Settings = new TorrentRssIndexerSettings { MinimumSeeders = 5 }
|
||||||
|
};
|
||||||
|
|
||||||
|
Mocker.GetMock<IIndexerFactory>()
|
||||||
|
.Setup(v => v.Get(1))
|
||||||
|
.Returns(_indexerDefinition);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenReleaseSeeders(int? seeders)
|
||||||
|
{
|
||||||
|
(_remoteEpisode.Release as TorrentInfo).Seeders = seeders;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_if_not_torrent()
|
||||||
|
{
|
||||||
|
_remoteEpisode.Release = new ReleaseInfo
|
||||||
|
{
|
||||||
|
IndexerId = 1,
|
||||||
|
Title = "Series.Title.S01.720p.BluRay.X264-RlsGrp"
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_if_indexer_not_specified()
|
||||||
|
{
|
||||||
|
_remoteEpisode.Release.IndexerId = 0;
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_if_indexer_no_longer_exists()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IIndexerFactory>()
|
||||||
|
.Setup(v => v.Get(It.IsAny<int>()))
|
||||||
|
.Callback<int>(i => { throw new ModelNotFoundException(typeof(IndexerDefinition), i); });
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_return_true_if_seeds_unknown()
|
||||||
|
{
|
||||||
|
GivenReleaseSeeders(null);
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(5)]
|
||||||
|
[TestCase(6)]
|
||||||
|
public void should_return_true_if_seeds_above_or_equal_to_limit(int seeders)
|
||||||
|
{
|
||||||
|
GivenReleaseSeeders(seeders);
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(0)]
|
||||||
|
[TestCase(4)]
|
||||||
|
public void should_return_false_if_seeds_belove_limit(int seeders)
|
||||||
|
{
|
||||||
|
GivenReleaseSeeders(seeders);
|
||||||
|
|
||||||
|
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ public void Setup()
|
|||||||
Subject.Definition = new IndexerDefinition()
|
Subject.Definition = new IndexerDefinition()
|
||||||
{
|
{
|
||||||
Name = "IPTorrents",
|
Name = "IPTorrents",
|
||||||
Settings = new IPTorrentsSettings() { Url = "http://fake.com/" }
|
Settings = new IPTorrentsSettings() { BaseUrl = "http://fake.com/" }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public void SetUp()
|
|||||||
{
|
{
|
||||||
_settings = new NewznabSettings()
|
_settings = new NewznabSettings()
|
||||||
{
|
{
|
||||||
Url = "http://indxer.local"
|
BaseUrl = "http://indxer.local"
|
||||||
};
|
};
|
||||||
|
|
||||||
_caps = ReadAllText("Files/Indexers/Newznab/newznab_caps.xml");
|
_caps = ReadAllText("Files/Indexers/Newznab/newznab_caps.xml");
|
||||||
|
@ -24,7 +24,7 @@ public void Setup()
|
|||||||
Name = "Newznab",
|
Name = "Newznab",
|
||||||
Settings = new NewznabSettings()
|
Settings = new NewznabSettings()
|
||||||
{
|
{
|
||||||
Url = "http://indexer.local/",
|
BaseUrl = "http://indexer.local/",
|
||||||
Categories = new int[] { 1 }
|
Categories = new int[] { 1 }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,7 @@ public void SetUp()
|
|||||||
{
|
{
|
||||||
Subject.Settings = new NewznabSettings()
|
Subject.Settings = new NewznabSettings()
|
||||||
{
|
{
|
||||||
Url = "http://127.0.0.1:1234/",
|
BaseUrl = "http://127.0.0.1:1234/",
|
||||||
Categories = new [] { 1, 2 },
|
Categories = new [] { 1, 2 },
|
||||||
AnimeCategories = new [] { 3, 4 },
|
AnimeCategories = new [] { 3, 4 },
|
||||||
ApiKey = "abcd",
|
ApiKey = "abcd",
|
||||||
|
@ -15,7 +15,7 @@ public void requires_apikey(string url)
|
|||||||
var setting = new NewznabSettings()
|
var setting = new NewznabSettings()
|
||||||
{
|
{
|
||||||
ApiKey = "",
|
ApiKey = "",
|
||||||
Url = url
|
BaseUrl = url
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -32,13 +32,13 @@ public void invalid_url_should_not_apikey(string url)
|
|||||||
var setting = new NewznabSettings
|
var setting = new NewznabSettings
|
||||||
{
|
{
|
||||||
ApiKey = "",
|
ApiKey = "",
|
||||||
Url = url
|
BaseUrl = url
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
setting.Validate().IsValid.Should().BeFalse();
|
setting.Validate().IsValid.Should().BeFalse();
|
||||||
setting.Validate().Errors.Should().NotContain(c => c.PropertyName == "ApiKey");
|
setting.Validate().Errors.Should().NotContain(c => c.PropertyName == "ApiKey");
|
||||||
setting.Validate().Errors.Should().Contain(c => c.PropertyName == "Url");
|
setting.Validate().Errors.Should().Contain(c => c.PropertyName == "BaseUrl");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public void doesnt_requires_apikey(string url)
|
|||||||
var setting = new NewznabSettings()
|
var setting = new NewznabSettings()
|
||||||
{
|
{
|
||||||
ApiKey = "",
|
ApiKey = "",
|
||||||
Url = url
|
BaseUrl = url
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public void Setup()
|
|||||||
Name = "Torznab",
|
Name = "Torznab",
|
||||||
Settings = new TorznabSettings()
|
Settings = new TorznabSettings()
|
||||||
{
|
{
|
||||||
Url = "http://indexer.local/",
|
BaseUrl = "http://indexer.local/",
|
||||||
Categories = new int[] { 1 }
|
Categories = new int[] { 1 }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -159,6 +159,7 @@
|
|||||||
<Compile Include="DecisionEngineTests\RetentionSpecificationFixture.cs" />
|
<Compile Include="DecisionEngineTests\RetentionSpecificationFixture.cs" />
|
||||||
<Compile Include="DecisionEngineTests\RssSync\DelaySpecificationFixture.cs" />
|
<Compile Include="DecisionEngineTests\RssSync\DelaySpecificationFixture.cs" />
|
||||||
<Compile Include="DecisionEngineTests\RssSync\ProperSpecificationFixture.cs" />
|
<Compile Include="DecisionEngineTests\RssSync\ProperSpecificationFixture.cs" />
|
||||||
|
<Compile Include="DecisionEngineTests\Search\TorrentSeedingSpecificationFixture.cs" />
|
||||||
<Compile Include="DecisionEngineTests\Search\SeriesSpecificationFixture.cs" />
|
<Compile Include="DecisionEngineTests\Search\SeriesSpecificationFixture.cs" />
|
||||||
<Compile Include="DecisionEngineTests\SameEpisodesSpecificationFixture.cs" />
|
<Compile Include="DecisionEngineTests\SameEpisodesSpecificationFixture.cs" />
|
||||||
<Compile Include="DecisionEngineTests\RawDiskSpecificationFixture.cs" />
|
<Compile Include="DecisionEngineTests\RawDiskSpecificationFixture.cs" />
|
||||||
|
@ -1,55 +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 RejectionType Type => RejectionType.Permanent;
|
|
||||||
|
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
|
|
||||||
{
|
|
||||||
var torrentInfo = remoteEpisode.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Decision IsSatisfiedBy(RemoteMovie remoteEpisode, SearchCriteriaBase searchCriteria)
|
|
||||||
{
|
|
||||||
var torrentInfo = remoteEpisode.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,96 @@
|
|||||||
|
using NLog;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
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 IIndexerFactory _indexerFactory;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
public TorrentSeedingSpecification(IIndexerFactory indexerFactory, Logger logger)
|
||||||
|
{
|
||||||
|
_indexerFactory = indexerFactory;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public SpecificationPriority Priority => SpecificationPriority.Default;
|
||||||
|
public RejectionType Type => RejectionType.Permanent;
|
||||||
|
|
||||||
|
|
||||||
|
public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteria)
|
||||||
|
{
|
||||||
|
var torrentInfo = remoteEpisode.Release as TorrentInfo;
|
||||||
|
|
||||||
|
if (torrentInfo == null || torrentInfo.IndexerId == 0)
|
||||||
|
{
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
IndexerDefinition indexer;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
indexer = _indexerFactory.Get(torrentInfo.IndexerId);
|
||||||
|
}
|
||||||
|
catch (ModelNotFoundException)
|
||||||
|
{
|
||||||
|
_logger.Debug("Indexer with id {0} does not exist, skipping seeders check", torrentInfo.IndexerId);
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Decision IsSatisfiedBy(RemoteMovie remoteEpisode, SearchCriteriaBase searchCriteria)
|
||||||
|
{
|
||||||
|
var torrentInfo = remoteEpisode.Release as TorrentInfo;
|
||||||
|
|
||||||
|
if (torrentInfo == null || torrentInfo.IndexerId == 0)
|
||||||
|
{
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
IndexerDefinition indexer;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
indexer = _indexerFactory.Get(torrentInfo.IndexerId);
|
||||||
|
}
|
||||||
|
catch (ModelNotFoundException)
|
||||||
|
{
|
||||||
|
_logger.Debug("Indexer with id {0} does not exist, skipping seeders check", torrentInfo.IndexerId);
|
||||||
|
return Decision.Accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,13 +14,14 @@ public AwesomeHDSettingsValidator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AwesomeHDSettings : IProviderConfig
|
public class AwesomeHDSettings : ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly AwesomeHDSettingsValidator Validator = new AwesomeHDSettingsValidator();
|
private static readonly AwesomeHDSettingsValidator Validator = new AwesomeHDSettingsValidator();
|
||||||
|
|
||||||
public AwesomeHDSettings()
|
public AwesomeHDSettings()
|
||||||
{
|
{
|
||||||
BaseUrl = "https://awesome-hd.me";
|
BaseUrl = "https://awesome-hd.me";
|
||||||
|
MinimumSeeders = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "API URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since you Passkey will be sent to that host.")]
|
[FieldDefinition(0, Label = "API URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since you Passkey will be sent to that host.")]
|
||||||
@ -32,6 +33,9 @@ public AwesomeHDSettings()
|
|||||||
[FieldDefinition(2, Type = FieldType.Checkbox, Label = "Require Internal", HelpText = "Will only include internal releases for RSS Sync.")]
|
[FieldDefinition(2, Type = FieldType.Checkbox, Label = "Require Internal", HelpText = "Will only include internal releases for RSS Sync.")]
|
||||||
public bool Internal { get; set; }
|
public bool Internal { 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()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
@ -19,13 +18,14 @@ public HDBitsSettingsValidator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HDBitsSettings : IProviderConfig
|
public class HDBitsSettings : ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly HDBitsSettingsValidator Validator = new HDBitsSettingsValidator();
|
private static readonly HDBitsSettingsValidator Validator = new HDBitsSettingsValidator();
|
||||||
|
|
||||||
public HDBitsSettings()
|
public HDBitsSettings()
|
||||||
{
|
{
|
||||||
BaseUrl = "https://hdbits.org";
|
BaseUrl = "https://hdbits.org";
|
||||||
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
||||||
|
|
||||||
Categories = new int[] { (int)HdBitsCategory.Movie };
|
Categories = new int[] { (int)HdBitsCategory.Movie };
|
||||||
Codecs = new int[0];
|
Codecs = new int[0];
|
||||||
@ -56,6 +56,9 @@ public HDBitsSettings()
|
|||||||
[FieldDefinition(7, Label = "Mediums", Type = FieldType.Tag, SelectOptions = typeof(HdBitsMedium), Advanced = true, HelpText = "Options: BluRay, Encode, Capture, Remux, WebDL. If unspecified, all options are used.")]
|
[FieldDefinition(7, Label = "Mediums", Type = FieldType.Tag, SelectOptions = typeof(HdBitsMedium), Advanced = true, HelpText = "Options: BluRay, Encode, Capture, Remux, WebDL. If unspecified, all options are used.")]
|
||||||
public IEnumerable<int> Mediums { get; set; }
|
public IEnumerable<int> Mediums { get; set; }
|
||||||
|
|
||||||
|
[FieldDefinition(8, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
|
||||||
|
public int MinimumSeeders { get; set; }
|
||||||
|
|
||||||
public NzbDroneValidationResult Validate()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
9
src/NzbDrone.Core/Indexers/IIndexerSettings.cs
Normal file
9
src/NzbDrone.Core/Indexers/IIndexerSettings.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using NzbDrone.Core.ThingiProvider;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Indexers
|
||||||
|
{
|
||||||
|
public interface IIndexerSettings : IProviderConfig
|
||||||
|
{
|
||||||
|
string BaseUrl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -50,7 +50,7 @@ public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearc
|
|||||||
|
|
||||||
private IEnumerable<IndexerRequest> GetRssRequests()
|
private IEnumerable<IndexerRequest> GetRssRequests()
|
||||||
{
|
{
|
||||||
yield return new IndexerRequest(Settings.Url, HttpAccept.Rss);
|
yield return new IndexerRequest(Settings.BaseUrl, HttpAccept.Rss);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
@ -11,26 +11,31 @@ public class IPTorrentsSettingsValidator : AbstractValidator<IPTorrentsSettings>
|
|||||||
{
|
{
|
||||||
public IPTorrentsSettingsValidator()
|
public IPTorrentsSettingsValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Url).ValidRootUrl();
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
||||||
|
|
||||||
RuleFor(c => c.Url).Matches(@"/rss\?.+$");
|
RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+$");
|
||||||
|
|
||||||
RuleFor(c => c.Url).Matches(@"/rss\?.+;download(?:;|$)")
|
RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+;download(?:;|$)")
|
||||||
.WithMessage("Use Direct Download Url (;download)")
|
.WithMessage("Use Direct Download Url (;download)")
|
||||||
.When(v => v.Url.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.Url, @"/rss\?.+$"));
|
.When(v => v.BaseUrl.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.BaseUrl, @"/rss\?.+$"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IPTorrentsSettings : IProviderConfig
|
public class IPTorrentsSettings : ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly IPTorrentsSettingsValidator Validator = new IPTorrentsSettingsValidator();
|
private static readonly IPTorrentsSettingsValidator Validator = new IPTorrentsSettingsValidator();
|
||||||
|
|
||||||
public IPTorrentsSettings()
|
public IPTorrentsSettings()
|
||||||
{
|
{
|
||||||
|
BaseUrl = string.Empty;
|
||||||
|
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 ...)")]
|
[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 Url { get; set; }
|
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()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
|
7
src/NzbDrone.Core/Indexers/ITorrentIndexerSettings.cs
Normal file
7
src/NzbDrone.Core/Indexers/ITorrentIndexerSettings.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace NzbDrone.Core.Indexers
|
||||||
|
{
|
||||||
|
public interface ITorrentIndexerSettings : IIndexerSettings
|
||||||
|
{
|
||||||
|
int MinimumSeeders { get; set; }
|
||||||
|
}
|
||||||
|
}
|
7
src/NzbDrone.Core/Indexers/IndexerDefaults.cs
Normal file
7
src/NzbDrone.Core/Indexers/IndexerDefaults.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace NzbDrone.Core.Indexers
|
||||||
|
{
|
||||||
|
public static class IndexerDefaults
|
||||||
|
{
|
||||||
|
public const int MINIMUM_SEEDERS = 1;
|
||||||
|
}
|
||||||
|
}
|
@ -76,7 +76,7 @@ private IndexerDefinition GetDefinition(string name, NewznabSettings settings)
|
|||||||
|
|
||||||
private NewznabSettings GetSettings(string url, params int[] categories)
|
private NewznabSettings GetSettings(string url, params int[] categories)
|
||||||
{
|
{
|
||||||
var settings = new NewznabSettings { Url = url };
|
var settings = new NewznabSettings { BaseUrl = url };
|
||||||
|
|
||||||
if (categories.Any())
|
if (categories.Any())
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ private NewznabCapabilities FetchCapabilities(NewznabSettings indexerSettings)
|
|||||||
{
|
{
|
||||||
var capabilities = new NewznabCapabilities();
|
var capabilities = new NewznabCapabilities();
|
||||||
|
|
||||||
var url = string.Format("{0}/api?t=caps", indexerSettings.Url.TrimEnd('/'));
|
var url = string.Format("{0}/api?t=caps", indexerSettings.BaseUrl.TrimEnd('/'));
|
||||||
|
|
||||||
if (indexerSettings.ApiKey.IsNotNullOrWhiteSpace())
|
if (indexerSettings.ApiKey.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
@ -59,7 +59,7 @@ private NewznabCapabilities FetchCapabilities(NewznabSettings indexerSettings)
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Debug(ex, "Failed to get newznab api capabilities from {0}", indexerSettings.Url);
|
_logger.Debug(ex, "Failed to get newznab api capabilities from {0}", indexerSettings.BaseUrl);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,12 +69,12 @@ private NewznabCapabilities FetchCapabilities(NewznabSettings indexerSettings)
|
|||||||
}
|
}
|
||||||
catch (XmlException ex)
|
catch (XmlException ex)
|
||||||
{
|
{
|
||||||
_logger.Debug(ex, "Failed to parse newznab api capabilities for {0}.", indexerSettings.Url);
|
_logger.Debug(ex, "Failed to parse newznab api capabilities for {0}.", indexerSettings.BaseUrl);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, "Failed to determine newznab api capabilities for {0}, using the defaults instead till Sonarr restarts.", indexerSettings.Url);
|
_logger.Error(ex, "Failed to determine newznab api capabilities for {0}, using the defaults instead till Sonarr restarts.", indexerSettings.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return capabilities;
|
return capabilities;
|
||||||
|
@ -85,7 +85,7 @@ private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, IEnumerable<i
|
|||||||
|
|
||||||
var categoriesQuery = string.Join(",", categories.Distinct());
|
var categoriesQuery = string.Join(",", categories.Distinct());
|
||||||
|
|
||||||
var baseUrl = string.Format("{0}/api?t={1}&cat={2}&extended=1{3}", Settings.Url.TrimEnd('/'), searchType, categoriesQuery, Settings.AdditionalParameters);
|
var baseUrl = string.Format("{0}/api?t={1}&cat={2}&extended=1{3}", Settings.BaseUrl.TrimEnd('/'), searchType, categoriesQuery, Settings.AdditionalParameters);
|
||||||
|
|
||||||
if (Settings.ApiKey.IsNotNullOrWhiteSpace())
|
if (Settings.ApiKey.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
|
@ -25,12 +25,12 @@ public class NewznabSettingsValidator : AbstractValidator<NewznabSettings>
|
|||||||
|
|
||||||
private static bool ShouldHaveApiKey(NewznabSettings settings)
|
private static bool ShouldHaveApiKey(NewznabSettings settings)
|
||||||
{
|
{
|
||||||
if (settings.Url == null)
|
if (settings.BaseUrl == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiKeyWhiteList.Any(c => settings.Url.ToLowerInvariant().Contains(c));
|
return ApiKeyWhiteList.Any(c => settings.BaseUrl.ToLowerInvariant().Contains(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled);
|
private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled);
|
||||||
@ -47,14 +47,14 @@ public NewznabSettingsValidator()
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
RuleFor(c => c.Url).ValidRootUrl();
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
||||||
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
||||||
RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex)
|
RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex)
|
||||||
.When(c => !c.AdditionalParameters.IsNullOrWhiteSpace());
|
.When(c => !c.AdditionalParameters.IsNullOrWhiteSpace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NewznabSettings : IProviderConfig
|
public class NewznabSettings : IIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly NewznabSettingsValidator Validator = new NewznabSettingsValidator();
|
private static readonly NewznabSettingsValidator Validator = new NewznabSettingsValidator();
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public NewznabSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "URL")]
|
[FieldDefinition(0, Label = "URL")]
|
||||||
public string Url { get; set; }
|
public string BaseUrl { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(1, Label = "API Key")]
|
[FieldDefinition(1, Label = "API Key")]
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
@ -79,6 +79,9 @@ public NewznabSettings()
|
|||||||
[FieldDefinition(4, Label = "Additional Parameters", HelpText = "Additional Newznab parameters", Advanced = true)]
|
[FieldDefinition(4, Label = "Additional Parameters", HelpText = "Additional Newznab parameters", Advanced = true)]
|
||||||
public string AdditionalParameters { get; set; }
|
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()
|
public virtual NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
namespace NzbDrone.Core.Indexers.Nyaa
|
namespace NzbDrone.Core.Indexers.Nyaa
|
||||||
@ -14,7 +13,7 @@ public NyaaSettingsValidator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NyaaSettings : IProviderConfig
|
public class NyaaSettings : ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly NyaaSettingsValidator Validator = new NyaaSettingsValidator();
|
private static readonly NyaaSettingsValidator Validator = new NyaaSettingsValidator();
|
||||||
|
|
||||||
@ -22,6 +21,7 @@ public NyaaSettings()
|
|||||||
{
|
{
|
||||||
BaseUrl = "http://www.nyaa.se";
|
BaseUrl = "http://www.nyaa.se";
|
||||||
AdditionalParameters = "&cats=1_37&filter=1";
|
AdditionalParameters = "&cats=1_37&filter=1";
|
||||||
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Website URL")]
|
[FieldDefinition(0, Label = "Website URL")]
|
||||||
@ -30,6 +30,9 @@ public NyaaSettings()
|
|||||||
[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.")]
|
[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; }
|
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()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
@ -15,7 +15,7 @@ public OmgwtfnzbsSettingsValidator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OmgwtfnzbsSettings : IProviderConfig
|
public class OmgwtfnzbsSettings : IIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly OmgwtfnzbsSettingsValidator Validator = new OmgwtfnzbsSettingsValidator();
|
private static readonly OmgwtfnzbsSettingsValidator Validator = new OmgwtfnzbsSettingsValidator();
|
||||||
|
|
||||||
@ -24,6 +24,9 @@ public OmgwtfnzbsSettings()
|
|||||||
Delay = 30;
|
Delay = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unused since Omg has a hardcoded url.
|
||||||
|
public string BaseUrl { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Username")]
|
[FieldDefinition(0, Label = "Username")]
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
@ -17,13 +17,14 @@ public PassThePopcornSettingsValidator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PassThePopcornSettings : IProviderConfig
|
public class PassThePopcornSettings : ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly PassThePopcornSettingsValidator Validator = new PassThePopcornSettingsValidator();
|
private static readonly PassThePopcornSettingsValidator Validator = new PassThePopcornSettingsValidator();
|
||||||
|
|
||||||
public PassThePopcornSettings()
|
public PassThePopcornSettings()
|
||||||
{
|
{
|
||||||
BaseUrl = "https://passthepopcorn.me";
|
BaseUrl = "https://passthepopcorn.me";
|
||||||
|
MinimumSeeders = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your cookie will be sent to that host.")]
|
[FieldDefinition(0, Label = "URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your cookie will be sent to that host.")]
|
||||||
@ -50,6 +51,9 @@ public PassThePopcornSettings()
|
|||||||
[FieldDefinition(7, Label = "Require Golden", Type = FieldType.Checkbox, HelpText = "Require Golden Popcorn-releases for releases to be accepted.")]
|
[FieldDefinition(7, Label = "Require Golden", Type = FieldType.Checkbox, HelpText = "Require Golden Popcorn-releases for releases to be accepted.")]
|
||||||
public bool RequireGolden { get; set; }
|
public bool RequireGolden { get; set; }
|
||||||
|
|
||||||
|
[FieldDefinition(8, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
|
||||||
|
public int MinimumSeeders { get; set; }
|
||||||
|
|
||||||
public NzbDroneValidationResult Validate()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.Rarbg
|
namespace NzbDrone.Core.Indexers.Rarbg
|
||||||
@ -13,7 +12,7 @@ public RarbgSettingsValidator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RarbgSettings : IProviderConfig
|
public class RarbgSettings : ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly RarbgSettingsValidator Validator = new RarbgSettingsValidator();
|
private static readonly RarbgSettingsValidator Validator = new RarbgSettingsValidator();
|
||||||
|
|
||||||
@ -21,6 +20,7 @@ public RarbgSettings()
|
|||||||
{
|
{
|
||||||
BaseUrl = "https://torrentapi.org";
|
BaseUrl = "https://torrentapi.org";
|
||||||
RankedOnly = false;
|
RankedOnly = false;
|
||||||
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "API URL", HelpText = "URL to Rarbg api, not the website.")]
|
[FieldDefinition(0, Label = "API URL", HelpText = "URL to Rarbg api, not the website.")]
|
||||||
@ -32,6 +32,9 @@ public RarbgSettings()
|
|||||||
[FieldDefinition(2, Type = FieldType.Captcha, Label = "CAPTCHA Token", HelpText = "CAPTCHA Clearance token used to handle CloudFlare Anti-DDOS measures on shared-ip VPNs.")]
|
[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; }
|
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()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
@ -13,13 +13,14 @@ public TorrentPotatoSettingsValidator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TorrentPotatoSettings : IProviderConfig
|
public class TorrentPotatoSettings : ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly TorrentPotatoSettingsValidator Validator = new TorrentPotatoSettingsValidator();
|
private static readonly TorrentPotatoSettingsValidator Validator = new TorrentPotatoSettingsValidator();
|
||||||
|
|
||||||
public TorrentPotatoSettings()
|
public TorrentPotatoSettings()
|
||||||
{
|
{
|
||||||
BaseUrl = "http://127.0.0.1";
|
BaseUrl = "http://127.0.0.1";
|
||||||
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "API URL", HelpText = "URL to TorrentPotato api.")]
|
[FieldDefinition(0, Label = "API URL", HelpText = "URL to TorrentPotato api.")]
|
||||||
@ -30,6 +31,10 @@ public TorrentPotatoSettings()
|
|||||||
|
|
||||||
[FieldDefinition(2, Label = "Passkey", HelpText = "The password you use at your Indexer.")]
|
[FieldDefinition(2, Label = "Passkey", HelpText = "The password you use at your Indexer.")]
|
||||||
public string Passkey { get; set; }
|
public string Passkey { 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()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers.TorrentRss
|
namespace NzbDrone.Core.Indexers.TorrentRss
|
||||||
@ -13,7 +12,7 @@ public TorrentRssIndexerSettingsValidator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TorrentRssIndexerSettings : IProviderConfig
|
public class TorrentRssIndexerSettings : ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly TorrentRssIndexerSettingsValidator validator = new TorrentRssIndexerSettingsValidator();
|
private static readonly TorrentRssIndexerSettingsValidator validator = new TorrentRssIndexerSettingsValidator();
|
||||||
|
|
||||||
@ -21,6 +20,7 @@ public TorrentRssIndexerSettings()
|
|||||||
{
|
{
|
||||||
BaseUrl = string.Empty;
|
BaseUrl = string.Empty;
|
||||||
AllowZeroSize = false;
|
AllowZeroSize = false;
|
||||||
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Full RSS Feed URL")]
|
[FieldDefinition(0, Label = "Full RSS Feed URL")]
|
||||||
@ -32,6 +32,9 @@ public TorrentRssIndexerSettings()
|
|||||||
[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.")]
|
[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; }
|
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()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(validator.Validate(this));
|
return new NzbDroneValidationResult(validator.Validate(this));
|
||||||
|
@ -66,7 +66,7 @@ private IndexerDefinition GetDefinition(string name, TorznabSettings settings)
|
|||||||
|
|
||||||
private TorznabSettings GetSettings(string url, params int[] categories)
|
private TorznabSettings GetSettings(string url, params int[] categories)
|
||||||
{
|
{
|
||||||
var settings = new TorznabSettings { Url = url };
|
var settings = new TorznabSettings { BaseUrl = url };
|
||||||
|
|
||||||
if (categories.Any())
|
if (categories.Any())
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.Indexers.Newznab;
|
using NzbDrone.Core.Indexers.Newznab;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
@ -17,12 +18,12 @@ public class TorznabSettingsValidator : AbstractValidator<TorznabSettings>
|
|||||||
|
|
||||||
private static bool ShouldHaveApiKey(TorznabSettings settings)
|
private static bool ShouldHaveApiKey(TorznabSettings settings)
|
||||||
{
|
{
|
||||||
if (settings.Url == null)
|
if (settings.BaseUrl == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiKeyWhiteList.Any(c => settings.Url.ToLowerInvariant().Contains(c));
|
return ApiKeyWhiteList.Any(c => settings.BaseUrl.ToLowerInvariant().Contains(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled);
|
private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled);
|
||||||
@ -39,17 +40,25 @@ public TorznabSettingsValidator()
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
RuleFor(c => c.Url).ValidRootUrl();
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
||||||
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
||||||
RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex)
|
RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex)
|
||||||
.When(c => !c.AdditionalParameters.IsNullOrWhiteSpace());
|
.When(c => !c.AdditionalParameters.IsNullOrWhiteSpace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TorznabSettings : NewznabSettings
|
public class TorznabSettings : NewznabSettings, ITorrentIndexerSettings
|
||||||
{
|
{
|
||||||
private static readonly TorznabSettingsValidator Validator = new TorznabSettingsValidator();
|
private static readonly TorznabSettingsValidator Validator = new TorznabSettingsValidator();
|
||||||
|
|
||||||
|
public TorznabSettings()
|
||||||
|
{
|
||||||
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
[FieldDefinition(6, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
|
||||||
|
public int MinimumSeeders { get; set; }
|
||||||
|
|
||||||
public override NzbDroneValidationResult Validate()
|
public override NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
@ -403,7 +403,7 @@
|
|||||||
<Compile Include="DecisionEngine\Specifications\Search\SeasonMatchSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\Search\SeasonMatchSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\Search\SeriesSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\Search\SeriesSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\Search\SingleEpisodeSearchMatchSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\Search\SingleEpisodeSearchMatchSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\Search\TorrentSeedingSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\TorrentSeedingSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\SameEpisodesGrabSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\SameEpisodesGrabSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\RawDiskSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\RawDiskSpecification.cs" />
|
||||||
<Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" />
|
<Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" />
|
||||||
@ -691,6 +691,7 @@
|
|||||||
<Compile Include="Indexers\IIndexer.cs" />
|
<Compile Include="Indexers\IIndexer.cs" />
|
||||||
<Compile Include="Indexers\IIndexerRequestGenerator.cs" />
|
<Compile Include="Indexers\IIndexerRequestGenerator.cs" />
|
||||||
<Compile Include="Indexers\IndexerBase.cs" />
|
<Compile Include="Indexers\IndexerBase.cs" />
|
||||||
|
<Compile Include="Indexers\IndexerDefaults.cs" />
|
||||||
<Compile Include="Indexers\IndexerDefinition.cs" />
|
<Compile Include="Indexers\IndexerDefinition.cs" />
|
||||||
<Compile Include="Indexers\IndexerFactory.cs" />
|
<Compile Include="Indexers\IndexerFactory.cs" />
|
||||||
<Compile Include="Indexers\IndexerPageableRequest.cs" />
|
<Compile Include="Indexers\IndexerPageableRequest.cs" />
|
||||||
@ -706,6 +707,7 @@
|
|||||||
<Compile Include="Indexers\IPTorrents\IPTorrentsRequestGenerator.cs" />
|
<Compile Include="Indexers\IPTorrents\IPTorrentsRequestGenerator.cs" />
|
||||||
<Compile Include="Indexers\IPTorrents\IPTorrents.cs" />
|
<Compile Include="Indexers\IPTorrents\IPTorrents.cs" />
|
||||||
<Compile Include="Indexers\IPTorrents\IPTorrentsSettings.cs" />
|
<Compile Include="Indexers\IPTorrents\IPTorrentsSettings.cs" />
|
||||||
|
<Compile Include="Indexers\ITorrentIndexerSettings.cs" />
|
||||||
<Compile Include="Indexers\Newznab\Newznab.cs" />
|
<Compile Include="Indexers\Newznab\Newznab.cs" />
|
||||||
<Compile Include="Indexers\Newznab\NewznabCapabilities.cs" />
|
<Compile Include="Indexers\Newznab\NewznabCapabilities.cs" />
|
||||||
<Compile Include="Indexers\Newznab\NewznabCapabilitiesProvider.cs" />
|
<Compile Include="Indexers\Newznab\NewznabCapabilitiesProvider.cs" />
|
||||||
@ -1285,6 +1287,7 @@
|
|||||||
<Compile Include="NetImport\ImportExclusions\ImportExclusionsRepository.cs" />
|
<Compile Include="NetImport\ImportExclusions\ImportExclusionsRepository.cs" />
|
||||||
<Compile Include="NetImport\ImportExclusions\ImportExclusionsService.cs" />
|
<Compile Include="NetImport\ImportExclusions\ImportExclusionsService.cs" />
|
||||||
<Compile Include="Datastore\Migration\138_add_physical_release_note.cs" />
|
<Compile Include="Datastore\Migration\138_add_physical_release_note.cs" />
|
||||||
|
<Compile Include="Indexers\IIndexerSettings.cs" />
|
||||||
<Compile Include="NetImport\Radarr\RadarrProxied.cs" />
|
<Compile Include="NetImport\Radarr\RadarrProxied.cs" />
|
||||||
<Compile Include="NetImport\Radarr\RadarrParser.cs" />
|
<Compile Include="NetImport\Radarr\RadarrParser.cs" />
|
||||||
<Compile Include="NetImport\Radarr\RadarrRequestGenerator.cs" />
|
<Compile Include="NetImport\Radarr\RadarrRequestGenerator.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user