diff --git a/PlexRequests.Api/SonarrApi.cs b/PlexRequests.Api/SonarrApi.cs index 4ff51e2d7..148f27d23 100644 --- a/PlexRequests.Api/SonarrApi.cs +++ b/PlexRequests.Api/SonarrApi.cs @@ -64,7 +64,7 @@ namespace PlexRequests.Api }; var options = new SonarrAddSeries(); - if (episodes == true) + if (episodes) { options.addOptions = new AddOptions { diff --git a/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs b/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs index ff7ea01a5..030ff16b8 100644 --- a/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs +++ b/PlexRequests.Core/SettingModels/CouchPotatoSettings.cs @@ -33,6 +33,7 @@ namespace PlexRequests.Core.SettingModels { public class CouchPotatoSettings : 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/Content/requests.js b/PlexRequests.UI/Content/requests.js index 68b942bdb..205b471c0 100644 --- a/PlexRequests.UI/Content/requests.js +++ b/PlexRequests.UI/Content/requests.js @@ -114,7 +114,7 @@ $(".theNoteSaveButton").click(function (e) { var $form = $("#noteForm"); var data = $form.serialize(); - + $.ajax({ type: $form.prop("method"), @@ -198,7 +198,11 @@ $(document).on("click", ".approve", function (e) { success: function (response) { if (checkJsonResponse(response)) { - generateNotify("Success! Request Approved.", "success"); + if (response.message) { + generateNotify(response.message, "success"); + } else { + generateNotify("Success! Request Approved.", "success"); + } $("button[custom-button='" + buttonId + "']").remove(); $("#" + buttonId + "notapproved").prop("class", "fa fa-check"); @@ -227,7 +231,7 @@ $(document).on("click", ".clear", function (e) { if (checkJsonResponse(response)) { generateNotify("Success! Issues Cleared.", "info"); - $('#issueArea'+buttonId).html("
Issue: None
"); + $('#issueArea' + buttonId).html("
Issue: None
"); } }, error: function (e) { @@ -258,7 +262,7 @@ $(document).on("click", ".change", function (e) { if (checkJsonResponse(response)) { generateNotify("Success! Availibility changed.", "info"); var button = $("button[custom-availibility='" + buttonId + "']"); - var icon = $('#availableIcon'+buttonId); + var icon = $('#availableIcon' + buttonId); if (response.available) { button.text("Mark Unavailable"); diff --git a/PlexRequests.UI/Modules/ApprovalModule.cs b/PlexRequests.UI/Modules/ApprovalModule.cs index 4a468414b..10795ceaa 100644 --- a/PlexRequests.UI/Modules/ApprovalModule.cs +++ b/PlexRequests.UI/Modules/ApprovalModule.cs @@ -121,12 +121,12 @@ namespace PlexRequests.UI.Modules Log.Info("Sent successfully, Approving request now."); request.Approved = true; var requestResult = Service.UpdateRequest(request); - Log.Trace("Approval result: {0}",requestResult); + Log.Trace("Approval result: {0}", requestResult); if (requestResult) { return Response.AsJson(new JsonResponseModel { Result = true }); } - return Response.AsJson(new JsonResponseModel { Result = false, Message = "Updated Sonarr but could not approve it in PlexRequests :("}); + return Response.AsJson(new JsonResponseModel { Result = false, Message = "Updated Sonarr but could not approve it in PlexRequests :(" }); } return Response.AsJson(new JsonResponseModel { @@ -177,6 +177,21 @@ namespace PlexRequests.UI.Modules var cpSettings = CpService.GetSettings(); var cp = new CouchPotatoApi(); Log.Info("Adding movie to CP : {0}", request.Title); + if (!cpSettings.Enabled) + { + // Approve it + request.Approved = true; + + // Update the record + var inserted = Service.UpdateRequest(request); + return Response.AsJson(inserted + ? new JsonResponseModel { Result = true, Message = "This has been approved, but It has not been sent to CouchPotato because it has not been configured." } + : new JsonResponseModel + { + Result = false, + Message = "We could not approve this request. Please try again or check the logs." + }); + } var result = cp.AddMovie(request.ImdbId, cpSettings.ApiKey, request.Title, cpSettings.FullUri, cpSettings.ProfileId); Log.Trace("Adding movie to CP result {0}", result); if (result) @@ -188,7 +203,7 @@ namespace PlexRequests.UI.Modules var inserted = Service.UpdateRequest(request); return Response.AsJson(inserted - ? new JsonResponseModel {Result = true} + ? new JsonResponseModel { Result = true } : new JsonResponseModel { Result = false, @@ -239,7 +254,7 @@ namespace PlexRequests.UI.Modules } if (r.Type == RequestType.TvShow) { - var sender = new TvSender(SonarrApi,SickRageApi); + var sender = new TvSender(SonarrApi, SickRageApi); var sr = SickRageSettings.GetSettings(); var sonarr = SonarrSettings.GetSettings(); if (sr.Enabled) @@ -289,7 +304,7 @@ namespace PlexRequests.UI.Modules } private bool SendMovie(CouchPotatoSettings settings, RequestedModel r, ICouchPotatoApi cp) - { + { Log.Info("Adding movie to CP : {0}", r.Title); var result = cp.AddMovie(r.ImdbId, settings.ApiKey, r.Title, settings.FullUri, settings.ProfileId); Log.Trace("Adding movie to CP result {0}", result); diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index b5e8b2e99..bdb16a243 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -176,15 +176,6 @@ namespace PlexRequests.UI.Modules } Log.Debug("movie with id {0} doesnt exists", movieId); - var cpSettings = CpService.GetSettings(); - if (cpSettings.ApiKey == null) - { - Log.Warn("CP apiKey is null"); - return Response.AsJson(new JsonResponseModel { Result = false, Message = "CouchPotato is not yet configured, If you are the Admin, please log in." }); - } - - Log.Trace("Settings: "); - Log.Trace(cpSettings.DumpJson); var movieApi = new TheMovieDbApi(); var movieInfo = movieApi.GetMovieInformation(movieId).Result; @@ -219,6 +210,11 @@ namespace PlexRequests.UI.Modules Log.Trace(settings.DumpJson()); if (!settings.RequireApproval) { + var cpSettings = CpService.GetSettings(); + + Log.Trace("Settings: "); + Log.Trace(cpSettings.DumpJson); + Log.Info("Adding movie to CP (No approval required)"); var result = CouchPotatoApi.AddMovie(model.ImdbId, cpSettings.ApiKey, model.Title, cpSettings.FullUri, cpSettings.ProfileId); Log.Debug("Adding movie to CP result {0}", result); diff --git a/PlexRequests.UI/Views/Admin/CouchPotato.cshtml b/PlexRequests.UI/Views/Admin/CouchPotato.cshtml index 9e0aff8ef..e90354a4a 100644 --- a/PlexRequests.UI/Views/Admin/CouchPotato.cshtml +++ b/PlexRequests.UI/Views/Admin/CouchPotato.cshtml @@ -14,7 +14,20 @@
CouchPotato Settings - +
+
+ +
+