Closed faxe1008 closed 7 years ago
Does this happen to all movies? or just some?
As far as I can tell, yes
Can you give me a sample of your code and I will try and look at it today. Thanks
private static final String apiKey = "<KEY>";
TmdbSearch apiSearch = new TmdbSearch(apiKey, new HttpTools(httpClient));
result = apiSearch.searchMovie("batman", nextPage, "de", true, null, null, null);
List<Genre> lg = result[0].getGenres();
if(lg!=null && lg.size()>0)
System.out.println(lg.get(0).getName());
Ok, the genres are now listed as IDs rather than specific strings. Your application will need to pre-load and cache a map of the genre IDs and Names, e.g.
private Map<Integer, String> mapGenres(String language) throws MovieDbException {
TmdbGenres tmdbGenres = new TmdbGenres(getApiKey(), getHttpTools());
List<Genre> genreList = tmdbGenres.getGenreMovieList(language).getResults();
Map<Integer, String> genreMap = new HashMap<>();
for(Genre g:genreList) {
genreMap.put(g.getId(), g.getName());
}
return genreMap;
}
Then you can do something like:
ResultList<MovieInfo> movieList = apiSearch.searchMovie("Blade Runner", 0, "", null, 0, 0, SearchType.PHRASE);
MovieInfo result = movieList.getResults().get(0);
Map<Integer, String> genreMap = mapGenres("de");
for (int g : result.getGenreIds()) {
LOG.info("{} = {}", g, genreMap.get(g));
}
I noticed that the GetGenres() method of the MovieInfo class always returns null. Did they change anything in their JSON encoding?