diff --git a/PlexRequests.Api/PlexRequests.Api.csproj b/PlexRequests.Api/PlexRequests.Api.csproj
index 5157e905c..2f204c975 100644
--- a/PlexRequests.Api/PlexRequests.Api.csproj
+++ b/PlexRequests.Api/PlexRequests.Api.csproj
@@ -73,6 +73,7 @@
+
diff --git a/PlexRequests.Api/SickrageApi.cs b/PlexRequests.Api/SickrageApi.cs
new file mode 100644
index 000000000..26dbdb3d7
--- /dev/null
+++ b/PlexRequests.Api/SickrageApi.cs
@@ -0,0 +1,68 @@
+#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 NLog;
+using PlexRequests.Api.Interfaces;
+using PlexRequests.Api.Models.Sonarr;
+using RestSharp;
+
+namespace PlexRequests.Api
+{
+ public class SickrageApi
+ {
+ public SickrageApi()
+ {
+ Api = new ApiRequest();
+ }
+ private ApiRequest Api { get; set; }
+ private static Logger Log = LogManager.GetCurrentClassLogger();
+
+
+ public SonarrAddSeries AddSeries(int tvdbId, string status, string futureStatus, string quality, string apiKey, Uri baseUrl)
+ {
+ //localhost:8081/api/e738882774aeb0b2210f4bc578cbb584/?cmd=show.addnew&tvdbid=101501&status=skipped&future_status=wanted&initial=fullhdbluray&sdtv
+
+ var request = new RestRequest
+ {
+ Resource = "/api/{apiKey}/?cmd=show.addnew",
+ Method = Method.GET
+ };
+
+ request.AddQueryParameter("tvdbid", tvdbId.ToString());
+ request.AddQueryParameter("status", status);
+ request.AddQueryParameter("future_status", futureStatus);
+ request.AddQueryParameter("initial", quality);
+
+ var obj = Api.ExecuteJson(request, baseUrl);
+
+ return obj;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/PlexRequests.Core/SettingModels/SickRageSettings.cs b/PlexRequests.Core/SettingModels/SickRageSettings.cs
index b06801db4..344e41434 100644
--- a/PlexRequests.Core/SettingModels/SickRageSettings.cs
+++ b/PlexRequests.Core/SettingModels/SickRageSettings.cs
@@ -24,13 +24,30 @@
// 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 SickRageSettings : Settings
{
+ public bool Enabled { get; set; }
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; }
+ public bool Ssl { get; set; }
+
+ [JsonIgnore]
+ public Uri FullUri
+ {
+ get
+ {
+ var formatted = Ip.ReturnUri(Port, Ssl);
+ return formatted;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/PlexRequests.Core/SettingModels/SonarrSettings.cs b/PlexRequests.Core/SettingModels/SonarrSettings.cs
index 15f486d37..2c128f993 100644
--- a/PlexRequests.Core/SettingModels/SonarrSettings.cs
+++ b/PlexRequests.Core/SettingModels/SonarrSettings.cs
@@ -33,6 +33,7 @@ namespace PlexRequests.Core.SettingModels
{
public class SonarrSettings : Settings
{
+ public bool Enabled { get; set; }
public string Ip { get; set; }
public int Port { get; set; }
public string ApiKey { get; set; }
diff --git a/PlexRequests.UI.Tests/AdminModuleTests.cs b/PlexRequests.UI.Tests/AdminModuleTests.cs
index 8e5ebbdc4..e42eb4a13 100644
--- a/PlexRequests.UI.Tests/AdminModuleTests.cs
+++ b/PlexRequests.UI.Tests/AdminModuleTests.cs
@@ -52,6 +52,7 @@ namespace PlexRequests.UI.Tests
private Mock> AuthMock { get; set; }
private Mock> PlexSettingsMock { get; set; }
private Mock> SonarrSettingsMock { get; set; }
+ private Mock> SickRageSettingsMock { get; set; }
private Mock> EmailMock { get; set; }
private Mock> PushbulletSettings { get; set; }
private Mock PlexMock { get; set; }
@@ -81,6 +82,7 @@ namespace PlexRequests.UI.Tests
PushbulletApi = new Mock();
PushbulletSettings = new Mock>();
CpApi = new Mock();
+ SickRageSettingsMock = new Mock>();
Bootstrapper = new ConfigurableBootstrapper(with =>
{
@@ -96,6 +98,7 @@ namespace PlexRequests.UI.Tests
with.Dependency(PushbulletApi.Object);
with.Dependency(PushbulletSettings.Object);
with.Dependency(CpApi.Object);
+ with.Dependency(SickRageSettingsMock.Object);
with.RootPathProvider();
with.RequestStartup((container, pipelines, context) =>
{
diff --git a/PlexRequests.UI/Bootstrapper.cs b/PlexRequests.UI/Bootstrapper.cs
index cba01fd25..358940c5c 100644
--- a/PlexRequests.UI/Bootstrapper.cs
+++ b/PlexRequests.UI/Bootstrapper.cs
@@ -73,6 +73,7 @@ namespace PlexRequests.UI
container.Register, SettingsServiceV2>();
container.Register, SettingsServiceV2>();
container.Register, SettingsServiceV2>();
+ container.Register, SettingsServiceV2>();
container.Register, SettingsServiceV2>();
container.Register, SettingsServiceV2>();
container.Register, GenericRepository>();
diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs
index fc86ad568..eeac628f0 100644
--- a/PlexRequests.UI/Modules/AdminModule.cs
+++ b/PlexRequests.UI/Modules/AdminModule.cs
@@ -54,6 +54,7 @@ namespace PlexRequests.UI.Modules
private ISettingsService AuthService { get; }
private ISettingsService PlexService { get; }
private ISettingsService SonarrService { get; }
+ private ISettingsService SickRageService { get; }
private ISettingsService EmailService { get; }
private ISettingsService PushbulletService { get; }
private IPlexApi PlexApi { get; }
@@ -67,6 +68,7 @@ namespace PlexRequests.UI.Modules
ISettingsService auth,
ISettingsService plex,
ISettingsService sonarr,
+ ISettingsService sickrage,
ISonarrApi sonarrApi,
ISettingsService email,
IPlexApi plexApi,
@@ -85,6 +87,7 @@ namespace PlexRequests.UI.Modules
PushbulletService = pbSettings;
PushbulletApi = pbApi;
CpApi = cpApi;
+ SickRageService = sickrage;
#if !DEBUG
this.RequiresAuthentication();
@@ -109,6 +112,9 @@ namespace PlexRequests.UI.Modules
Get["/sonarr"] = _ => Sonarr();
Post["/sonarr"] = _ => SaveSonarr();
+ Get["/sickrage"] = _ => Sickrage();
+ Post["/sickrage"] = _ => SaveSickrage();
+
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
Post["/cpprofiles"] = _ => GetCpProfiles();
@@ -283,7 +289,11 @@ namespace PlexRequests.UI.Modules
{
return Response.AsJson(valid.SendJsonError());
}
-
+ var sickRageEnabled = SickRageService.GetSettings().Enabled;
+ if (sickRageEnabled)
+ {
+ return Response.AsJson(new JsonResponseModel { Result = false, Message = "SickRage is enabled, we cannot enable Sonarr and SickRage" });
+ }
var result = SonarrService.SaveSettings(sonarrSettings);
return Response.AsJson(result
@@ -291,6 +301,35 @@ namespace PlexRequests.UI.Modules
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
}
+ private Negotiator Sickrage()
+ {
+ var settings = SickRageService.GetSettings();
+
+ return View["Sickrage", settings];
+ }
+
+ private Response SaveSickrage()
+ {
+ var sickRageSettings = this.Bind();
+
+ var valid = this.Validate(sickRageSettings);
+ if (!valid.IsValid)
+ {
+ return Response.AsJson(valid.SendJsonError());
+ }
+
+ var sonarrEnabled = SonarrService.GetSettings().Enabled;
+ if (sonarrEnabled)
+ {
+ return Response.AsJson(new JsonResponseModel { Result = false, Message = "Sonarr is enabled, we cannot enable Sonarr and SickRage" });
+ }
+ var result = SickRageService.SaveSettings(sickRageSettings);
+
+ return Response.AsJson(result
+ ? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for SickRage!" }
+ : new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
+ }
+
private Response GetSonarrQualityProfiles()
{
var settings = this.Bind();
diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj
index ec0bf2acc..a5eed1bcf 100644
--- a/PlexRequests.UI/PlexRequests.UI.csproj
+++ b/PlexRequests.UI/PlexRequests.UI.csproj
@@ -165,6 +165,7 @@
+ PreserveNewest
@@ -320,6 +321,9 @@
Always
+
+ Always
+ web.config
diff --git a/PlexRequests.UI/Validators/SickRageValidator.cs b/PlexRequests.UI/Validators/SickRageValidator.cs
new file mode 100644
index 000000000..28056e095
--- /dev/null
+++ b/PlexRequests.UI/Validators/SickRageValidator.cs
@@ -0,0 +1,43 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: SonarrValidator.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 FluentValidation;
+
+using PlexRequests.Core.SettingModels;
+
+namespace PlexRequests.UI.Validators
+{
+ public class SickRageValidator : AbstractValidator
+ {
+ public SickRageValidator()
+ {
+ RuleFor(request => request.ApiKey).NotEmpty().WithMessage("You must specify a Api Key.");
+ RuleFor(request => request.Ip).NotEmpty().WithMessage("You must specify a IP/Host name.");
+ RuleFor(request => request.Port).NotEmpty().WithMessage("You must specify a Port.");
+ RuleFor(request => request.QualityProfile).NotEmpty().WithMessage("You must specify a Quality Profile.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/PlexRequests.UI/Views/Admin/Sickrage.cshtml b/PlexRequests.UI/Views/Admin/Sickrage.cshtml
new file mode 100644
index 000000000..34b17bb49
--- /dev/null
+++ b/PlexRequests.UI/Views/Admin/Sickrage.cshtml
@@ -0,0 +1,197 @@
+@Html.Partial("_Sidebar")
+@{
+ int port;
+ if (Model.Port == 0)
+ {
+ port = 8081;
+ }
+ else
+ {
+ port = Model.Port;
+ }
+}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PlexRequests.UI/Views/Admin/Sonarr.cshtml b/PlexRequests.UI/Views/Admin/Sonarr.cshtml
index 83a06c443..192161a23 100644
--- a/PlexRequests.UI/Views/Admin/Sonarr.cshtml
+++ b/PlexRequests.UI/Views/Admin/Sonarr.cshtml
@@ -14,7 +14,20 @@