Added some debugging code around the newsletter for Emby #1116

This commit is contained in:
tidusjar 2017-02-17 22:37:19 +00:00
parent d6684eb1de
commit 10ef372cfd

View file

@ -33,6 +33,7 @@ using NLog;
using Ombi.Api.Interfaces; using Ombi.Api.Interfaces;
using Ombi.Api.Models.Emby; using Ombi.Api.Models.Emby;
using Ombi.Helpers; using Ombi.Helpers;
using Polly;
using RestSharp; using RestSharp;
namespace Ombi.Api namespace Ombi.Api
@ -162,30 +163,72 @@ namespace Ombi.Api
TimeSpan.FromSeconds(5) TimeSpan.FromSeconds(5)
}); });
IRestResponse response = null;
try
{
switch (type)
{
case EmbyMediaType.Movie:
response = policy.Execute(() => Api.Execute(request, baseUri));
break;
case EmbyMediaType.Series:
response = policy.Execute(() => Api.Execute(request, baseUri));
break;
case EmbyMediaType.Music:
break;
case EmbyMediaType.Episode:
response = policy.Execute(() => Api.Execute(request, baseUri));
break;
default:
throw new ArgumentOutOfRangeException(nameof(type), type, null);
}
var info = new EmbyInformation();
switch (type) switch (type)
{ {
case EmbyMediaType.Movie: case EmbyMediaType.Movie:
return new EmbyInformation return new EmbyInformation
{ {
MovieInformation = policy.Execute(() => Api.ExecuteJson<EmbyMovieInformation>(request, baseUri)) MovieInformation = JsonConvert.DeserializeObject<EmbyMovieInformation>(response.Content)
}; };
case EmbyMediaType.Series: case EmbyMediaType.Series:
return new EmbyInformation return new EmbyInformation
{ {
SeriesInformation = SeriesInformation = JsonConvert.DeserializeObject<EmbySeriesInformation>(response.Content)
policy.Execute(() => Api.ExecuteJson<EmbySeriesInformation>(request, baseUri))
}; };
case EmbyMediaType.Music: case EmbyMediaType.Music:
break; break;
case EmbyMediaType.Episode: case EmbyMediaType.Episode:
return new EmbyInformation return new EmbyInformation
{ {
EpisodeInformation = EpisodeInformation = JsonConvert.DeserializeObject<EmbyEpisodeInformation>(response.Content)
policy.Execute(() => Api.ExecuteJson<EmbyEpisodeInformation>(request, baseUri))
}; };
default: default:
throw new ArgumentOutOfRangeException(nameof(type), type, null); throw new ArgumentOutOfRangeException(nameof(type), type, null);
} }
}
catch (Exception e)
{
Log.Error("Could not get the media item's information");
Log.Error(e);
Log.Debug("ResponseContent");
Log.Debug(response?.Content ?? "Empty");
Log.Debug("ResponseStatusCode");
Log.Debug(response?.StatusCode ?? HttpStatusCode.PreconditionFailed);
Log.Debug("ResponseError");
Log.Debug(response?.ErrorMessage ?? "No Error");
Log.Debug("ResponseException");
Log.Debug(response?.ErrorException ?? new Exception());
throw;
}
return new EmbyInformation(); return new EmbyInformation();
} }