2018-04-15 03:03:32 +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";
|
2019-07-01 01:50:01 +00:00
|
|
|
OlderMoviePriority = (int)RTorrentPriority.Normal;
|
|
|
|
RecentMoviePriority = (int)RTorrentPriority.Normal;
|
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; }
|
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(2, Label = "UseSsl", Type = FieldType.Checkbox, HelpText = "DownloadClientSettingsUseSslHelpText")]
|
|
|
|
[FieldToken(TokenField.HelpText, "UseSsl", "clientName", "rTorrent")]
|
2015-05-08 18:50:22 +00:00
|
|
|
public bool UseSsl { get; set; }
|
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(3, Label = "DownloadClientRTorrentSettingsUrlPath", Type = FieldType.Textbox, HelpText = "DownloadClientRTorrentSettingsUrlPathHelpText")]
|
|
|
|
[FieldToken(TokenField.HelpText, "DownloadClientRTorrentSettingsUrlPath", "url", "http(s)://[host]:[port]/[urlPath]")]
|
|
|
|
[FieldToken(TokenField.HelpText, "DownloadClientRTorrentSettingsUrlPath", "url2", "/plugins/rpc/rpc.php")]
|
2021-03-08 22:59:11 +00:00
|
|
|
public string UrlBase { get; set; }
|
|
|
|
|
2020-10-17 03:27:01 +00:00
|
|
|
[FieldDefinition(4, Label = "Username", Type = FieldType.Textbox, Privacy = PrivacyLevel.UserName)]
|
2015-05-08 18:50:22 +00:00
|
|
|
public string Username { get; set; }
|
|
|
|
|
2020-10-17 03:27:01 +00:00
|
|
|
[FieldDefinition(5, Label = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
|
2015-05-08 18:50:22 +00:00
|
|
|
public string Password { get; set; }
|
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(6, Label = "Category", Type = FieldType.Textbox, HelpText = "DownloadClientSettingsCategoryHelpText")]
|
2017-01-13 16:21:34 +00:00
|
|
|
public string MovieCategory { get; set; }
|
2015-05-08 18:50:22 +00:00
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(7, Label = "PostImportCategory", Type = FieldType.Textbox, Advanced = true, HelpText = "DownloadClientSettingsPostImportCategoryHelpText")]
|
2019-07-01 01:50:01 +00:00
|
|
|
public string MovieImportedCategory { get; set; }
|
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(8, Label = "Directory", Type = FieldType.Textbox, Advanced = true, HelpText = "DownloadClientRTorrentSettingsDirectoryHelpText")]
|
2017-01-13 16:21:34 +00:00
|
|
|
public string MovieDirectory { get; set; }
|
2015-05-08 18:50:22 +00:00
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(9, Label = "DownloadClientSettingsRecentPriority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "DownloadClientSettingsRecentPriorityMovieHelpText")]
|
2018-04-15 03:03:32 +00:00
|
|
|
public int RecentMoviePriority { get; set; }
|
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(10, Label = "DownloadClientSettingsOlderPriority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "DownloadClientSettingsOlderPriorityMovieHelpText")]
|
2018-04-15 03:03:32 +00:00
|
|
|
public int OlderMoviePriority { get; set; }
|
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(11, Label = "DownloadClientRTorrentSettingsAddStopped", Type = FieldType.Checkbox, HelpText = "DownloadClientRTorrentSettingsAddStoppedHelpText")]
|
2019-06-14 03:54:25 +00:00
|
|
|
public bool AddStopped { get; set; }
|
2018-12-07 10:26:26 +00:00
|
|
|
|
2015-05-08 18:50:22 +00:00
|
|
|
public NzbDroneValidationResult Validate()
|
|
|
|
{
|
|
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|