Added nested settings for seed criteria.
This commit is contained in:
parent
b6ef4d50dc
commit
47018b02a8
|
@ -23,7 +23,7 @@ namespace NzbDrone.Core.Configuration
|
|||
{
|
||||
return new TorrentSeedConfiguration
|
||||
{
|
||||
Ratio = torrentIndexerSettings.SeedRatio
|
||||
Ratio = torrentIndexerSettings.SeedCriteria.SeedRatio
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
{
|
||||
int MinimumSeeders { get; set; }
|
||||
|
||||
double? SeedRatio { get; set; }
|
||||
SeedCriteriaSettings SeedCriteria { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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<SeedCriteriaSettings>
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -142,7 +142,6 @@
|
|||
<Compile Include="Configuration\Events\ConfigSavedEvent.cs" />
|
||||
<Compile Include="Configuration\IConfigService.cs" />
|
||||
<Compile Include="Configuration\InvalidConfigFileException.cs" />
|
||||
<Compile Include="Configuration\ISeedConfigProvider.cs" />
|
||||
<Compile Include="Configuration\ResetApiKeyCommand.cs" />
|
||||
<Compile Include="Configuration\SeedConfigProvider.cs" />
|
||||
<Compile Include="DataAugmentation\DailySeries\DailySeries.cs" />
|
||||
|
@ -709,6 +708,7 @@
|
|||
<Compile Include="Indexers\Rarbg\RarbgParser.cs" />
|
||||
<Compile Include="Indexers\Rarbg\RarbgTokenProvider.cs" />
|
||||
<Compile Include="Indexers\RssEnclosure.cs" />
|
||||
<Compile Include="Indexers\SeedCriteriaSettings.cs" />
|
||||
<Compile Include="Indexers\XmlCleaner.cs" />
|
||||
<Compile Include="Indexers\RssIndexerRequestGenerator.cs" />
|
||||
<Compile Include="Indexers\RssParser.cs" />
|
||||
|
|
Loading…
Reference in New Issue