From d6c631457c53aea06883da82d34347198bf0643f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 27 Feb 2024 21:03:35 -0800 Subject: [PATCH] New: URL Base setting for Plex Server connections Plus some translations (cherry picked from commit 9fd193d2a82d5c2cdc0f36c1f984e4b6b68aaa8d) --- src/NzbDrone.Core/Localization/Core/en.json | 9 +++++++++ .../Plex/Server/PlexServerProxy.cs | 2 +- .../Plex/Server/PlexServerSettings.cs | 20 +++++++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index f25855769..32e539e90 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -167,6 +167,7 @@ "ConnectionLost": "Connection Lost", "ConnectionLostReconnect": "{appName} will try to connect automatically, or you can click reload below.", "ConnectionLostToBackend": "{appName} has lost its connection to the backend and will need to be reloaded to restore functionality.", + "ConnectionSettingsUrlBaseHelpText": "Adds a prefix to the {connectionName} url, such as {url}", "Connections": "Connections", "ConsoleLogLevel": "Console Log Level", "Continuing": "Continuing", @@ -620,6 +621,14 @@ "NotificationStatusAllClientHealthCheckMessage": "All notifications are unavailable due to failures", "NotificationStatusSingleClientHealthCheckMessage": "Notifications unavailable due to failures: {0}", "NotificationTriggers": "Notification Triggers", + "NotificationsPlexSettingsAuthToken": "Auth Token", + "NotificationsPlexSettingsAuthenticateWithPlexTv": "Authenticate with Plex.tv", + "NotificationsSettingsUpdateLibrary": "Update Library", + "NotificationsSettingsUpdateMapPathsFrom": "Map Paths From", + "NotificationsSettingsUpdateMapPathsFromHelpText": "{appName} path, used to modify series paths when {serviceName} sees library path location differently from {appName} (Requires 'Update Library')", + "NotificationsSettingsUpdateMapPathsTo": "Map Paths To", + "NotificationsSettingsUpdateMapPathsToHelpText": "{serviceName} path, used to modify series paths when {serviceName} sees library path location differently from {appName} (Requires 'Update Library')", + "NotificationsSettingsUseSslHelpText": "Connect to {serviceName} over HTTPS instead of HTTP", "OnApplicationUpdate": "On Application Update", "OnApplicationUpdateHelpText": "On Application Update", "OnAuthorAdded": "On Author Added", diff --git a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs index a1be8ce1f..b4c782fb4 100644 --- a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs +++ b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs @@ -94,7 +94,7 @@ namespace NzbDrone.Core.Notifications.Plex.Server { var scheme = settings.UseSsl ? "https" : "http"; - var requestBuilder = new HttpRequestBuilder($"{scheme}://{settings.Host.ToUrlHost()}:{settings.Port}") + var requestBuilder = new HttpRequestBuilder($"{scheme}://{settings.Host.ToUrlHost()}:{settings.Port}{settings.UrlBase}") .Accept(HttpAccept.Json) .AddQueryParam("X-Plex-Client-Identifier", _configService.PlexClientIdentifier) .AddQueryParam("X-Plex-Product", BuildInfo.AppName) diff --git a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerSettings.cs b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerSettings.cs index e5b6d6537..de76f9eef 100644 --- a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerSettings.cs +++ b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerSettings.cs @@ -34,22 +34,30 @@ namespace NzbDrone.Core.Notifications.Plex.Server [FieldDefinition(1, Label = "Port")] public int Port { get; set; } - [FieldDefinition(2, Label = "Use SSL", Type = FieldType.Checkbox, HelpText = "Connect to Plex over HTTPS instead of HTTP")] + [FieldDefinition(2, Label = "UseSsl", Type = FieldType.Checkbox, HelpText = "NotificationsSettingsUseSslHelpText")] + [FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Plex")] public bool UseSsl { get; set; } - [FieldDefinition(3, Label = "Auth Token", Type = FieldType.Textbox, Privacy = PrivacyLevel.ApiKey, Advanced = true)] + [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)] public string AuthToken { get; set; } - [FieldDefinition(4, Label = "Authenticate with Plex.tv", Type = FieldType.OAuth)] + [FieldDefinition(5, Label = "NotificationsPlexSettingsAuthenticateWithPlexTv", Type = FieldType.OAuth)] public string SignIn { get; set; } - [FieldDefinition(5, Label = "Update Library", Type = FieldType.Checkbox)] + [FieldDefinition(6, Label = "NotificationsSettingsUpdateLibrary", Type = FieldType.Checkbox)] public bool UpdateLibrary { get; set; } - [FieldDefinition(6, Label = "Map Paths From", Type = FieldType.Textbox, Advanced = true, HelpText = "Readarr path, used to modify author paths when Plex sees library path location differently from Readarr")] + [FieldDefinition(7, Label = "NotificationsSettingsUpdateMapPathsFrom", Type = FieldType.Textbox, Advanced = true, HelpText = "NotificationsSettingsUpdateMapPathsFromHelpText")] + [FieldToken(TokenField.HelpText, "NotificationsSettingsUpdateMapPathsFrom", "serviceName", "Plex")] public string MapFrom { get; set; } - [FieldDefinition(7, Label = "Map Paths To", Type = FieldType.Textbox, Advanced = true, HelpText = "Plex path, used to modify author paths when Plex sees library path location differently from Readarr")] + [FieldDefinition(8, Label = "NotificationsSettingsUpdateMapPathsTo", Type = FieldType.Textbox, Advanced = true, HelpText = "NotificationsSettingsUpdateMapPathsToHelpText")] + [FieldToken(TokenField.HelpText, "NotificationsSettingsUpdateMapPathsTo", "serviceName", "Plex")] public string MapTo { get; set; } public bool IsValid => !string.IsNullOrWhiteSpace(Host);