Fix {info.poster}

This commit is contained in:
Reinhard Pointner 2016-08-12 02:04:41 +08:00
parent e5dc94afa9
commit e6f57fa3a6
1 changed files with 13 additions and 0 deletions

View File

@ -173,8 +173,17 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
public MovieInfo getMovieInfo(String id, Locale locale, boolean extendedInfo) throws Exception {
Object response = request("movie/" + id, extendedInfo ? singletonMap("append_to_response", "alternative_titles,releases,casts,trailers") : emptyMap(), locale, REQUEST_LIMIT);
// read all basic movie properties
Map<MovieProperty, String> fields = getEnumMap(response, MovieProperty.class);
// fix poster path
try {
fields.computeIfPresent(MovieProperty.poster_path, (k, v) -> resolveImage(v).toString());
} catch (Exception e) {
// movie does not belong to any collection
debug.warning(format("Bad data: poster_path => %s", response));
}
try {
Map<?, ?> collection = getMap(response, "belongs_to_collection");
fields.put(MovieProperty.collection, getString(collection, "name"));
@ -510,6 +519,10 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
return get(MovieProperty.homepage, URL::new);
}
public URL getPoster() {
return get(MovieProperty.poster_path, URL::new);
}
public List<String> getGenres() {
return unmodifiableList(asList(genres));
}