mirror of https://github.com/lidarr/Lidarr
51 lines
2.2 KiB
C#
51 lines
2.2 KiB
C#
using System.Text.RegularExpressions;
|
|
using FluentValidation;
|
|
using NzbDrone.Core.Annotations;
|
|
using NzbDrone.Core.Validation;
|
|
namespace NzbDrone.Core.Indexers.Nyaa
|
|
{
|
|
public class NyaaSettingsValidator : AbstractValidator<NyaaSettings>
|
|
{
|
|
public NyaaSettingsValidator()
|
|
{
|
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
|
RuleFor(c => c.AdditionalParameters).Matches("(&[a-z]+=[a-z0-9_]+)*", RegexOptions.IgnoreCase);
|
|
}
|
|
}
|
|
|
|
public class NyaaSettings : ITorrentIndexerSettings
|
|
{
|
|
private static readonly NyaaSettingsValidator Validator = new NyaaSettingsValidator();
|
|
|
|
public NyaaSettings()
|
|
{
|
|
BaseUrl = "";
|
|
AdditionalParameters = "&cats=2_0&filter=1";
|
|
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
|
|
}
|
|
|
|
[FieldDefinition(0, Label = "Website URL")]
|
|
public string BaseUrl { get; set; }
|
|
|
|
[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.Number, Label = "Early Download Limit", Unit = "days", HelpText = "Time before release date Lidarr will download from this indexer, empty is no limit", Advanced = true)]
|
|
public int? EarlyReleaseLimit { get; set; }
|
|
|
|
[FieldDefinition(3, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
|
|
public int MinimumSeeders { get; set; }
|
|
|
|
[FieldDefinition(4)]
|
|
public SeedCriteriaSettings SeedCriteria { get; set; } = new SeedCriteriaSettings();
|
|
|
|
[FieldDefinition(5, Type = FieldType.Checkbox, Label = "IndexerSettingsRejectBlocklistedTorrentHashes", HelpText = "IndexerSettingsRejectBlocklistedTorrentHashesHelpText", Advanced = true)]
|
|
public bool RejectBlocklistedTorrentHashesWhileGrabbing { get; set; }
|
|
|
|
public NzbDroneValidationResult Validate()
|
|
{
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
}
|
|
}
|
|
}
|