From f6529d5ad3059a6bd1f4430cec47d257ec0e0bc7 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 Media Server connections Plus some translations (cherry picked from commit 9fd193d2a82d5c2cdc0f36c1f984e4b6b68aaa8d) --- src/NzbDrone.Core/Localization/Core/en.json | 21 ++++++++++++++++++ .../MediaBrowser/MediaBrowserService.cs | 2 +- .../MediaBrowser/MediaBrowserSettings.cs | 17 +++++++++----- .../Plex/Server/PlexServerProxy.cs | 2 +- .../Plex/Server/PlexServerSettings.cs | 20 ++++++++++++----- .../Notifications/Xbmc/XbmcSettings.cs | 22 ++++++++++++------- 6 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 077e7e289..ff5d7380b 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -225,6 +225,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", "Continuing": "Continuing", "ContinuingAllTracksDownloaded": "Continuing (All tracks downloaded)", @@ -771,6 +772,25 @@ "NotificationStatusAllClientHealthCheckMessage": "All notifications are unavailable due to failures", "NotificationStatusSingleClientHealthCheckMessage": "Notifications unavailable due to failures: {0}", "NotificationTriggers": "Notification Triggers", + "NotificationsEmbySettingsSendNotifications": "Send Notifications", + "NotificationsEmbySettingsSendNotificationsHelpText": "Have MediaBrowser send notifications to configured providers", + "NotificationsEmbySettingsUpdateLibraryHelpText": "Update Library on Import, Rename, or Delete?", + "NotificationsKodiSettingAlwaysUpdate": "Always Update", + "NotificationsKodiSettingAlwaysUpdateHelpText": "Update library even when a video is playing?", + "NotificationsKodiSettingsCleanLibrary": "Clean Library", + "NotificationsKodiSettingsCleanLibraryHelpText": "Clean library after update", + "NotificationsKodiSettingsDisplayTime": "Display Time", + "NotificationsKodiSettingsDisplayTimeHelpText": "How long the notification will be displayed for (In seconds)", + "NotificationsKodiSettingsGuiNotification": "GUI Notification", + "NotificationsKodiSettingsUpdateLibraryHelpText": "Update library on Import & Rename?", + "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", "Ok": "Ok", "OnAlbumDelete": "On Album Delete", "OnApplicationUpdate": "On Application Update", @@ -1228,6 +1248,7 @@ "UrlBaseHelpTextWarning": "Requires restart to take effect", "UseHardlinksInsteadOfCopy": "Use Hardlinks instead of Copy", "UseProxy": "Use Proxy", + "UseSsl": "Use SSL", "Usenet": "Usenet", "UsenetDelay": "Usenet Delay", "UsenetDelayHelpText": "Delay in minutes to wait before grabbing a release from Usenet", diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs index 8a7216411..3d92d5c18 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs @@ -44,7 +44,7 @@ namespace NzbDrone.Core.Notifications.Emby { try { - _logger.Debug("Testing connection to MediaBrowser: {0}", settings.Address); + _logger.Debug("Testing connection to Emby/Jellyfin : {0}", settings.Address); Notify(settings, "Test from Lidarr", "Success! MediaBrowser has been successfully configured!"); } diff --git a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserSettings.cs b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserSettings.cs index add572239..a3f344516 100644 --- a/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserSettings.cs +++ b/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserSettings.cs @@ -13,6 +13,7 @@ namespace NzbDrone.Core.Notifications.Emby { RuleFor(c => c.Host).ValidHost(); RuleFor(c => c.ApiKey).NotEmpty(); + RuleFor(c => c.UrlBase).ValidUrlBase(); } } @@ -31,20 +32,26 @@ namespace NzbDrone.Core.Notifications.Emby [FieldDefinition(1, Label = "Port")] public int Port { get; set; } - [FieldDefinition(2, Label = "Use SSL", Type = FieldType.Checkbox, HelpText = "Connect to Emby over HTTPS instead of HTTP")] + [FieldDefinition(2, Label = "UseSsl", Type = FieldType.Checkbox, HelpText = "NotificationsSettingsUseSslHelpText")] + [FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Emby/Jellyfin")] public bool UseSsl { get; set; } - [FieldDefinition(3, Label = "API Key", Privacy = PrivacyLevel.ApiKey)] + [FieldDefinition(3, Label = "UrlBase", Type = FieldType.Textbox, Advanced = true, HelpText = "ConnectionSettingsUrlBaseHelpText")] + [FieldToken(TokenField.HelpText, "UrlBase", "connectionName", "Emby/Jellyfin")] + [FieldToken(TokenField.HelpText, "UrlBase", "url", "http://[host]:[port]/[urlBase]/mediabrowser")] + public string UrlBase { get; set; } + + [FieldDefinition(4, Label = "ApiKey", Privacy = PrivacyLevel.ApiKey)] public string ApiKey { get; set; } - [FieldDefinition(4, Label = "Send Notifications", HelpText = "Have MediaBrowser send notifications to configured providers", Type = FieldType.Checkbox)] + [FieldDefinition(5, Label = "NotificationsEmbySettingsSendNotifications", HelpText = "NotificationsEmbySettingsSendNotificationsHelpText", Type = FieldType.Checkbox)] public bool Notify { get; set; } - [FieldDefinition(5, Label = "Update Library", HelpText = "Update Library on Import, Rename, & Delete?", Type = FieldType.Checkbox)] + [FieldDefinition(6, Label = "NotificationsSettingsUpdateLibrary", HelpText = "NotificationsEmbySettingsUpdateLibraryHelpText", Type = FieldType.Checkbox)] public bool UpdateLibrary { get; set; } [JsonIgnore] - public string Address => $"{Host.ToUrlHost()}:{Port}"; + public string Address => $"{Host.ToUrlHost()}:{Port}{UrlBase}"; public bool IsValid => !string.IsNullOrWhiteSpace(Host) && Port > 0; diff --git a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs index cceed18b7..53d14012d 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 6d125168d..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 = "Lidarr path, used to modify series paths when Plex sees library path location differently from Lidarr")] + [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 series paths when Plex sees library path location differently from Lidarr")] + [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); diff --git a/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs b/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs index 8f2e00870..2d54157f2 100644 --- a/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs +++ b/src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs @@ -33,29 +33,35 @@ namespace NzbDrone.Core.Notifications.Xbmc [FieldDefinition(1, Label = "Port")] public int Port { get; set; } - [FieldDefinition(2, Label = "Use SSL", Type = FieldType.Checkbox, HelpText = "Connect to Kodi over HTTPS instead of HTTP")] + [FieldDefinition(2, Label = "UseSsl", Type = FieldType.Checkbox, HelpText = "NotificationsSettingsUseSslHelpText")] + [FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Kodi")] public bool UseSsl { get; set; } - [FieldDefinition(3, Label = "Username", Privacy = PrivacyLevel.UserName)] + [FieldDefinition(3, Label = "UrlBase", Type = FieldType.Textbox, Advanced = true, HelpText = "ConnectionSettingsUrlBaseHelpText")] + [FieldToken(TokenField.HelpText, "UrlBase", "connectionName", "Kodi")] + [FieldToken(TokenField.HelpText, "UrlBase", "url", "http://[host]:[port]/[urlBase]/kodi")] + public string UrlBase { get; set; } + + [FieldDefinition(4, Label = "Username", Privacy = PrivacyLevel.UserName)] public string Username { get; set; } - [FieldDefinition(4, Label = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)] + [FieldDefinition(5, Label = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)] public string Password { get; set; } [DefaultValue(5)] - [FieldDefinition(5, Label = "Display Time", HelpText = "How long the notification will be displayed for (In seconds)")] + [FieldDefinition(6, Label = "NotificationsKodiSettingsDisplayTime", HelpText = "NotificationsKodiSettingsDisplayTimeHelpText")] public int DisplayTime { get; set; } - [FieldDefinition(6, Label = "GUI Notification", Type = FieldType.Checkbox)] + [FieldDefinition(7, Label = "NotificationsKodiSettingsGuiNotification", Type = FieldType.Checkbox)] public bool Notify { get; set; } - [FieldDefinition(7, Label = "Update Library", HelpText = "Update Library on Import & Rename?", Type = FieldType.Checkbox)] + [FieldDefinition(8, Label = "NotificationsSettingsUpdateLibrary", HelpText = "NotificationsKodiSettingsUpdateLibraryHelpText", Type = FieldType.Checkbox)] public bool UpdateLibrary { get; set; } - [FieldDefinition(8, Label = "Clean Library", HelpText = "Clean Library after update?", Type = FieldType.Checkbox)] + [FieldDefinition(9, Label = "NotificationsKodiSettingsCleanLibrary", HelpText = "NotificationsKodiSettingsCleanLibraryHelpText", Type = FieldType.Checkbox)] public bool CleanLibrary { get; set; } - [FieldDefinition(9, Label = "Always Update", HelpText = "Update Library even when a file is playing?", Type = FieldType.Checkbox)] + [FieldDefinition(10, Label = "NotificationsKodiSettingAlwaysUpdate", HelpText = "NotificationsKodiSettingAlwaysUpdateHelpText", Type = FieldType.Checkbox)] public bool AlwaysUpdate { get; set; } [JsonIgnore]