From 6048053c3c15387ffb251964c2e2ebbd773fbbe2 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Mon, 9 Jan 2017 08:47:28 +0000 Subject: [PATCH] Api changed again, so more fixes for #878 --- Ombi.Api.Models/Watcher/WatcherAddMovieResult.cs | 2 +- Ombi.Api.Models/Watcher/WatcherListStatusResult.cs | 5 ++++- Ombi.Api/WatcherApi.cs | 11 ++++------- Ombi.Core/MovieSender.cs | 2 +- Ombi.Services/Jobs/WatcherCacher.cs | 4 ++-- Ombi.UI/Jobs/Scheduler.cs | 4 ++-- Ombi.UI/Modules/ApplicationTesterModule.cs | 2 +- Ombi.UI/Modules/SearchModule.cs | 4 ++-- Ombi.UI/Views/Integration/Watcher.cshtml | 2 +- Ombi.UI/Views/Shared/Partial/_Sidebar.cshtml | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Ombi.Api.Models/Watcher/WatcherAddMovieResult.cs b/Ombi.Api.Models/Watcher/WatcherAddMovieResult.cs index 28fbef946..fe9f50959 100644 --- a/Ombi.Api.Models/Watcher/WatcherAddMovieResult.cs +++ b/Ombi.Api.Models/Watcher/WatcherAddMovieResult.cs @@ -31,7 +31,7 @@ namespace Ombi.Api.Models.Watcher { public class WatcherAddMovieResult { - public string status { get; set; } + public bool response { get; set; } public string message { get; set; } [JsonIgnore] diff --git a/Ombi.Api.Models/Watcher/WatcherListStatusResult.cs b/Ombi.Api.Models/Watcher/WatcherListStatusResult.cs index 6fe46f864..a8116f33a 100644 --- a/Ombi.Api.Models/Watcher/WatcherListStatusResult.cs +++ b/Ombi.Api.Models/Watcher/WatcherListStatusResult.cs @@ -78,7 +78,10 @@ namespace Ombi.Api.Models.Watcher public class WatcherListStatusResultContainer { - public List Results { get; set; } + [JsonProperty("movies")] + public List Movies { get; set; } + [JsonProperty("response")] + public bool Response { get; set; } [JsonIgnore] public string ErrorMessage { get; set; } [JsonIgnore] diff --git a/Ombi.Api/WatcherApi.cs b/Ombi.Api/WatcherApi.cs index 08328a9d0..49466d5b5 100644 --- a/Ombi.Api/WatcherApi.cs +++ b/Ombi.Api/WatcherApi.cs @@ -84,16 +84,15 @@ namespace Ombi.Api public WatcherListStatusResultContainer ListMovies(string apiKey, Uri baseUrl) { - var response = Send("liststatus", apiKey, baseUrl); + var response = Send("liststatus", apiKey, baseUrl); try { if (response.Content.Contains("No movies found")) { return new WatcherListStatusResultContainer(); } - var items = JsonConvert.DeserializeObject>(response.Content); - - return new WatcherListStatusResultContainer {Results = items}; + var items = JsonConvert.DeserializeObject(response.Content); + return items; } catch (Exception e) { @@ -115,9 +114,7 @@ namespace Ombi.Api { return new WatcherListStatusResultContainer(); } - var items = JsonConvert.DeserializeObject>(response.Content); - - return new WatcherListStatusResultContainer { Results = items }; + return JsonConvert.DeserializeObject(response.Content); } catch (Exception e) { diff --git a/Ombi.Core/MovieSender.cs b/Ombi.Core/MovieSender.cs index faf2e138e..39e2e0554 100644 --- a/Ombi.Core/MovieSender.cs +++ b/Ombi.Core/MovieSender.cs @@ -78,7 +78,7 @@ namespace Ombi.Core Log.Error(result.ErrorMessage); return new MovieSenderResult { Result = false }; } - if (result.status.Equals("success", StringComparison.CurrentCultureIgnoreCase)) + if (result.response) { return new MovieSenderResult { Result = true, MovieSendingEnabled = true }; } diff --git a/Ombi.Services/Jobs/WatcherCacher.cs b/Ombi.Services/Jobs/WatcherCacher.cs index 6e172f6df..4257defe5 100644 --- a/Ombi.Services/Jobs/WatcherCacher.cs +++ b/Ombi.Services/Jobs/WatcherCacher.cs @@ -77,10 +77,10 @@ namespace Ombi.Services.Jobs Log.Error(movies.ErrorMessage); } var wantedMovies = - movies?.Results?.Where(x => x.status.Equals("Wanted", StringComparison.CurrentCultureIgnoreCase)); + movies?.Movies?.Where(x => x.status.Equals("Wanted", StringComparison.CurrentCultureIgnoreCase)); if (wantedMovies != null && wantedMovies.Any()) { - Cache.Set(CacheKeys.WatcherQueued, movies.Results.Select(x => x.imdbid).ToArray(), CacheKeys.TimeFrameMinutes.SchedulerCaching); + Cache.Set(CacheKeys.WatcherQueued, movies.Movies.Select(x => x.imdbid).ToArray(), CacheKeys.TimeFrameMinutes.SchedulerCaching); } } diff --git a/Ombi.UI/Jobs/Scheduler.cs b/Ombi.UI/Jobs/Scheduler.cs index 70055fd5b..7450e1c86 100644 --- a/Ombi.UI/Jobs/Scheduler.cs +++ b/Ombi.UI/Jobs/Scheduler.cs @@ -210,7 +210,7 @@ namespace Ombi.UI.Jobs var cpCacher = TriggerBuilder.Create() .WithIdentity("CouchPotatoCacher", "Cache") - .StartAt(DateBuilder.FutureDate(4, IntervalUnit.Minute)) + .StartAt(DateBuilder.FutureDate(2, IntervalUnit.Minute)) .WithSimpleSchedule(x => x.WithIntervalInMinutes(s.CouchPotatoCacher).RepeatForever()) .Build(); @@ -218,7 +218,7 @@ namespace Ombi.UI.Jobs TriggerBuilder.Create() .WithIdentity("WatcherCacher", "Cache") //.StartNow() - .StartAt(DateBuilder.FutureDate(3, IntervalUnit.Minute)) + .StartAt(DateBuilder.FutureDate(2, IntervalUnit.Minute)) .WithSimpleSchedule(x => x.WithIntervalInMinutes(s.WatcherCacher).RepeatForever()) .Build(); diff --git a/Ombi.UI/Modules/ApplicationTesterModule.cs b/Ombi.UI/Modules/ApplicationTesterModule.cs index e188848d3..b0d4f2d17 100644 --- a/Ombi.UI/Modules/ApplicationTesterModule.cs +++ b/Ombi.UI/Modules/ApplicationTesterModule.cs @@ -114,7 +114,7 @@ namespace Ombi.UI.Modules try { var status = WatcherApi.Version(settings.ApiKey, settings.FullUri); - return !status.response + return status.response ? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to Watcher successfully!" }) : Response.AsJson(new JsonResponseModel { Result = false, Message = $"Could not connect to Watcher, Error: {status.ErrorMessage}" }); diff --git a/Ombi.UI/Modules/SearchModule.cs b/Ombi.UI/Modules/SearchModule.cs index 51f687cb9..0dcc5242b 100644 --- a/Ombi.UI/Modules/SearchModule.cs +++ b/Ombi.UI/Modules/SearchModule.cs @@ -567,6 +567,7 @@ namespace Ombi.UI.Modules { if (ShouldAutoApprove(RequestType.Movie, settings, Username)) { + model.Approved = true; var result = await MovieSender.Send(model); if (result.Result) @@ -576,8 +577,7 @@ namespace Ombi.UI.Modules } if (!result.MovieSendingEnabled) { - - model.Approved = true; + return await AddRequest(model, settings, $"{fullMovieName} {Resources.UI.Search_SuccessfullyAdded}"); } diff --git a/Ombi.UI/Views/Integration/Watcher.cshtml b/Ombi.UI/Views/Integration/Watcher.cshtml index 6dcda811c..7ac9651bc 100644 --- a/Ombi.UI/Views/Integration/Watcher.cshtml +++ b/Ombi.UI/Views/Integration/Watcher.cshtml @@ -16,7 +16,7 @@
Watcher Settings - + Please note, this is still in beta and may stop working at anytime as Watcher is still very much in development and is constantly changing. @Html.Checkbox(Model.Enabled, "Enabled", "Enabled")
diff --git a/Ombi.UI/Views/Shared/Partial/_Sidebar.cshtml b/Ombi.UI/Views/Shared/Partial/_Sidebar.cshtml index 6e85d9c87..34b080460 100644 --- a/Ombi.UI/Views/Shared/Partial/_Sidebar.cshtml +++ b/Ombi.UI/Views/Shared/Partial/_Sidebar.cshtml @@ -10,10 +10,10 @@ @Html.GetSidebarUrl(Context, "/admin/usermanagementsettings", "User Management Settings") @Html.GetSidebarUrl(Context, "/admin/plex", "Plex") @Html.GetSidebarUrl(Context, "/admin/couchpotato", "CouchPotato") - @Html.GetSidebarUrl(Context, "/admin/watcher", "Watcher") + @Html.GetSidebarUrl(Context, "/admin/watcher", "Watcher (beta)") @Html.GetSidebarUrl(Context, "/admin/sonarr", "Sonarr") @Html.GetSidebarUrl(Context, "/admin/sickrage", "SickRage") - @Html.GetSidebarUrl(Context, "/admin/headphones", "Headphones (Beta)") + @Html.GetSidebarUrl(Context, "/admin/headphones", "Headphones (beta)") @Html.GetSidebarUrl(Context, "/admin/newsletter", "Newsletter Settings") @Html.GetSidebarUrl(Context, "/admin/emailnotification", "Email Notifications") @Html.GetSidebarUrl(Context, "/admin/pushbulletnotification", "Pushbullet Notifications")