Skip to content

Commit 9fd193d

Browse files
committed
New: URL Base setting for Media Server connections
Closes Sonarr#4416
1 parent 64f4365 commit 9fd193d

File tree

6 files changed

+38
-21
lines changed

6 files changed

+38
-21
lines changed

src/NzbDrone.Core/Localization/Core/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
"ConnectionLostReconnect": "{appName} will try to connect automatically, or you can click reload below.",
248248
"ConnectionLostToBackend": "{appName} has lost its connection to the backend and will need to be reloaded to restore functionality.",
249249
"Connections": "Connections",
250+
"ConnectionSettingsUrlBaseHelpText": "Adds a prefix to the {connectionName} url, such as {url}",
250251
"Continuing": "Continuing",
251252
"ContinuingOnly": "Continuing Only",
252253
"ContinuingSeriesDescription": "More episodes/another season is expected",

src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Net;
44
using FluentValidation.Results;
@@ -61,7 +61,7 @@ public ValidationFailure Test(MediaBrowserSettings settings)
6161
{
6262
try
6363
{
64-
_logger.Debug("Testing connection to MediaBrowser: {0}", settings.Address);
64+
_logger.Debug("Testing connection to Emby/Jellyfin : {0}", settings.Address);
6565

6666
Notify(settings, "Test from Sonarr", "Success! MediaBrowser has been successfully configured!");
6767
}

src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserSettings.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public MediaBrowserSettingsValidator()
1515
RuleFor(c => c.ApiKey).NotEmpty();
1616
RuleFor(c => c.MapFrom).NotEmpty().Unless(c => c.MapTo.IsNullOrWhiteSpace());
1717
RuleFor(c => c.MapTo).NotEmpty().Unless(c => c.MapFrom.IsNullOrWhiteSpace());
18+
RuleFor(c => c.UrlBase).ValidUrlBase();
1819
}
1920
}
2021

