mirror of
https://github.com/lidarr/Lidarr
synced 2025-03-15 08:19:05 +00:00
62 lines
2.8 KiB
C#
62 lines
2.8 KiB
C#
using FluentValidation;
|
|
using NzbDrone.Core.Annotations;
|
|
using NzbDrone.Core.Validation;
|
|
|
|
namespace NzbDrone.Core.Indexers
|
|
{
|
|
public class SeedCriteriaSettingsValidator : AbstractValidator<SeedCriteriaSettings>
|
|
{
|
|
public SeedCriteriaSettingsValidator(double seedRatioMinimum = 0.0, int seedTimeMinimum = 0, int discographySeedTimeMinimum = 0)
|
|
{
|
|
RuleFor(c => c.SeedRatio).GreaterThan(0.0)
|
|
.When(c => c.SeedRatio.HasValue)
|
|
.AsWarning().WithMessage("Should be greater than zero");
|
|
|
|
RuleFor(c => c.SeedTime).GreaterThan(0)
|
|
.When(c => c.SeedTime.HasValue)
|
|
.AsWarning().WithMessage("Should be greater than zero");
|
|
|
|
RuleFor(c => c.DiscographySeedTime).GreaterThan(0)
|
|
.When(c => c.DiscographySeedTime.HasValue)
|
|
.AsWarning().WithMessage("Should be greater than zero");
|
|
|
|
if (seedRatioMinimum != 0.0)
|
|
{
|
|
RuleFor(c => c.SeedRatio).GreaterThanOrEqualTo(seedRatioMinimum)
|
|
.When(c => c.SeedRatio > 0.0)
|
|
.AsWarning()
|
|
.WithMessage($"Under {seedRatioMinimum} leads to H&R");
|
|
}
|
|
|
|
if (seedTimeMinimum != 0)
|
|
{
|
|
RuleFor(c => c.SeedTime).GreaterThanOrEqualTo(seedTimeMinimum)
|
|
.When(c => c.SeedTime > 0)
|
|
.AsWarning()
|
|
.WithMessage($"Under {seedTimeMinimum} leads to H&R");
|
|
}
|
|
|
|
if (discographySeedTimeMinimum != 0)
|
|
{
|
|
RuleFor(c => c.DiscographySeedTime).GreaterThanOrEqualTo(discographySeedTimeMinimum)
|
|
.When(c => c.DiscographySeedTime > 0)
|
|
.AsWarning()
|
|
.WithMessage($"Under {discographySeedTimeMinimum} leads to H&R");
|
|
}
|
|
}
|
|
}
|
|
|
|
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. Ratio should be at least 1.0 and follow the indexers rules")]
|
|
public double? SeedRatio { get; set; }
|
|
|
|
[FieldDefinition(1, Type = FieldType.Textbox, Label = "Seed Time", Unit = "minutes", 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 = "Discography Seed Time", Unit = "minutes", HelpText = "The time a torrent should be seeded before stopping, empty is download client's default", Advanced = true)]
|
|
public int? DiscographySeedTime { get; set; }
|
|
}
|
|
}
|