info.movito.themoviedbapi.TmdbGenre Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of themoviedbapi Show documentation
Show all versions of themoviedbapi Show documentation
A Java-wrapper around the JSON API provided by TMdB, which is an open database for movie and tv content.
package info.movito.themoviedbapi;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import info.movito.themoviedbapi.model.core.AbstractJsonMapping;
import info.movito.themoviedbapi.model.core.Genre;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for genre. See the
* documentation for more info.
*/
public class TmdbGenre extends AbstractTmdbApi {
protected static final String TMDB_METHOD_GENRE = "genre";
/**
* Create a new TmdbGenre instance to call the genre related TMDb API methods.
*/
public TmdbGenre(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
* Get the list of official genres for movies.
* See the documentation for more info.
*
* @param language nullable - The language to query the results in. Default: en-US.
* @return The list of official genres for movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public List getMovieList(String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GENRE, "movie/list");
apiUrl.addLanguage(language);
return mapJsonResult(apiUrl, Genres.class).genres;
}
/**
* Get the list of official genres for TV shows.
* See the documentation for more info.
*
* @param language nullable - The language to query the results in. Default: en-US.
* @return The list of official genres for movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public List getTvList(String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GENRE, "tv/list");
apiUrl.addLanguage(language);
return mapJsonResult(apiUrl, Genres.class).genres;
}
private static class Genres extends AbstractJsonMapping {
@JsonProperty("genres")
private List genres;
}
}