mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
New: Added optional UrlBase to Nzbget, Sabnzbd, and Subsonic settings (#428)
* New: Added optional UrlBase to Nzbget, Sabnzbd, and Subsonic settings Fixes #386 * fixup! Remove commented code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Rest;
|
||||
using RestSharp;
|
||||
using System.IO;
|
||||
@@ -9,6 +10,7 @@ namespace NzbDrone.Core.Notifications.Subsonic
|
||||
{
|
||||
public interface ISubsonicServerProxy
|
||||
{
|
||||
string GetBaseUrl(SubsonicSettings settings, string relativePath = null);
|
||||
void Notify(SubsonicSettings settings, string message);
|
||||
void Update(SubsonicSettings settings);
|
||||
string Version(SubsonicSettings settings);
|
||||
@@ -23,6 +25,14 @@ namespace NzbDrone.Core.Notifications.Subsonic
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public string GetBaseUrl(SubsonicSettings settings, string relativePath = null)
|
||||
{
|
||||
var baseUrl = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
|
||||
baseUrl = HttpUri.CombinePath(baseUrl, relativePath);
|
||||
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public void Notify(SubsonicSettings settings, string message)
|
||||
{
|
||||
var resource = "addChatMessage";
|
||||
@@ -68,9 +78,7 @@ namespace NzbDrone.Core.Notifications.Subsonic
|
||||
|
||||
private RestClient GetSubsonicServerClient(SubsonicSettings settings)
|
||||
{
|
||||
var protocol = settings.UseSsl ? "https" : "http";
|
||||
|
||||
return RestClientFactory.BuildClient(string.Format("{0}://{1}:{2}/rest", protocol, settings.Host, settings.Port));
|
||||
return RestClientFactory.BuildClient(GetBaseUrl(settings, "rest"));
|
||||
}
|
||||
|
||||
private RestRequest GetSubsonicServerRequest(string resource, Method method, SubsonicSettings settings)
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace NzbDrone.Core.Notifications.Subsonic
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.Debug("Determining version of Host: {0}", settings.Address);
|
||||
_logger.Debug("Determining version of Host: {0}", _proxy.GetBaseUrl(settings));
|
||||
var version = GetVersion(settings);
|
||||
_logger.Debug("Version is: {0}", version);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using FluentValidation;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation;
|
||||
@@ -11,6 +12,8 @@ namespace NzbDrone.Core.Notifications.Subsonic
|
||||
public SubsonicSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Host).ValidHost();
|
||||
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
|
||||
RuleFor(c => c.UrlBase).ValidUrlBase().When(c => c.UrlBase.IsNotNullOrWhiteSpace());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,24 +32,24 @@ namespace NzbDrone.Core.Notifications.Subsonic
|
||||
[FieldDefinition(1, Label = "Port")]
|
||||
public int Port { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Username")]
|
||||
[FieldDefinition(2, Label = "Url Base", Type = FieldType.Textbox, Advanced = true, HelpText = "Adds a prefix to the Subsonic url, e.g. http://[host]:[port]/[urlBase]/rest")]
|
||||
public string UrlBase { get; set; }
|
||||
|
||||
[FieldDefinition(3, Label = "Username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[FieldDefinition(3, Label = "Password", Type = FieldType.Password)]
|
||||
[FieldDefinition(4, Label = "Password", Type = FieldType.Password)]
|
||||
public string Password { get; set; }
|
||||
|
||||
[FieldDefinition(4, Label = "Notify with Chat Message", Type = FieldType.Checkbox)]
|
||||
[FieldDefinition(5, Label = "Notify with Chat Message", Type = FieldType.Checkbox)]
|
||||
public bool Notify { get; set; }
|
||||
|
||||
[FieldDefinition(5, Label = "Update Library", HelpText = "Update Library on Download & Rename?", Type = FieldType.Checkbox)]
|
||||
[FieldDefinition(6, Label = "Update Library", HelpText = "Update Library on Download & Rename?", Type = FieldType.Checkbox)]
|
||||
public bool UpdateLibrary { get; set; }
|
||||
|
||||
[FieldDefinition(6, Label = "Use SSL", Type = FieldType.Checkbox, HelpText = "Connect to Subsonic over HTTPS instead of HTTP")]
|
||||
[FieldDefinition(7, Label = "Use SSL", Type = FieldType.Checkbox, HelpText = "Connect to Subsonic over HTTPS instead of HTTP")]
|
||||
public bool UseSsl { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string Address => string.Format("{0}:{1}", Host, Port);
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
|
||||
Reference in New Issue
Block a user