2019-04-13 03:25:58 +00:00
|
|
|
using FluentValidation;
|
2022-04-22 03:49:09 +00:00
|
|
|
using NzbDrone.Common.Extensions;
|
2013-05-19 23:17:32 +00:00
|
|
|
using NzbDrone.Core.Annotations;
|
2015-03-17 04:33:34 +00:00
|
|
|
using NzbDrone.Core.Validation;
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2019-04-13 03:25:58 +00:00
|
|
|
namespace NzbDrone.Core.Notifications.Plex.Server
|
2013-05-19 23:17:32 +00:00
|
|
|
{
|
2013-10-12 18:44:40 +00:00
|
|
|
public class PlexServerSettingsValidator : AbstractValidator<PlexServerSettings>
|
|
|
|
{
|
|
|
|
public PlexServerSettingsValidator()
|
|
|
|
{
|
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);
|
2022-04-22 03:49:09 +00:00
|
|
|
RuleFor(c => c.MapFrom).NotEmpty().Unless(c => c.MapTo.IsNullOrWhiteSpace());
|
|
|
|
RuleFor(c => c.MapTo).NotEmpty().Unless(c => c.MapFrom.IsNullOrWhiteSpace());
|
2013-10-12 18:44:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-14 04:16:26 +00:00
|
|
|
public class PlexServerSettings : NotificationSettingsBase<PlexServerSettings>
|
2013-05-19 23:17:32 +00:00
|
|
|
{
|
2024-04-14 04:16:26 +00:00
|
|
|
private static readonly PlexServerSettingsValidator Validator = new ();
|
2013-10-12 18:44:40 +00:00
|
|
|
|
2013-08-09 06:22:26 +00:00
|
|
|
public PlexServerSettings()
|
|
|
|
{
|
|
|
|
Port = 32400;
|
2016-02-26 03:19:31 +00:00
|
|
|
UpdateLibrary = true;
|
2019-04-13 03:25:58 +00:00
|
|
|
SignIn = "startOAuth";
|
2013-08-09 06:22:26 +00:00
|
|
|
}
|
|
|
|
|
2013-06-28 01:55:45 +00:00
|
|
|
[FieldDefinition(0, Label = "Host")]
|
2015-10-03 17:45:26 +00:00
|
|
|
public string Host { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2013-06-13 06:41:26 +00:00
|
|
|
[FieldDefinition(1, Label = "Port")]
|
2015-10-03 17:45:26 +00:00
|
|
|
public int Port { get; set; }
|
2013-06-13 06:41:26 +00:00
|
|
|
|
2024-01-03 20:41:16 +00:00
|
|
|
[FieldDefinition(2, Label = "UseSsl", Type = FieldType.Checkbox, HelpText = "NotificationsSettingsUseSslHelpText")]
|
|
|
|
[FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Plex")]
|
2019-04-13 03:25:58 +00:00
|
|
|
public bool UseSsl { get; set; }
|
2014-04-07 02:44:04 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(3, Label = "UrlBase", Type = FieldType.Textbox, Advanced = true, HelpText = "ConnectionSettingsUrlBaseHelpText")]
|
|
|
|
[FieldToken(TokenField.HelpText, "UrlBase", "connectionName", "Plex")]
|
|
|
|
[FieldToken(TokenField.HelpText, "UrlBase", "url", "http://[host]:[port]/[urlBase]/plex")]
|
|
|
|
public string UrlBase { get; set; }
|
|
|
|
|
|
|
|
[FieldDefinition(4, Label = "NotificationsPlexSettingsAuthToken", Type = FieldType.Textbox, Privacy = PrivacyLevel.ApiKey, Advanced = true)]
|
2019-04-13 03:25:58 +00:00
|
|
|
public string AuthToken { get; set; }
|
2014-04-07 02:44:04 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(5, Label = "NotificationsPlexSettingsAuthenticateWithPlexTv", Type = FieldType.OAuth)]
|
2019-04-13 03:25:58 +00:00
|
|
|
public string SignIn { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(6, Label = "NotificationsSettingsUpdateLibrary", Type = FieldType.Checkbox)]
|
2019-04-13 03:25:58 +00:00
|
|
|
public bool UpdateLibrary { get; set; }
|
2015-06-04 21:10:38 +00:00
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(7, Label = "NotificationsSettingsUpdateMapPathsFrom", Type = FieldType.Textbox, Advanced = true, HelpText = "NotificationsSettingsUpdateMapPathsFromHelpText")]
|
2024-01-03 20:41:16 +00:00
|
|
|
[FieldToken(TokenField.HelpText, "NotificationsSettingsUpdateMapPathsFrom", "serviceName", "Plex")]
|
2022-04-22 03:49:09 +00:00
|
|
|
public string MapFrom { get; set; }
|
|
|
|
|
2024-02-28 05:03:35 +00:00
|
|
|
[FieldDefinition(8, Label = "NotificationsSettingsUpdateMapPathsTo", Type = FieldType.Textbox, Advanced = true, HelpText = "NotificationsSettingsUpdateMapPathsToHelpText")]
|
2024-01-03 20:41:16 +00:00
|
|
|
[FieldToken(TokenField.HelpText, "NotificationsSettingsUpdateMapPathsTo", "serviceName", "Plex")]
|
2022-04-22 03:49:09 +00:00
|
|
|
public string MapTo { get; set; }
|
|
|
|
|
2016-12-09 06:54:15 +00:00
|
|
|
public bool IsValid => !string.IsNullOrWhiteSpace(Host);
|
2013-09-21 07:09:26 +00:00
|
|
|
|
2024-04-14 04:16:26 +00:00
|
|
|
public override NzbDroneValidationResult Validate()
|
2013-09-21 07:09:26 +00:00
|
|
|
{
|
2015-03-17 04:33:34 +00:00
|
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
2013-09-21 07:09:26 +00:00
|
|
|
}
|
2013-05-19 23:17:32 +00:00
|
|
|
}
|
|
|
|
}
|