mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 04:49:33 -07:00
Made #85 better
This commit is contained in:
parent
7349f78b80
commit
1f9ed51320
2 changed files with 15 additions and 16 deletions
|
@ -92,19 +92,11 @@ namespace PlexRequests.Api
|
||||||
throw new ApplicationException(message, response.ErrorException);
|
throw new ApplicationException(message, response.ErrorException);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var json = JsonConvert.DeserializeObject<T>(response.Content);
|
var json = JsonConvert.DeserializeObject<T>(response.Content);
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.Error(e);
|
|
||||||
Log.Error(response.Content);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private T DeserializeXml<T>(string input)
|
private T DeserializeXml<T>(string input)
|
||||||
where T : class
|
where T : class
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using PlexRequests.Api.Interfaces;
|
using PlexRequests.Api.Interfaces;
|
||||||
using PlexRequests.Api.Models.Sonarr;
|
using PlexRequests.Api.Models.Sonarr;
|
||||||
|
@ -93,15 +96,19 @@ namespace PlexRequests.Api
|
||||||
request.AddHeader("X-Api-Key", apiKey);
|
request.AddHeader("X-Api-Key", apiKey);
|
||||||
request.AddJsonBody(options);
|
request.AddJsonBody(options);
|
||||||
|
|
||||||
var obj = Api.ExecuteJson<SonarrAddSeries>(request, baseUrl);
|
SonarrAddSeries result;
|
||||||
|
try
|
||||||
if (obj == null)
|
|
||||||
{
|
{
|
||||||
|
result = Api.ExecuteJson<SonarrAddSeries>(request, baseUrl);
|
||||||
|
}
|
||||||
|
catch (JsonSerializationException jse)
|
||||||
|
{
|
||||||
|
Log.Error(jse);
|
||||||
var error = Api.ExecuteJson<SonarrError>(request, baseUrl);
|
var error = Api.ExecuteJson<SonarrError>(request, baseUrl);
|
||||||
obj = new SonarrAddSeries { ErrorMessage = error.errorMessage };
|
result = new SonarrAddSeries { ErrorMessage = error.errorMessage };
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemStatus SystemStatus(string apiKey, Uri baseUrl)
|
public SystemStatus SystemStatus(string apiKey, Uri baseUrl)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue