Added a subdir to CP, SickRage, Sonarr and Plex #43

pull/83/head
tidusjar 9 years ago
parent 21ea315cd0
commit 895a0c50eb

@ -38,12 +38,18 @@ namespace PlexRequests.Core.SettingModels
public string ApiKey { get; set; } public string ApiKey { get; set; }
public bool Ssl { get; set; } public bool Ssl { get; set; }
public string ProfileId { get; set; } public string ProfileId { get; set; }
public string SubDir { get; set; }
[JsonIgnore] [JsonIgnore]
public Uri FullUri public Uri FullUri
{ {
get get
{ {
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl); var formatted = Ip.ReturnUri(Port, Ssl);
return formatted; return formatted;
} }

@ -36,12 +36,18 @@ namespace PlexRequests.Core.SettingModels
public string Ip { get; set; } public string Ip { get; set; }
public int Port { get; set; } public int Port { get; set; }
public bool Ssl { get; set; } public bool Ssl { get; set; }
public string SubDir { get; set; }
[JsonIgnore] [JsonIgnore]
public Uri FullUri public Uri FullUri
{ {
get get
{ {
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl); var formatted = Ip.ReturnUri(Port, Ssl);
return formatted; return formatted;
} }

@ -39,12 +39,18 @@ namespace PlexRequests.Core.SettingModels
public string ApiKey { get; set; } public string ApiKey { get; set; }
public string QualityProfile { get; set; } public string QualityProfile { get; set; }
public bool Ssl { get; set; } public bool Ssl { get; set; }
public string SubDir { get; set; }
[JsonIgnore] [JsonIgnore]
public Uri FullUri public Uri FullUri
{ {
get get
{ {
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl); var formatted = Ip.ReturnUri(Port, Ssl);
return formatted; return formatted;
} }

@ -41,12 +41,18 @@ namespace PlexRequests.Core.SettingModels
public bool SeasonFolders { get; set; } public bool SeasonFolders { get; set; }
public string RootPath { get; set; } public string RootPath { get; set; }
public bool Ssl { get; set; } public bool Ssl { get; set; }
public string SubDir { get; set; }
[JsonIgnore] [JsonIgnore]
public Uri FullUri public Uri FullUri
{ {
get get
{ {
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl); var formatted = Ip.ReturnUri(Port, Ssl);
return formatted; return formatted;
} }

@ -26,6 +26,7 @@
#endregion #endregion
using System; using System;
using System.Linq.Expressions;
using NUnit.Framework; using NUnit.Framework;
namespace PlexRequests.Helpers.Tests namespace PlexRequests.Helpers.Tests
@ -58,6 +59,14 @@ namespace PlexRequests.Helpers.Tests
Assert.That(result, Is.EqualTo(expected)); Assert.That(result, Is.EqualTo(expected));
} }
[TestCaseSource(nameof(UriDataWithSubDir))]
public void CreateUriWithSubDir(string uri, int port, bool ssl, string subDir, Uri expected)
{
var result = uri.ReturnUriWithSubDir(port, ssl, subDir);
Assert.That(result, Is.EqualTo(expected));
}
static readonly object[] UriData = static readonly object[] UriData =
{ {
new object[] { "google.com", new Uri("http://google.com/"), }, new object[] { "google.com", new Uri("http://google.com/"), },
@ -84,5 +93,13 @@ namespace PlexRequests.Helpers.Tests
new object[] {"http://www.google.com/id=2", 443, new Uri("http://www.google.com:443/id=2") }, new object[] {"http://www.google.com/id=2", 443, new Uri("http://www.google.com:443/id=2") },
new object[] {"https://www.google.com/id=2", 443, new Uri("https://www.google.com:443/id=2") }, new object[] {"https://www.google.com/id=2", 443, new Uri("https://www.google.com:443/id=2") },
}; };
static readonly object[] UriDataWithSubDir =
{
new object[] {"www.google.com", 80, false,"test", new Uri("http://www.google.com:80/test"), },
new object[] {"www.google.com", 443, false,"test", new Uri("http://www.google.com:443/test") },
new object[] {"http://www.google.com", 443, true,"test", new Uri("https://www.google.com:443/test") },
new object[] {"https://www.google.com", 443,true,"test", new Uri("https://www.google.com:443/test") },
};
} }
} }

@ -53,7 +53,10 @@ namespace PlexRequests.Helpers
/// </summary> /// </summary>
/// <param name="val">The value.</param> /// <param name="val">The value.</param>
/// <param name="port">The port.</param> /// <param name="port">The port.</param>
/// <param name="ssl">if set to <c>true</c> [SSL].</param>
/// <param name="subdir">The subdir.</param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="ApplicationSettingsException">The URI is null, please check your settings to make sure you have configured the applications correctly.</exception>
/// <exception cref="System.Exception"></exception> /// <exception cref="System.Exception"></exception>
public static Uri ReturnUri(this string val, int port, bool ssl = default(bool)) public static Uri ReturnUri(this string val, int port, bool ssl = default(bool))
{ {
@ -93,5 +96,21 @@ namespace PlexRequests.Helpers
throw new Exception(exception.Message, exception); throw new Exception(exception.Message, exception);
} }
} }
public static Uri ReturnUriWithSubDir(this string val, int port, bool ssl, string subDir)
{
var uriBuilder = new UriBuilder(val);
if (ssl)
{
uriBuilder.Scheme = Uri.UriSchemeHttps;
}
if (!string.IsNullOrEmpty(subDir))
{
uriBuilder.Path = subDir;
}
uriBuilder.Port = port;
return uriBuilder.Uri;
}
} }
} }

@ -51,6 +51,12 @@
</label> </label>
</div> </div>
</div> </div>
<div class="form-group">
<label for="SubDir" class="control-label">CouchPotato SubDirectory</label>
<div>
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
</div>
</div>
<div class="form-group"> <div class="form-group">

@ -43,6 +43,12 @@
</label> </label>
</div> </div>
</div> </div>
<div class="form-group">
<label for="SubDir" class="control-label">Plex SubDirectory</label>
<div>
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
</div>
</div>
<div class="form-group"> <div class="form-group">
<div> <div>
<button id="testPlex" type="submit" class="btn btn-primary-outline">Test Connectivity</button> <button id="testPlex" type="submit" class="btn btn-primary-outline">Test Connectivity</button>

@ -64,6 +64,13 @@
</label> </label>
</div> </div>
</div> </div>
<div class="form-group">
<label for="SubDir" class="control-label">SickRage SubDirectory</label>
<div>
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="profiles" class="control-label">Quality Profiles</label> <label for="profiles" class="control-label">Quality Profiles</label>
<div id="profiles"> <div id="profiles">

@ -64,6 +64,12 @@
</label> </label>
</div> </div>
</div> </div>
<div class="form-group">
<label for="SubDir" class="control-label">Sonarr SubDirectory</label>
<div>
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
</div>
</div>
<div class="form-group"> <div class="form-group">
<div> <div>
<button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles</button> <button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles</button>

Loading…
Cancel
Save