2020-01-03 12:49:24 +00:00
using System.Text.RegularExpressions ;
2017-10-08 03:54:13 +00:00
using FluentValidation ;
2014-05-13 17:57:46 +00:00
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 ( ) ;
2015-04-02 17:52:23 +00:00
RuleFor ( c = > c . AdditionalParameters ) . Matches ( "(&[a-z]+=[a-z0-9_]+)*" , RegexOptions . IgnoreCase ) ;
2014-05-13 17:57:46 +00:00
}
}
2017-10-26 02:30:31 +00:00
public class NyaaSettings : ITorrentIndexerSettings
2014-05-13 17:57:46 +00:00
{
2015-03-17 04:33:34 +00:00
private static readonly NyaaSettingsValidator Validator = new NyaaSettingsValidator ( ) ;
2014-05-13 17:57:46 +00:00
public NyaaSettings ( )
{
2017-10-28 21:47:01 +00:00
BaseUrl = "" ;
2021-01-25 03:03:01 +00:00
AdditionalParameters = "&cats=2_0&filter=1" ;
2017-10-26 02:30:31 +00:00
MinimumSeeders = IndexerDefaults . MINIMUM_SEEDERS ;
2014-05-13 17:57:46 +00:00
}
[FieldDefinition(0, Label = "Website URL")]
2017-02-16 17:19:28 +00:00
public string BaseUrl { get ; set ; }
2014-05-13 17:57:46 +00:00
2015-04-02 17:52:23 +00:00
[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.")]
2017-02-16 17:19:28 +00:00
public string AdditionalParameters { get ; set ; }
2015-04-02 17:52:23 +00:00
2023-10-29 18:23:23 +00:00
[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)]
2017-10-26 02:30:31 +00:00
public int MinimumSeeders { get ; set ; }
2023-10-29 18:23:23 +00:00
[FieldDefinition(4)]
2020-08-18 20:11:44 +00:00
public SeedCriteriaSettings SeedCriteria { get ; set ; } = new SeedCriteriaSettings ( ) ;
2018-06-02 01:59:54 +00:00
2024-01-16 05:52:55 +00:00
[FieldDefinition(5, Type = FieldType.Checkbox, Label = "IndexerSettingsRejectBlocklistedTorrentHashes", HelpText = "IndexerSettingsRejectBlocklistedTorrentHashesHelpText", Advanced = true)]
2023-10-29 18:23:23 +00:00
public bool RejectBlocklistedTorrentHashesWhileGrabbing { get ; set ; }
2018-09-21 02:21:26 +00:00
2015-03-17 04:33:34 +00:00
public NzbDroneValidationResult Validate ( )
2014-05-13 17:57:46 +00:00
{
2015-03-17 04:33:34 +00:00
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
2014-05-13 17:57:46 +00:00
}
}
2017-10-08 03:54:13 +00:00
}