diff --git a/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj b/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
index 21d6ccefc..c12da3add 100644
--- a/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
+++ b/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
@@ -48,6 +48,7 @@
+
diff --git a/PlexRequests.Api.Models/Sonarr/SonarrProfile.cs b/PlexRequests.Api.Models/Sonarr/SonarrProfile.cs
new file mode 100644
index 000000000..2aee359bb
--- /dev/null
+++ b/PlexRequests.Api.Models/Sonarr/SonarrProfile.cs
@@ -0,0 +1,57 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: SonarrProfile.cs
+// Created By: Jamie Rees
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ************************************************************************/
+#endregion
+
+using System.Collections.Generic;
+
+namespace PlexRequests.Api.Models.Sonarr
+{
+ public class Cutoff
+ {
+ public int id { get; set; }
+ public string name { get; set; }
+ }
+
+ public class Quality
+ {
+ public int id { get; set; }
+ public string name { get; set; }
+ }
+
+ public class Item
+ {
+ public Quality quality { get; set; }
+ public bool allowed { get; set; }
+ }
+
+ public class SonarrProfile
+ {
+ public string name { get; set; }
+ public Cutoff cutoff { get; set; }
+ public List- items { get; set; }
+ public int id { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/PlexRequests.Api/PlexRequests.Api.csproj b/PlexRequests.Api/PlexRequests.Api.csproj
index e9b578476..fa917a6de 100644
--- a/PlexRequests.Api/PlexRequests.Api.csproj
+++ b/PlexRequests.Api/PlexRequests.Api.csproj
@@ -66,6 +66,7 @@
+
diff --git a/PlexRequests.Api/SonarrApi.cs b/PlexRequests.Api/SonarrApi.cs
new file mode 100644
index 000000000..f02408bb4
--- /dev/null
+++ b/PlexRequests.Api/SonarrApi.cs
@@ -0,0 +1,58 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: CouchPotatoApi.cs
+// Created By: Jamie Rees
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// ************************************************************************/
+#endregion
+using System;
+using System.Collections.Generic;
+using Newtonsoft.Json.Linq;
+
+using NLog;
+using PlexRequests.Api.Interfaces;
+using PlexRequests.Api.Models.Sonarr;
+using RestSharp;
+
+namespace PlexRequests.Api
+{
+ public class SonarrApi
+ {
+ public SonarrApi()
+ {
+ Api = new ApiRequest();
+ }
+ private ApiRequest Api { get; set; }
+ private static Logger Log = LogManager.GetCurrentClassLogger();
+
+ public List GetProfiles(string apiKey, Uri baseUrl)
+ {
+ var request = new RestRequest { Resource = "/api/profile", Method = Method.GET};
+
+ request.AddHeader("X-Api-Key", apiKey);
+
+ var obj = Api.ExecuteJson
>(request, baseUrl);
+
+ return obj;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PlexRequests.Core/SettingModels/SonarrSettings.cs b/PlexRequests.Core/SettingModels/SonarrSettings.cs
index 7982fac05..cc5ca120d 100644
--- a/PlexRequests.Core/SettingModels/SonarrSettings.cs
+++ b/PlexRequests.Core/SettingModels/SonarrSettings.cs
@@ -24,6 +24,11 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
+
+using System;
+using Newtonsoft.Json;
+using PlexRequests.Helpers;
+
namespace PlexRequests.Core.SettingModels
{
public class SonarrSettings : Settings
@@ -31,6 +36,16 @@ namespace PlexRequests.Core.SettingModels
public string Ip { get; set; }
public int Port { get; set; }
public string ApiKey { get; set; }
- public bool Enabled { get; set; }
+ public string QualityProfile { get; set; }
+
+ [JsonIgnore]
+ public Uri FullUri
+ {
+ get
+ {
+ var formatted = Ip.ReturnUri(Port);
+ return formatted;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/PlexRequests.UI/Bootstrapper.cs b/PlexRequests.UI/Bootstrapper.cs
index 7d9a09bc3..4ec6842da 100644
--- a/PlexRequests.UI/Bootstrapper.cs
+++ b/PlexRequests.UI/Bootstrapper.cs
@@ -69,6 +69,7 @@ namespace PlexRequests.UI
container.Register, SettingsServiceV2>();
container.Register, SettingsServiceV2>();
container.Register, SettingsServiceV2>();
+ container.Register, SettingsServiceV2>();
container.Register, GenericRepository>();
container.Register();
diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs
index d745e45cd..d7ab075d8 100644
--- a/PlexRequests.UI/Modules/AdminModule.cs
+++ b/PlexRequests.UI/Modules/AdminModule.cs
@@ -49,14 +49,20 @@ namespace PlexRequests.UI.Modules
private ISettingsService CpService { get; set; }
private ISettingsService AuthService { get; set; }
private ISettingsService PlexService { get; set; }
+ private ISettingsService SonarrService { get; set; }
private static Logger Log = LogManager.GetCurrentClassLogger();
- public AdminModule(ISettingsService rpService, ISettingsService cpService, ISettingsService auth, ISettingsService plex) : base("admin")
+ public AdminModule(ISettingsService rpService,
+ ISettingsService cpService,
+ ISettingsService auth
+ , ISettingsService plex,
+ ISettingsService sonarr ) : base("admin")
{
RpService = rpService;
CpService = cpService;
AuthService = auth;
PlexService = plex;
+ SonarrService = sonarr;
#if !DEBUG
this.RequiresAuthentication();
@@ -77,6 +83,11 @@ namespace PlexRequests.UI.Modules
Get["/plex"] = _ => Plex();
Post["/plex"] = _ => SavePlex();
+
+ Get["/sonarr"] = _ => Sonarr();
+ Post["/sonarr"] = _ => SaveSonarr();
+
+ Get["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
}
private Negotiator Authentication()
@@ -201,5 +212,29 @@ namespace PlexRequests.UI.Modules
return Context.GetRedirect("~/admin/plex");
}
+ private Negotiator Sonarr()
+ {
+ var settings = SonarrService.GetSettings();
+
+ return View["Sonarr", settings];
+ }
+
+ private Response SaveSonarr()
+ {
+ var plexSettings = this.Bind();
+ SonarrService.SaveSettings(plexSettings);
+
+ return Context.GetRedirect("~/admin/Sonarr");
+ }
+
+ private Response GetSonarrQualityProfiles()
+ {
+ var settings = SonarrService.GetSettings();
+ var api = new SonarrApi();
+ var profiles = api.GetProfiles(settings.ApiKey, settings.FullUri);
+
+ return Response.AsJson(profiles);
+ }
+
}
}
\ No newline at end of file
diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj
index 2b4d233eb..dacff157e 100644
--- a/PlexRequests.UI/PlexRequests.UI.csproj
+++ b/PlexRequests.UI/PlexRequests.UI.csproj
@@ -273,6 +273,9 @@
Always
+
+ Always
+
web.config
diff --git a/PlexRequests.UI/Views/Admin/Sonarr.cshtml b/PlexRequests.UI/Views/Admin/Sonarr.cshtml
new file mode 100644
index 000000000..94e02ee4b
--- /dev/null
+++ b/PlexRequests.UI/Views/Admin/Sonarr.cshtml
@@ -0,0 +1,84 @@
+@Html.Partial("_Sidebar")
+@{
+ int port;
+ if (Model.Port == 0)
+ {
+ port = 80;
+ }
+ else
+ {
+ port = Model.Port;
+ }
+}
+
+
+
+
+
\ No newline at end of file
diff --git a/PlexRequests.UI/Views/Shared/_Layout.cshtml b/PlexRequests.UI/Views/Shared/_Layout.cshtml
index dd47e2422..6420c1261 100644
--- a/PlexRequests.UI/Views/Shared/_Layout.cshtml
+++ b/PlexRequests.UI/Views/Shared/_Layout.cshtml
@@ -43,6 +43,15 @@
Search
}
+
+ @if (Context.Request.Path == "/requests")
+ {
+ Requests
+ }
+ else
+ {
+ Requests
+ }
@if (Context.CurrentUser.IsAuthenticated())
{
if (Context.Request.Path == "/admin")
@@ -54,14 +63,6 @@
Admin
}
}
- @if (Context.Request.Path == "/requests")
- {
- Requests
- }
- else
- {
- Requests
- }
@if (!Context.CurrentUser.IsAuthenticated())