From 41b439d3bb45c1673960542d689ee4e78548a3fc Mon Sep 17 00:00:00 2001 From: tidusjar Date: Thu, 2 Jun 2016 14:12:44 +0100 Subject: [PATCH] fixes #296 --- .../Movie/CouchPotatoProfiles.cs | 7 ++++++- PlexRequests.Api/CouchPotatoApi.cs | 4 ++-- PlexRequests.UI/Modules/RequestsModule.cs | 20 ++++++++++++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/PlexRequests.Api.Models/Movie/CouchPotatoProfiles.cs b/PlexRequests.Api.Models/Movie/CouchPotatoProfiles.cs index f63661ecb..5a24ee6eb 100644 --- a/PlexRequests.Api.Models/Movie/CouchPotatoProfiles.cs +++ b/PlexRequests.Api.Models/Movie/CouchPotatoProfiles.cs @@ -27,11 +27,15 @@ using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; + namespace PlexRequests.Api.Models.Movie { public class ProfileList { public bool core { get; set; } + public bool hide { get; set; } public string _rev { get; set; } public List finish { get; set; } public List qualities { get; set; } @@ -42,7 +46,8 @@ namespace PlexRequests.Api.Models.Movie public List stop_after { get; set; } public List wait_for { get; set; } public int order { get; set; } - public List __invalid_name__3d { get; set; } + [JsonProperty(PropertyName = "3d")] + public List threeD { get; set; } } public class CouchPotatoProfiles diff --git a/PlexRequests.Api/CouchPotatoApi.cs b/PlexRequests.Api/CouchPotatoApi.cs index 3693a28be..4ec0356c5 100644 --- a/PlexRequests.Api/CouchPotatoApi.cs +++ b/PlexRequests.Api/CouchPotatoApi.cs @@ -143,8 +143,8 @@ namespace PlexRequests.Api request.AddUrlSegment("status", string.Join(",", status)); try { - var obj = RetryHandler.Execute(() => Api.Execute (request, baseUrl), - new TimeSpan[] { + var obj = RetryHandler.Execute(() => Api.Execute (request, baseUrl), + new[] { TimeSpan.FromSeconds (5), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(30) diff --git a/PlexRequests.UI/Modules/RequestsModule.cs b/PlexRequests.UI/Modules/RequestsModule.cs index 365c7f6b3..cbb9e1524 100644 --- a/PlexRequests.UI/Modules/RequestsModule.cs +++ b/PlexRequests.UI/Modules/RequestsModule.cs @@ -44,6 +44,8 @@ using System.Collections.Generic; using PlexRequests.Api.Interfaces; using System.Threading.Tasks; +using NLog; + namespace PlexRequests.UI.Modules { public class RequestsModule : BaseAuthModule @@ -87,6 +89,7 @@ namespace PlexRequests.UI.Modules Post["/addnote", true] = async (x, ct) => await AddNote((int)Request.Form.requestId, (string)Request.Form.noteArea); } + private static Logger Log = LogManager.GetCurrentClassLogger(); private IRequestService Service { get; } private INotificationService NotificationService { get; } private ISettingsService PrSettings { get; } @@ -126,13 +129,20 @@ namespace PlexRequests.UI.Modules var cpSettings = CpSettings.GetSettings(); if (cpSettings.Enabled) { - - var result = await Cache.GetOrSetAsync(CacheKeys.CouchPotatoQualityProfiles, async () => + try { - return await Task.Run(() => CpApi.GetProfiles(cpSettings.FullUri, cpSettings.ApiKey)).ConfigureAwait(false); - }); + var result = await Cache.GetOrSetAsync(CacheKeys.CouchPotatoQualityProfiles, async () => + { + return await Task.Run(() => CpApi.GetProfiles(cpSettings.FullUri, cpSettings.ApiKey)).ConfigureAwait(false); + }); + + qualities = result.list.Select(x => new QualityModel() { Id = x._id, Name = x.label }).ToList(); - qualities = result.list.Select(x => new QualityModel() { Id = x._id, Name = x.label }).ToList(); + } + catch (Exception e) + { + Log.Info(e); + } } }