Fixed an issue where sometimes the json returned from IMDb just was not parsed correctly for some misterious reason.

This commit is contained in:
Leonardo Galli 2017-01-04 15:01:34 +01:00
parent b47d5f7fa1
commit 6e2ded5d33
4 changed files with 32 additions and 3 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -0,0 +1,21 @@
using System.Collections.Generic;
namespace NzbDrone.Core.MetadataSource.SkyHook.Resource
{
public class ImdbResource
{
public int v { get; set; }
public string q { get; set; }
public MovieResource[] d { get; set; }
}
public class MovieResource
{
public string l { get; set; }
public string id { get; set; }
public string s { get; set; }
public int y { get; set; }
public string q { get; set; }
public object[] i { get; set; }
}
}

View File

@ -148,11 +148,17 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
var responseCleaned = response.Content.Replace(imdbCallback, "").TrimEnd(")");
dynamic json = JsonConvert.DeserializeObject(responseCleaned);
_logger.Warn("Cleaned response: " + responseCleaned);
ImdbResource json = JsonConvert.DeserializeObject<ImdbResource>(responseCleaned);
_logger.Warn("Json object: " + json);
_logger.Warn("Crash ahead.");
var imdbMovies = new List<Movie>();
foreach (dynamic entry in json.d)
foreach (MovieResource entry in json.d)
{
var imdbMovie = new Movie();
imdbMovie.ImdbId = entry.id;
@ -166,7 +172,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
imdbMovie.Images = new List<MediaCover.MediaCover>();
try
{
string url = entry.i[0];
string url = (string)entry.i[0];
var imdbPoster = new MediaCover.MediaCover(MediaCoverTypes.Poster, url);
imdbMovie.Images.Add(imdbPoster);
}

View File

@ -183,6 +183,7 @@
<Compile Include="Datastore\Migration\002_remove_tvrage_imdb_unique_constraint.cs" />
<Compile Include="Datastore\Migration\003_remove_clean_title_from_scene_mapping.cs" />
<Compile Include="Datastore\Migration\004_updated_history.cs" />
<Compile Include="Datastore\Migration\105_fix_history_movieId.cs" />
<Compile Include="Datastore\Migration\005_added_eventtype_to_history.cs" />
<Compile Include="Datastore\Migration\006_add_index_to_log_time.cs" />
<Compile Include="Datastore\Migration\007_add_renameEpisodes_to_naming.cs" />
@ -807,6 +808,7 @@
<Compile Include="MetadataSource\SkyHook\Resource\ImageResource.cs" />
<Compile Include="MetadataSource\SkyHook\Resource\RatingResource.cs" />
<Compile Include="MetadataSource\SkyHook\Resource\SeasonResource.cs" />
<Compile Include="MetadataSource\SkyHook\Resource\MovieResource.cs" />
<Compile Include="MetadataSource\SkyHook\Resource\ShowResource.cs" />
<Compile Include="MetadataSource\SkyHook\Resource\TimeOfDayResource.cs" />
<Compile Include="MetadataSource\SkyHook\SkyHookProxy.cs" />