diff --git a/src/NzbDrone.Core/Configuration/SeedConfigProvider.cs b/src/NzbDrone.Core/Configuration/SeedConfigProvider.cs index 2398c8201..ab207b0a2 100644 --- a/src/NzbDrone.Core/Configuration/SeedConfigProvider.cs +++ b/src/NzbDrone.Core/Configuration/SeedConfigProvider.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Core.Configuration { return new TorrentSeedConfiguration { - Ratio = torrentIndexerSettings.SeedRatio + Ratio = torrentIndexerSettings.SeedCriteria.SeedRatio }; } diff --git a/src/NzbDrone.Core/Indexers/BitMeTv/BitMeTvSettings.cs b/src/NzbDrone.Core/Indexers/BitMeTv/BitMeTvSettings.cs index e7d066da8..babdd3beb 100644 --- a/src/NzbDrone.Core/Indexers/BitMeTv/BitMeTvSettings.cs +++ b/src/NzbDrone.Core/Indexers/BitMeTv/BitMeTvSettings.cs @@ -19,6 +19,8 @@ namespace NzbDrone.Core.Indexers.BitMeTv .Matches(@"pass=[0-9a-f]{32}", RegexOptions.IgnoreCase) .WithMessage("Wrong pattern") .AsWarning(); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -47,8 +49,8 @@ namespace NzbDrone.Core.Indexers.BitMeTv [FieldDefinition(4, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(5, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(5)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetSettings.cs b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetSettings.cs index d259b9273..993089d74 100644 --- a/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetSettings.cs +++ b/src/NzbDrone.Core/Indexers/BroadcastheNet/BroadcastheNetSettings.cs @@ -10,6 +10,8 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet { RuleFor(c => c.BaseUrl).ValidRootUrl(); RuleFor(c => c.ApiKey).NotEmpty(); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -32,8 +34,8 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet [FieldDefinition(2, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(3, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(3)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsSettings.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsSettings.cs index 1a44e76fc..48fd48783 100644 --- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsSettings.cs +++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsSettings.cs @@ -10,6 +10,8 @@ namespace NzbDrone.Core.Indexers.HDBits { RuleFor(c => c.BaseUrl).ValidRootUrl(); RuleFor(c => c.ApiKey).NotEmpty(); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -35,8 +37,8 @@ namespace NzbDrone.Core.Indexers.HDBits [FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(4, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(4)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsSettings.cs b/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsSettings.cs index 8fd4f55a6..52255d8fb 100644 --- a/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsSettings.cs +++ b/src/NzbDrone.Core/Indexers/IPTorrents/IPTorrentsSettings.cs @@ -17,6 +17,8 @@ namespace NzbDrone.Core.Indexers.IPTorrents RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+;download(?:;|$)") .WithMessage("Use Direct Download Url (;download)") .When(v => v.BaseUrl.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.BaseUrl, @"/rss\?.+$")); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -35,8 +37,8 @@ namespace NzbDrone.Core.Indexers.IPTorrents [FieldDefinition(1, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(2, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(2)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Indexers/ITorrentIndexerSettings.cs b/src/NzbDrone.Core/Indexers/ITorrentIndexerSettings.cs index 761a56b5f..6915bc966 100644 --- a/src/NzbDrone.Core/Indexers/ITorrentIndexerSettings.cs +++ b/src/NzbDrone.Core/Indexers/ITorrentIndexerSettings.cs @@ -4,6 +4,6 @@ { int MinimumSeeders { get; set; } - double? SeedRatio { get; set; } + SeedCriteriaSettings SeedCriteria { get; } } } diff --git a/src/NzbDrone.Core/Indexers/Nyaa/NyaaSettings.cs b/src/NzbDrone.Core/Indexers/Nyaa/NyaaSettings.cs index 587b4d15b..9213084e5 100644 --- a/src/NzbDrone.Core/Indexers/Nyaa/NyaaSettings.cs +++ b/src/NzbDrone.Core/Indexers/Nyaa/NyaaSettings.cs @@ -11,6 +11,8 @@ namespace NzbDrone.Core.Indexers.Nyaa { RuleFor(c => c.BaseUrl).ValidRootUrl(); RuleFor(c => c.AdditionalParameters).Matches("(&[a-z]+=[a-z0-9_]+)*", RegexOptions.IgnoreCase); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -34,8 +36,8 @@ namespace NzbDrone.Core.Indexers.Nyaa [FieldDefinition(2, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(3, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(3)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Indexers/Rarbg/RarbgSettings.cs b/src/NzbDrone.Core/Indexers/Rarbg/RarbgSettings.cs index 50f1aa45d..9a363741a 100644 --- a/src/NzbDrone.Core/Indexers/Rarbg/RarbgSettings.cs +++ b/src/NzbDrone.Core/Indexers/Rarbg/RarbgSettings.cs @@ -9,6 +9,8 @@ namespace NzbDrone.Core.Indexers.Rarbg public RarbgSettingsValidator() { RuleFor(c => c.BaseUrl).ValidRootUrl(); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -35,8 +37,8 @@ namespace NzbDrone.Core.Indexers.Rarbg [FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(4, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(4)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Indexers/SeedCriteriaSettings.cs b/src/NzbDrone.Core/Indexers/SeedCriteriaSettings.cs new file mode 100644 index 000000000..c50495819 --- /dev/null +++ b/src/NzbDrone.Core/Indexers/SeedCriteriaSettings.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FluentValidation; +using NzbDrone.Core.Annotations; +using NzbDrone.Core.Validation; + +namespace NzbDrone.Core.Indexers +{ + public class SeedCriteriaSettingsValidator : AbstractValidator + { + public SeedCriteriaSettingsValidator() + { + RuleFor(c => c.SeedRatio).GreaterThan(0.0).When(c => c.SeedRatio.HasValue); + //RuleFor(c => c.SeedTime).GreaterThan(0).When(c => c.SeedTime.HasValue); + //RuleFor(c => c.SeasonPackSeedTime).GreaterThan(0).When(c => c.SeasonPackSeedTime.HasValue); + } + } + + public class SeedCriteriaSettings + { + private static readonly SeedCriteriaSettingsValidator Validator = new SeedCriteriaSettingsValidator(); + + [FieldDefinition(0, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] + public double? SeedRatio { get; set; } + + //[FieldDefinition(1, Type = FieldType.Textbox, Label = "Seed Time", HelpText = "The time a torrent should be seeded before stopping, empty is download client's default", Advanced = true)] + //public int? SeedTime { get; set; } + + //[FieldDefinition(2, Type = FieldType.Textbox, Label = "Season-Pack Seed Time", HelpText = "The time a torrent should be seeded before stopping, empty is download client's default", Advanced = true)] + //public int? SeasonPackSeedTime { get; set; } + } +} diff --git a/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerSettings.cs b/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerSettings.cs index 5ba3282c6..93e9bbebd 100644 --- a/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerSettings.cs +++ b/src/NzbDrone.Core/Indexers/TorrentRss/TorrentRssIndexerSettings.cs @@ -9,6 +9,8 @@ namespace NzbDrone.Core.Indexers.TorrentRss public TorrentRssIndexerSettingsValidator() { RuleFor(c => c.BaseUrl).ValidRootUrl(); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -35,8 +37,8 @@ namespace NzbDrone.Core.Indexers.TorrentRss [FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(4, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(4)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Indexers/Torrentleech/TorrentleechSettings.cs b/src/NzbDrone.Core/Indexers/Torrentleech/TorrentleechSettings.cs index 8f3c5203e..0a0984647 100644 --- a/src/NzbDrone.Core/Indexers/Torrentleech/TorrentleechSettings.cs +++ b/src/NzbDrone.Core/Indexers/Torrentleech/TorrentleechSettings.cs @@ -10,6 +10,8 @@ namespace NzbDrone.Core.Indexers.Torrentleech { RuleFor(c => c.BaseUrl).ValidRootUrl(); RuleFor(c => c.ApiKey).NotEmpty(); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -32,8 +34,8 @@ namespace NzbDrone.Core.Indexers.Torrentleech [FieldDefinition(2, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(3, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(3)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/Indexers/Torznab/TorznabSettings.cs b/src/NzbDrone.Core/Indexers/Torznab/TorznabSettings.cs index d1dc0ed9f..0e0437108 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/TorznabSettings.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/TorznabSettings.cs @@ -45,6 +45,8 @@ namespace NzbDrone.Core.Indexers.Torznab RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey); RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex) .When(c => !c.AdditionalParameters.IsNullOrWhiteSpace()); + + RuleFor(c => c.SeedCriteria).SetValidator(_ => new SeedCriteriaSettingsValidator()); } } @@ -60,8 +62,8 @@ namespace NzbDrone.Core.Indexers.Torznab [FieldDefinition(6, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)] public int MinimumSeeders { get; set; } - [FieldDefinition(7, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)] - public double? SeedRatio { get; set; } + [FieldDefinition(7)] + public SeedCriteriaSettings SeedCriteria { get; } = new SeedCriteriaSettings(); public override NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index c69d1bd27..24f650b51 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -142,7 +142,6 @@ - @@ -709,6 +708,7 @@ +