@@ -37,25 +38,30 @@ public MediaBrowserSettings()
3738
[FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Emby/Jellyfin")]
3839
public bool UseSsl { get; set; }
3940

40-
[FieldDefinition(3, Label = "ApiKey", Privacy = PrivacyLevel.ApiKey)]
41+
[FieldDefinition(3, Label = "UrlBase", Type = FieldType.Textbox, Advanced = true, HelpText = "ConnectionSettingsUrlBaseHelpText")]
42+
[FieldToken(TokenField.HelpText, "UrlBase", "connectionName", "Emby/Jellyfin")]
43+
[FieldToken(TokenField.HelpText, "UrlBase", "url", "http://[host]:[port]/[urlBase]/mediabrowser")]
44+
public string UrlBase { get; set; }
45+
46+
[FieldDefinition(4, Label = "ApiKey", Privacy = PrivacyLevel.ApiKey)]
4147
public string ApiKey { get; set; }
4248

43-
[FieldDefinition(4, Label = "NotificationsEmbySettingsSendNotifications", HelpText = "NotificationsEmbySettingsSendNotificationsHelpText", Type = FieldType.Checkbox)]
49+
[FieldDefinition(5, Label = "NotificationsEmbySettingsSendNotifications", HelpText = "NotificationsEmbySettingsSendNotificationsHelpText", Type = FieldType.Checkbox)]
4450
public bool Notify { get; set; }
4551

46-
[FieldDefinition(5, Label = "NotificationsSettingsUpdateLibrary", HelpText = "NotificationsEmbySettingsUpdateLibraryHelpText", Type = FieldType.Checkbox)]
52+
[FieldDefinition(6, Label = "NotificationsSettingsUpdateLibrary", HelpText = "NotificationsEmbySettingsUpdateLibraryHelpText", Type = FieldType.Checkbox)]
4753
public bool UpdateLibrary { get; set; }
4854

49-
[FieldDefinition(6, Label = "NotificationsSettingsUpdateMapPathsFrom", HelpText = "NotificationsSettingsUpdateMapPathsFromHelpText", Type = FieldType.Textbox, Advanced = true)]
55+
[FieldDefinition(7, Label = "NotificationsSettingsUpdateMapPathsFrom", HelpText = "NotificationsSettingsUpdateMapPathsFromHelpText", Type = FieldType.Textbox, Advanced = true)]
5056
[FieldToken(TokenField.HelpText, "NotificationsSettingsUpdateMapPathsFrom", "serviceName", "Emby/Jellyfin")]
5157
public string MapFrom { get; set; }
5258

53-
[FieldDefinition(7, Label = "NotificationsSettingsUpdateMapPathsTo", HelpText = "NotificationsSettingsUpdateMapPathsToHelpText", Type = FieldType.Textbox, Advanced = true)]
59+
[FieldDefinition(8, Label = "NotificationsSettingsUpdateMapPathsTo", HelpText = "NotificationsSettingsUpdateMapPathsToHelpText", Type = FieldType.Textbox, Advanced = true)]
5460
[FieldToken(TokenField.HelpText, "NotificationsSettingsUpdateMapPathsTo", "serviceName", "Emby/Jellyfin")]
5561
public string MapTo { get; set; }
5662

5763
[JsonIgnore]
58-
public string Address => $"{Host.ToUrlHost()}:{Port}";
64+
public string Address => $"{Host.ToUrlHost()}:{Port}{UrlBase}";
5965

6066
public bool IsValid => !string.IsNullOrWhiteSpace(Host) && Port > 0;
6167

src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private HttpRequestBuilder BuildRequest(string resource, HttpMethod method, Plex
9494
{
9595
var scheme = settings.UseSsl ? "https" : "http";
9696

97-
var requestBuilder = new HttpRequestBuilder($"{scheme}://{settings.Host.ToUrlHost()}:{settings.Port}")
97+
var requestBuilder = new HttpRequestBuilder($"{scheme}://{settings.Host.ToUrlHost()}:{settings.Port}{settings.UrlBase}")
9898
.Accept(HttpAccept.Json)
9999
.AddQueryParam("X-Plex-Client-Identifier", _configService.PlexClientIdentifier)
100100
.AddQueryParam("X-Plex-Product", BuildInfo.AppName)

src/NzbDrone.Core/Notifications/Plex/Server/PlexServerSettings.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,25 @@ public PlexServerSettings()
3838
[FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Plex")]
3939
public bool UseSsl { get; set; }
4040

41-
[FieldDefinition(3, Label = "NotificationsPlexSettingsAuthToken", Type = FieldType.Textbox, Privacy = PrivacyLevel.ApiKey, Advanced = true)]
41+
[FieldDefinition(3, Label = "UrlBase", Type = FieldType.Textbox, Advanced = true, HelpText = "ConnectionSettingsUrlBaseHelpText")]
42+
[FieldToken(TokenField.HelpText, "UrlBase", "connectionName", "Plex")]
43+
[FieldToken(TokenField.HelpText, "UrlBase", "url", "http://[host]:[port]/[urlBase]/plex")]
44+
public string UrlBase { get; set; }
45+
46+
[FieldDefinition(4, Label = "NotificationsPlexSettingsAuthToken", Type = FieldType.Textbox, Privacy = PrivacyLevel.ApiKey, Advanced = true)]
4247
public string AuthToken { get; set; }
4348

44-
[FieldDefinition(4, Label = "NotificationsPlexSettingsAuthenticateWithPlexTv", Type = FieldType.OAuth)]
49+
[FieldDefinition(5, Label = "NotificationsPlexSettingsAuthenticateWithPlexTv", Type = FieldType.OAuth)]
4550
public string SignIn { get; set; }
4651

47-
[FieldDefinition(5, Label = "NotificationsSettingsUpdateLibrary", Type = FieldType.Checkbox)]
52+
[FieldDefinition(6, Label = "NotificationsSettingsUpdateLibrary", Type = FieldType.Checkbox)]
4853
public bool UpdateLibrary { get; set; }
4954

50-
[FieldDefinition(6, Label = "NotificationsSettingsUpdateMapPathsFrom", Type = FieldType.Textbox, Advanced = true, HelpText = "NotificationsSettingsUpdateMapPathsFromHelpText")]
55+
[FieldDefinition(7, Label = "NotificationsSettingsUpdateMapPathsFrom", Type = FieldType.Textbox, Advanced = true, HelpText = "NotificationsSettingsUpdateMapPathsFromHelpText")]
5156
[FieldToken(TokenField.HelpText, "NotificationsSettingsUpdateMapPathsFrom", "serviceName", "Plex")]
5257
public string MapFrom { get; set; }
5358

54-
[FieldDefinition(7, Label = "NotificationsSettingsUpdateMapPathsTo", Type = FieldType.Textbox, Advanced = true, HelpText = "NotificationsSettingsUpdateMapPathsToHelpText")]
59+
[FieldDefinition(8, Label = "NotificationsSettingsUpdateMapPathsTo", Type = FieldType.Textbox, Advanced = true, HelpText = "NotificationsSettingsUpdateMapPathsToHelpText")]
5560
[FieldToken(TokenField.HelpText, "NotificationsSettingsUpdateMapPathsTo", "serviceName", "Plex")]
5661
public string MapTo { get; set; }
5762

src/NzbDrone.Core/Notifications/Xbmc/XbmcSettings.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,31 @@ public XbmcSettings()
3737
[FieldToken(TokenField.HelpText, "UseSsl", "serviceName", "Kodi")]
3838
public bool UseSsl { get; set; }
3939

40-
[FieldDefinition(3, Label = "Username", Privacy = PrivacyLevel.UserName)]
40+
[FieldDefinition(3, Label = "UrlBase", Type = FieldType.Textbox, Advanced = true, HelpText = "ConnectionSettingsUrlBaseHelpText")]
41+
[FieldToken(TokenField.HelpText, "UrlBase", "connectionName", "Kodi")]
42+
[FieldToken(TokenField.HelpText, "UrlBase", "url", "http://[host]:[port]/[urlBase]/kodi")]
43+
public string UrlBase { get; set; }
44+
45+
[FieldDefinition(4, Label = "Username", Privacy = PrivacyLevel.UserName)]
4146
public string Username { get; set; }
4247

43-
[FieldDefinition(4, Label = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
48+
[FieldDefinition(5, Label = "Password", Type = FieldType.Password, Privacy = PrivacyLevel.Password)]
4449
public string Password { get; set; }
4550

4651
[DefaultValue(5)]
47-
[FieldDefinition(5, Label = "NotificationsKodiSettingsDisplayTime", HelpText = "NotificationsKodiSettingsDisplayTimeHelpText")]
52+
[FieldDefinition(6, Label = "NotificationsKodiSettingsDisplayTime", HelpText = "NotificationsKodiSettingsDisplayTimeHelpText")]
4853
public int DisplayTime { get; set; }
4954

50-
[FieldDefinition(6, Label = "NotificationsKodiSettingsGuiNotification", Type = FieldType.Checkbox)]
55+
[FieldDefinition(7, Label = "NotificationsKodiSettingsGuiNotification", Type = FieldType.Checkbox)]
5156
public bool Notify { get; set; }
5257

53-
[FieldDefinition(7, Label = "NotificationsSettingsUpdateLibrary", HelpText = "NotificationsKodiSettingsUpdateLibraryHelpText", Type = FieldType.Checkbox)]
58+
[FieldDefinition(8, Label = "NotificationsSettingsUpdateLibrary", HelpText = "NotificationsKodiSettingsUpdateLibraryHelpText", Type = FieldType.Checkbox)]
5459
public bool UpdateLibrary { get; set; }
5560

56-
[FieldDefinition(8, Label = "NotificationsKodiSettingsCleanLibrary", HelpText = "NotificationsKodiSettingsCleanLibraryHelpText", Type = FieldType.Checkbox)]
61+
[FieldDefinition(9, Label = "NotificationsKodiSettingsCleanLibrary", HelpText = "NotificationsKodiSettingsCleanLibraryHelpText", Type = FieldType.Checkbox)]
5762
public bool CleanLibrary { get; set; }
5863

59-
[FieldDefinition(9, Label = "NotificationsKodiSettingAlwaysUpdate", HelpText = "NotificationsKodiSettingAlwaysUpdateHelpText", Type = FieldType.Checkbox)]
64+
[FieldDefinition(10, Label = "NotificationsKodiSettingAlwaysUpdate", HelpText = "NotificationsKodiSettingAlwaysUpdateHelpText", Type = FieldType.Checkbox)]
6065
public bool AlwaysUpdate { get; set; }
6166

6267
[JsonIgnore]

0 commit comments

Comments
 (0)