Fixed a sonarr deseralization error.

pull/1284/head
tidusjar 8 years ago
parent 2b27559277
commit 20c4ce8b7d

@ -25,7 +25,7 @@ namespace Ombi.Api.Models.Sonarr
{
public SonarrAddSeries()
{
images = new List<string>();
images = new List<SonarrImage>();
}
public AddOptions addOptions { get; set; }
public string title { get; set; }
@ -40,7 +40,7 @@ namespace Ombi.Api.Models.Sonarr
public string imdbId { get; set; }
public string titleSlug { get; set; }
public int id { get; set; }
public List<string> images { get; set; }
public List<SonarrImage> images { get; set; }
[JsonIgnore]
public List<string> ErrorMessages { get; set; }
}
@ -51,4 +51,18 @@ namespace Ombi.Api.Models.Sonarr
public bool ignoreEpisodesWithoutFiles { get; set; }
public bool searchForMissingEpisodes { get; set; }
}
public class Addoptions
{
public bool searchForMissingEpisodes { get; set; }
public bool ignoreEpisodesWithFiles { get; set; }
public bool ignoreEpisodesWithoutFiles { get; set; }
}
public class SonarrImage
{
public string coverType { get; set; }
public string url { get; set; }
}
}

@ -45,7 +45,7 @@ namespace Ombi.Api
MissingMemberHandling = MissingMemberHandling.Ignore
};
private static Logger Log = LogManager.GetCurrentClassLogger();
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// An API request handler
/// </summary>
@ -58,8 +58,7 @@ namespace Ombi.Api
var client = new RestClient { BaseUrl = baseUri };
var response = client.Execute<T>(request);
Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}");
if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created)
if ((int)response.StatusCode < 300)
return response.Data;
else
throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}.");
@ -78,8 +77,7 @@ namespace Ombi.Api
var client = new RestClient { BaseUrl = baseUri };
var response = client.Execute(request);
Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}");
if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created)
if ((int)response.StatusCode < 300)
return DeserializeXml<T>(response.Content);
else
throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}.");
@ -92,7 +90,7 @@ namespace Ombi.Api
var response = client.Execute(request);
Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}");
if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created)
if ((int)response.StatusCode < 300)
return JsonConvert.DeserializeObject<T>(response.Content, _settings);
else
throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}.");

@ -864,6 +864,14 @@ namespace Ombi.UI.Modules
private async Task<Response> RequestMovie(int movieId)
{
if(string.IsNullOrEmpty(Username))
{
return Response.AsJson(new JsonResponseModel
{
Result = false,
Message = "Your session has expired, please refresh the page"
});
}
if (Security.HasPermissions(User, Permissions.ReadOnlyUser) || !Security.HasPermissions(User, Permissions.RequestMovie))
{
return
@ -1031,6 +1039,14 @@ namespace Ombi.UI.Modules
/// <returns></returns>
private async Task<Response> RequestTvShow(int showId, string seasons)
{
if (string.IsNullOrEmpty(Username))
{
return Response.AsJson(new JsonResponseModel
{
Result = false,
Message = "Your session has expired, please refresh the page"
});
}
if (Security.HasPermissions(User, Permissions.ReadOnlyUser) || !Security.HasPermissions(User, Permissions.RequestTvShow))
{
return

Loading…
Cancel
Save