1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 13:02:47 +01:00

Fixed: Only Add Images if not Null on TMDB

This commit is contained in:
Qstick 2020-01-20 20:59:50 -05:00
parent 92f7b25117
commit dfa3df8ea5

View File

@ -191,8 +191,8 @@ public Tuple<Movie, List<Credit>> GetMovieInfo(int tmdbId, Profile profile, bool
movie.TitleSlug += "-" + movie.TmdbId.ToString(); movie.TitleSlug += "-" + movie.TmdbId.ToString();
movie.Images.Add(_configService.GetCoverForURL(resource.poster_path, MediaCoverTypes.Poster)); //TODO: Update to load image specs from tmdb page! movie.Images.AddIfNotNull(MapImage(resource.poster_path, MediaCoverTypes.Poster)); //TODO: Update to load image specs from tmdb page!
movie.Images.Add(_configService.GetCoverForURL(resource.backdrop_path, MediaCoverTypes.Fanart)); movie.Images.AddIfNotNull(MapImage(resource.backdrop_path, MediaCoverTypes.Fanart));
movie.Runtime = resource.runtime; movie.Runtime = resource.runtime;
//foreach(Title title in resource.alternative_titles.titles) //foreach(Title title in resource.alternative_titles.titles)
@ -321,8 +321,8 @@ public Tuple<Movie, List<Credit>> GetMovieInfo(int tmdbId, Profile profile, bool
{ {
movie.Collection = MapCollection(resource.belongs_to_collection); movie.Collection = MapCollection(resource.belongs_to_collection);
movie.Collection.Images.Add(_configService.GetCoverForURL(resource.belongs_to_collection.poster_path, MediaCoverTypes.Poster)); movie.Collection.Images.AddIfNotNull(MapImage(resource.belongs_to_collection.poster_path, MediaCoverTypes.Poster));
movie.Collection.Images.Add(_configService.GetCoverForURL(resource.belongs_to_collection.backdrop_path, MediaCoverTypes.Fanart)); movie.Collection.Images.AddIfNotNull(MapImage(resource.belongs_to_collection.backdrop_path, MediaCoverTypes.Fanart));
} }
return new Tuple<Movie, List<Credit>>(movie, people); return new Tuple<Movie, List<Credit>>(movie, people);
@ -620,8 +620,7 @@ public Movie MapMovie(MovieResult result)
try try
{ {
var imdbPoster = _configService.GetCoverForURL(result.poster_path, MediaCoverTypes.Poster); imdbMovie.Images.AddIfNotNull(MapImage(result.poster_path, MediaCoverTypes.Poster));
imdbMovie.Images.Add(imdbPoster);
} }
catch (Exception) catch (Exception)
{ {
@ -703,6 +702,16 @@ private static MovieCollection MapCollection(CollectionResource arg)
return newCollection; return newCollection;
} }
private MediaCover.MediaCover MapImage(string path, MediaCoverTypes type)
{
if (path.IsNotNullOrWhiteSpace())
{
return _configService.GetCoverForURL(path, type);
}
return null;
}
public Movie MapMovieToTmdbMovie(Movie movie) public Movie MapMovieToTmdbMovie(Movie movie)
{ {
try try