2015-07-08 08:11:33 +00:00
using FluentValidation ;
2015-05-08 18:50:22 +00:00
using NzbDrone.Core.Annotations ;
using NzbDrone.Core.ThingiProvider ;
using NzbDrone.Core.Validation ;
namespace NzbDrone.Core.Download.Clients.RTorrent
{
public class RTorrentSettingsValidator : AbstractValidator < RTorrentSettings >
{
public RTorrentSettingsValidator ( )
{
2015-05-21 20:06:47 +00:00
RuleFor ( c = > c . Host ) . ValidHost ( ) ;
2017-01-27 06:35:16 +00:00
RuleFor ( c = > c . Port ) . InclusiveBetween ( 1 , 65535 ) ;
2017-01-13 16:21:34 +00:00
RuleFor ( c = > c . MovieCategory ) . NotEmpty ( )
2015-08-04 22:13:57 +00:00
. WithMessage ( "A category is recommended" )
2017-01-27 06:35:16 +00:00
. AsWarning ( ) ;
2015-05-08 18:50:22 +00:00
}
}
public class RTorrentSettings : IProviderConfig
{
private static readonly RTorrentSettingsValidator Validator = new RTorrentSettingsValidator ( ) ;
public RTorrentSettings ( )
{
Host = "localhost" ;
Port = 8080 ;
UrlBase = "RPC2" ;
2017-02-07 00:51:30 +00:00
MovieCategory = "radarr" ;
2015-05-08 18:50:22 +00:00
}
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
public string Host { get ; set ; }
[FieldDefinition(1, Label = "Port", Type = FieldType.Textbox)]
public int Port { get ; set ; }
2015-10-02 12:35:31 +00:00
[FieldDefinition(2, Label = "Url Path", Type = FieldType.Textbox, HelpText = "Path to the XMLRPC endpoint, see http(s)://[host] : [ port ] / [ urlPath ] . When using ruTorrent this usually is RPC2 or ( path to ruTorrent ) / plugins / rpc / rpc . php ")]
2015-05-08 18:50:22 +00:00
public string UrlBase { get ; set ; }
[FieldDefinition(3, Label = "Use SSL", Type = FieldType.Checkbox)]
public bool UseSsl { get ; set ; }
[FieldDefinition(4, Label = "Username", Type = FieldType.Textbox)]
public string Username { get ; set ; }
[FieldDefinition(5, Label = "Password", Type = FieldType.Password)]
public string Password { get ; set ; }
2017-01-12 02:59:13 +00:00
[FieldDefinition(6, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional.")]
2017-01-13 16:21:34 +00:00
public string MovieCategory { get ; set ; }
2015-05-08 18:50:22 +00:00
2015-07-08 08:11:33 +00:00
[FieldDefinition(7, Label = "Directory", Type = FieldType.Textbox, Advanced = true, HelpText = "Optional location to put downloads in, leave blank to use the default rTorrent location")]
2017-01-13 16:21:34 +00:00
public string MovieDirectory { get ; set ; }
2015-05-08 18:50:22 +00:00
public NzbDroneValidationResult Validate ( )
{
return new NzbDroneValidationResult ( Validator . Validate ( this ) ) ;
}
}
}