2017-10-23 19:47:49 +00:00
|
|
|
using FluentValidation;
|
2019-02-24 17:16:12 +00:00
|
|
|
using NzbDrone.Common.Extensions;
|
2014-02-14 05:31:49 +00:00
|
|
|
using NzbDrone.Core.Annotations;
|
2015-02-17 23:43:33 +00:00
|
|
|
using NzbDrone.Core.Validation;
|
2014-02-14 05:31:49 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Download.Clients.Nzbget
|
|
|
|
{
|
|
|
|
public class NzbgetSettingsValidator : AbstractValidator<NzbgetSettings>
|
|
|
|
{
|
|
|
|
public NzbgetSettingsValidator()
|
|
|
|
{
|
2015-03-31 21:52:27 +00:00
|
|
|
RuleFor(c => c.Host).ValidHost();
|
2017-01-27 06:35:16 +00:00
|
|
|
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
|
2019-02-24 17:16:12 +00:00
|
|
|
RuleFor(c => c.UrlBase).ValidUrlBase().When(c => c.UrlBase.IsNotNullOrWhiteSpace());
|
|
|
|
|
2015-10-03 17:45:26 +00:00
|
|
|
RuleFor(c => c.Username).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Password));
|
|
|
|
RuleFor(c => c.Password).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Username));
|
2014-07-05 14:21:44 +00:00
|
|
|
|
2017-10-23 19:47:49 +00:00
|
|
|
RuleFor(c => c.MovieCategory).NotEmpty().WithMessage("A category is recommended").AsWarning();
|
2014-02-14 05:31:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-14 04:16:26 +00:00
|
|
|
public class NzbgetSettings : DownloadClientSettingsBase<NzbgetSettings>
|
2014-02-14 05:31:49 +00:00
|
|
|
{
|
2024-04-14 04:16:26 +00:00
|
|
|
private static readonly NzbgetSettingsValidator Validator = new ();
|
2014-02-14 05:31:49 +00:00
|
|
|
|
|
|
|
public NzbgetSettings()
|
|
|
|
{
|
|
|
|
Host = "localhost";
|
|
|
|
Port = 6789;
|
2017-10-23 19:47:49 +00:00
|
|
|
MovieCategory = "Movies";
|
2017-01-03 23:33:16 +00:00
|
|
|
Username = "nzbget";
|
|
|
|
Password = "tegbzn6789";
|
2018-04-15 03:03:32 +00:00
|
|
|
RecentMoviePriority = (int)NzbgetPriority.Normal;
|
|
|
|
OlderMoviePriority = (int)NzbgetPriority.Normal;
|
2014-02-14 05:31:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public string Host { get; set; }
|
2014-02-14 05:31:49 +00:00
|
|
|
|
|
|
|
[FieldDefinition(1, Label = "Port", Type = FieldType.Textbox)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public int Port { get; set; }
|
2014-02-14 05:31:49 +00:00
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(2, Label = "UseSsl", Type = FieldType.Checkbox, HelpText = "DownloadClientSettingsUseSslHelpText")]
|
|
|
|
[FieldToken(TokenField.HelpText, "UseSsl", "clientName", "NZBGet")]
|
2021-03-08 22:59:11 +00:00
|
|
|
public bool UseSsl { get; set; }
|
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(3, Label = "UrlBase", Type = FieldType.Textbox, Advanced = true, HelpText = "DownloadClientSettingsUrlBaseHelpText")]
|
|
|
|
[FieldToken(TokenField.HelpText, "UrlBase", "clientName", "NZBGet")]
|
|
|
|
[FieldToken(TokenField.HelpText, "UrlBase", "url", "http://[host]:[port]/[urlBase]/jsonrpc")]
|
2019-02-24 17:16:12 +00:00
|
|
|
public string UrlBase { get; set; }
|
|
|
|
|
2021-03-08 22:59:11 +00:00
|
|
|
[FieldDefinition(4, Label = "Username", Type = FieldType.Textbox, Privacy = PrivacyLevel.UserName)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public string Username { get; set; }
|
2014-02-14 05:31:49 +00:00
|
|
|
|
2021-03-08 22:59:11 +00:00
|
|
|
[FieldDefinition(5, Label = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
|
2015-10-03 17:45:26 +00:00
|
|
|
public string Password { get; set; }
|
2014-02-14 05:31:49 +00:00
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(6, Label = "Category", Type = FieldType.Textbox, HelpText = "DownloadClientSettingsCategoryHelpText")]
|
2019-12-22 21:24:11 +00:00
|
|
|
public string MovieCategory { get; set; }
|
2014-02-14 05:31:49 +00:00
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(7, Label = "DownloadClientSettingsRecentPriority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "DownloadClientSettingsRecentPriorityMovieHelpText")]
|
2018-04-15 03:03:32 +00:00
|
|
|
public int RecentMoviePriority { get; set; }
|
2014-02-14 05:31:49 +00:00
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(8, Label = "DownloadClientSettingsOlderPriority", Type = FieldType.Select, SelectOptions = typeof(NzbgetPriority), HelpText = "DownloadClientSettingsOlderPriorityMovieHelpText")]
|
2018-04-15 03:03:32 +00:00
|
|
|
public int OlderMoviePriority { get; set; }
|
2014-02-14 05:31:49 +00:00
|
|
|
|
2023-11-10 16:44:04 +00:00
|
|
|
[FieldDefinition(9, Label = "DownloadClientSettingsAddPaused", Type = FieldType.Checkbox, HelpText = "DownloadClientNzbgetSettingsAddPausedHelpText")]
|
2017-01-18 17:42:33 +00:00
|
|
|
public bool AddPaused { get; set; }
|
|
|
|
|
2024-04-14 04:16:26 +00:00
|
|
|
public override NzbDroneValidationResult Validate()
|
2014-02-14 05:31:49 +00:00
|
|
|
{
|
2015-03-17 04:33:34 +00:00
|
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
2014-02-14 05:31:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|