Search in sources :

Example 1 with FindResults

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;
}
Also used : Movie(com.uwetrottmann.tmdb2.entities.Movie) FindResults(com.uwetrottmann.tmdb2.entities.FindResults) IOException(java.io.IOException)

Aggregations

FindResults (com.uwetrottmann.tmdb2.entities.FindResults)1 Movie (com.uwetrottmann.tmdb2.entities.Movie)1 IOException (java.io.IOException)1