2018-02-01 13:18:52 +00:00
using System.Collections.Generic ;
2014-05-13 17:57:46 +00:00
using FluentValidation ;
using NzbDrone.Core.Annotations ;
using NzbDrone.Core.Validation ;
2015-04-02 17:52:23 +00:00
using System.Text.RegularExpressions ;
2018-02-01 13:18:52 +00:00
using NzbDrone.Core.Parser.Model ;
2014-05-13 17:57:46 +00:00
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-06-12 12:47:05 +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 ( )
{
BaseUrl = "http://www.nyaa.se" ;
2015-04-02 17:52:23 +00:00
AdditionalParameters = "&cats=1_37&filter=1" ;
2017-06-12 12:47:05 +00:00
MinimumSeeders = IndexerDefaults . MINIMUM_SEEDERS ;
2014-05-13 17:57:46 +00:00
}
[FieldDefinition(0, Label = "Website URL")]
2015-10-03 17:45:26 +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.")]
2015-10-03 17:45:26 +00:00
public string AdditionalParameters { get ; set ; }
2015-04-02 17:52:23 +00:00
2017-06-12 12:47:05 +00:00
[FieldDefinition(2, Type = FieldType.Textbox, Label = "Minimum Seeders", HelpText = "Minimum number of seeders required.", Advanced = true)]
public int MinimumSeeders { get ; set ; }
2018-05-27 09:05:23 +00:00
[FieldDefinition(3, Type = FieldType.Tag, SelectOptions = typeof(IndexerFlags), Label = "Required Flags", HelpText = "What indexer flags are required?", HelpLink = "https://github.com/Radarr/Radarr/wiki/Indexer-Flags#1-required-flags", Advanced = true)]
2018-02-01 13:18:52 +00:00
public IEnumerable < int > RequiredFlags { get ; set ; }
2017-06-12 12:47:05 +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
}
}
2018-05-27 09:05:23 +00:00
}