use of com.uwetrottmann.tmdb2.entities.FindResults in project nzbhydra2 by theotherp.
the class TmdbHandler method getMovieByImdbId.
private Movie getMovieByImdbId(String imdbId) throws InfoProviderException {
Movie movie;
Call<FindResults> resultsCall = tmdb.findService().find(imdbId, ExternalSource.IMDB_ID, configProvider.getBaseConfig().getSearching().getLanguage().orElse("en"));
try {
Response<FindResults> response = resultsCall.execute();
if (!response.isSuccessful()) {
throw new InfoProviderException("Error while contacting TMDB: " + response.errorBody().string());
}
if (response.body().movie_results.size() == 0) {
throw new InfoProviderException(String.format("TMDB query for IMDB ID %s returned no searchResults", imdbId));
}
movie = response.body().movie_results.get(0);
} catch (IOException e) {
throw new InfoProviderException("Error while contacting TMDB", e);
}
return movie;
}
Aggregations