2014-05-13 17:57:46 +00:00
using FluentValidation ;
using NzbDrone.Core.Annotations ;
using NzbDrone.Core.ThingiProvider ;
using NzbDrone.Core.Validation ;
2015-04-02 17:52:23 +00:00
using System.Text.RegularExpressions ;
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
}
}
public class NyaaSettings : IProviderConfig
{
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" ;
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
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
}
}
}