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 bool Ssl { get; set; }
public string ProfileId { get; set; }
public string SubDir { get; set; }
[JsonIgnore]
public Uri FullUri
{
get
{
if (!string.IsNullOrEmpty(SubDir))
{
var formattedSubDir = Ip.ReturnUriWithSubDir(Port, Ssl, SubDir);
return formattedSubDir;
}
var formatted = Ip.ReturnUri(Port, Ssl);
return formatted;
}

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

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

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

@ -26,6 +26,7 @@
#endregion
using System;
using System.Linq.Expressions;
using NUnit.Framework;
namespace PlexRequests.Helpers.Tests
@ -35,7 +36,7 @@ namespace PlexRequests.Helpers.Tests
{
[TestCaseSource(nameof(UriData))]
public void CreateUri1(string uri, Uri expected)
{
{
var result = uri.ReturnUri();
Assert.That(result, Is.EqualTo(expected));
@ -58,6 +59,14 @@ namespace PlexRequests.Helpers.Tests
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 =
{
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[] {"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>
/// <param name="val">The value.</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>
/// <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>
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);
}
}
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>
</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">

@ -43,6 +43,12 @@
</label>
</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>
<button id="testPlex" type="submit" class="btn btn-primary-outline">Test Connectivity</button>

@ -64,6 +64,13 @@
</label>
</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">
<label for="profiles" class="control-label">Quality Profiles</label>
<div id="profiles">

@ -64,6 +64,12 @@
</label>
</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>
<button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles</button>

Loading…
Cancel
Save