*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @return The account details.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Account getDetails(Integer accountId, String sessionId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId)
.addQueryParam(PARAM_SESSION, sessionId);
return mapJsonResult(apiUrl, Account.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param mediaId the id of the media to add to the favorites list.
* @param mediaType the type of media to add to the favorites list.
* @return The status of the request.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus addFavorite(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType)
throws TmdbException {
return changeFavoriteStatus(accountId, sessionId, mediaId, mediaType, true);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param mediaId the id of the media to remove from the favorites list.
* @param mediaType the type of media to remove from the favorites list.
* @return The status of the request.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus removeFavorite(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType)
throws TmdbException {
return changeFavoriteStatus(accountId, sessionId, mediaId, mediaType, false);
}
private ResponseStatus changeFavoriteStatus(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType,
boolean isFavorite) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "favorite")
.addQueryParam(PARAM_SESSION, sessionId);
HashMap body = new HashMap<>();
body.put("media_type", mediaType.toString());
body.put("media_id", mediaId);
body.put("favorite", isFavorite);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param mediaId the id of the media to add to the watch list.
* @param mediaType the type of media to add to the watch list.
* @return The status of the request.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus addToWatchList(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType)
throws TmdbException {
return changeWatchListStatus(accountId, sessionId, mediaId, mediaType, true);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param mediaId the id of the media to remove from the watch list.
* @param mediaType the type of media to remove from the watch list.
* @return The status of the request.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus removeFromWatchList(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType)
throws TmdbException {
return changeWatchListStatus(accountId, sessionId, mediaId, mediaType, false);
}
private ResponseStatus changeWatchListStatus(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType,
boolean isWatchList) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "watchlist")
.addQueryParam(PARAM_SESSION, sessionId);
HashMap body = new HashMap<>();
body.put("media_type", mediaType.toString());
body.put("media_id", mediaId);
body.put("watchlist", isWatchList);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The favorite movies of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage getFavoriteMovies(Integer accountId, String sessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "favorite/movies")
.addQueryParam(PARAM_SESSION, sessionId)
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, MovieResultsPage.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The favorite tv series of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getFavoriteTv(Integer accountId, String sessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "favorite/tv")
.addQueryParam(PARAM_SESSION, sessionId)
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param page nullable - The page of results to return. Default: 1.
* @return The lists of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieListResultsPage getLists(Integer accountId, String sessionId, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "lists")
.addQueryParam(PARAM_SESSION, sessionId)
.addPage(page);
return mapJsonResult(apiUrl, MovieListResultsPage.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The rated movies of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public RatedMovieResultsPage getRatedMovies(int accountId, String sessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "rated/movies")
.addQueryParam(PARAM_SESSION, sessionId)
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, RatedMovieResultsPage.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The rated tv series of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public RatedTvSeriesResultsPage getRatedTvSeries(int accountId, String sessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "rated/tv")
.addQueryParam(PARAM_SESSION, sessionId)
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, RatedTvSeriesResultsPage.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The rated tv episodes of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public RatedTvEpisodeResultsPage getRatedTvEpisodes(int accountId, String sessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "rated/tv/episodes")
.addQueryParam(PARAM_SESSION, sessionId)
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, RatedTvEpisodeResultsPage.class);
}
/**
*
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The movies in the account's watchlist
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage getWatchListMovies(Integer accountId, String sessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "watchlist/movies")
.addQueryParam(PARAM_SESSION, sessionId)
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, MovieResultsPage.class);
}
/**
*
Get the list of tv series on an accounts watchlist.
*
* @param accountId The account id of the user.
* @param sessionId nullable - The session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The tv series in the account's watchlist
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getWatchListTvSeries(Integer accountId, String sessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "watchlist/tv")
.addQueryParam(PARAM_SESSION, sessionId)
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
/**
* Needed to tell TMDB API about what type of id is provided.
* e.g. see the documentation
*/
public enum MediaType {
MOVIE, TV;
@Override
public String toString() {
return super.toString().toLowerCase();
}
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbApi.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.tools.TmdbHttpClient;
import info.movito.themoviedbapi.tools.TmdbUrlReader;
import lombok.AccessLevel;
import lombok.Getter;
/**
* The movie db api for getting started. See the
* documentation for more info.
*
* @author Holger Brandl.
*/
public class TmdbApi {
/**
* Http client to make requests to the movie database api.
*/
@Getter(AccessLevel.PROTECTED)
private final TmdbUrlReader tmdbUrlReader;
/**
* Constructor.
*
* @param apiKey your TMDB api key
*/
public TmdbApi(String apiKey) {
this(new TmdbHttpClient(apiKey));
}
/**
* Constructor.
*
* @param tmdbUrlReader the url reader to use
*/
public TmdbApi(TmdbUrlReader tmdbUrlReader) {
this.tmdbUrlReader = tmdbUrlReader;
}
public TmdbAccount getAccount() {
return new TmdbAccount(this);
}
public TmdbAuthentication getAuthentication() {
return new TmdbAuthentication(this);
}
public TmdbCertifications getCertifications() {
return new TmdbCertifications(this);
}
public TmdbChanges getChanges() {
return new TmdbChanges(this);
}
public TmdbCollections getCollections() {
return new TmdbCollections(this);
}
public TmdbCompanies getCompanies() {
return new TmdbCompanies(this);
}
public TmdbConfiguration getConfiguration() {
return new TmdbConfiguration(this);
}
public TmdbDiscover getDiscover() {
return new TmdbDiscover(this);
}
public TmdbFind getFind() {
return new TmdbFind(this);
}
public TmdbGenre getGenre() {
return new TmdbGenre(this);
}
public TmdbGuestSessions getGuestSessions() {
return new TmdbGuestSessions(this);
}
public TmdbKeywords getKeywords() {
return new TmdbKeywords(this);
}
public TmdbLists getLists() {
return new TmdbLists(this);
}
public TmdbMovieLists getMovieLists() {
return new TmdbMovieLists(this);
}
public TmdbMovies getMovies() {
return new TmdbMovies(this);
}
public TmdbNetworks getNetworks() {
return new TmdbNetworks(this);
}
public TmdbPeopleLists getPeopleLists() {
return new TmdbPeopleLists(this);
}
public TmdbPeople getPeople() {
return new TmdbPeople(this);
}
public TmdbReviews getReviews() {
return new TmdbReviews(this);
}
public TmdbSearch getSearch() {
return new TmdbSearch(this);
}
public TmdbTrending getTrending() {
return new TmdbTrending(this);
}
public TmdbTvEpisodes getTvEpisodes() {
return new TmdbTvEpisodes(this);
}
public TmdbTvEpisodeGroups getTvEpisodeGroups() {
return new TmdbTvEpisodeGroups(this);
}
public TmdbTvSeasons getTvSeasons() {
return new TmdbTvSeasons(this);
}
public TmdbTvSeries getTvSeries() {
return new TmdbTvSeries(this);
}
public TmdbTvSeriesLists getTvSeriesLists() {
return new TmdbTvSeriesLists(this);
}
public TmdbWatchProviders getWatchProviders() {
return new TmdbWatchProviders(this);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbAuthentication.java
================================================
package info.movito.themoviedbapi;
import java.util.HashMap;
import info.movito.themoviedbapi.model.authentication.GuestSession;
import info.movito.themoviedbapi.model.authentication.RequestToken;
import info.movito.themoviedbapi.model.authentication.Session;
import info.movito.themoviedbapi.model.core.responses.ResponseStatusAuthentication;
import info.movito.themoviedbapi.model.core.responses.ResponseStatusDelete;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.RequestType;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.util.JsonUtil;
/**
* The movie database api for authentication. See the
* documentation for more info.
*/
public class TmdbAuthentication extends AbstractTmdbApi {
protected static final String TMDB_METHOD_AUTH = "authentication";
private static final String PARAM_REQUEST_TOKEN = "request_token";
/**
* Create a new TmdbAuthentication instance to call the authentication related TMDb API methods.
*/
TmdbAuthentication(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @return The guest session.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public GuestSession createGuestSession() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "guest_session/new");
return mapJsonResult(apiUrl, GuestSession.class);
}
/**
*
Creates an unauthenticated request token. This will need to be authenticated by the user using
* {@link #getTmdbAuthenticationUrlForRequestToken(RequestToken, String)}. If you cannot redirect the user to a browser,
* use {@link #createAuthenticatedRequestToken(RequestToken, String, String)} instead.
*
* @return The unauthenticated request token.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public RequestToken createRequestToken() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "token/new");
return mapJsonResult(apiUrl, RequestToken.class);
}
/**
*
Creates the url to redirect the user to in order to authenticate their request token.
*
* @param token The request token.
* @param redirectUrl nullable - The url to redirect the user to after authentication.
* @return The url to redirect the user to.
* @throws TmdbException If the request token is null or not successful.
*/
public static String getTmdbAuthenticationUrlForRequestToken(RequestToken token, String redirectUrl) throws TmdbException {
if (token == null || !token.getSuccess()) {
throw new TmdbException("Invalid request token! The request token must not be null and must be successful!");
}
StringBuilder sb = new StringBuilder("https://www.themoviedb.org/authenticate/");
sb.append(token.getRequestToken());
if (redirectUrl != null && !redirectUrl.trim().isEmpty()) {
sb.append("?redirect_to=").append(redirectUrl);
}
return sb.toString();
}
/**
*
Creates an authenticated request token, with the non-authenticated request token, username and password.
*
Use this function if you have no way of directing the user to a browser for authentication.
*
* @param token The unauthenticated request token.
* @param username The TMDB account username.
* @param password The TMDB account password.
* @return The authenticated request token.
* @throws TmdbException If the request token is null or not successful. Or, if there was an error making the request or mapping the
* response.
*/
public RequestToken createAuthenticatedRequestToken(RequestToken token, String username, String password) throws TmdbException {
if (token == null || !token.getSuccess()) {
throw new TmdbException("Invalid request token! The request token must not be null and must be successful!");
}
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "token/validate_with_login");
HashMap body = new HashMap<>();
body.put("username", username);
body.put("password", password);
body.put(PARAM_REQUEST_TOKEN, token.getRequestToken());
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, RequestToken.class);
}
/**
*
Creates a session with an authenticated request token.
*
* @param token The authenticated request token.
* @return The session.
* @throws TmdbException If the request token is null or not successful.
*/
public Session createSession(RequestToken token) throws TmdbException {
if (token == null || !token.getSuccess()) {
throw new TmdbException("Invalid request token! The request token must not be null and must be successful!");
}
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "session/new");
HashMap body = new HashMap<>();
body.put(PARAM_REQUEST_TOKEN, token.getRequestToken());
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, Session.class);
}
/**
*
*
* @param sessionId The session id.
* @return The response status.
* @throws TmdbException If the session id is null or empty. Or, if there was an error making the request or mapping the response.
*/
public ResponseStatusDelete deleteSession(String sessionId) throws TmdbException {
if (sessionId == null || sessionId.trim().isEmpty()) {
throw new TmdbException("Invalid session id! The session id must not be null or empty!");
}
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "session");
HashMap body = new HashMap<>();
body.put("session_id", sessionId);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.DELETE, ResponseStatusDelete.class);
}
/**
*
*
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatusAuthentication validateKey() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH);
return mapJsonResult(apiUrl, ResponseStatusAuthentication.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbCertifications.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.certifications.CertificationResults;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for certifications. See the
* documentation for more info.
*/
public class TmdbCertifications extends AbstractTmdbApi {
protected static final String TMDB_METHOD_CERTIFICATIONS = "certification";
protected static final String TMDB_METHOD_MOVIE_CERTIFICATIONS = "movie/list";
protected static final String TMDB_METHOD_TV_CERTIFICATIONS = "tv/list";
TmdbCertifications(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
Get an up to date list of the officially supported movie certifications on TMDB.
*
* @return The movie certifications.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public CertificationResults getMovieCertifications() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CERTIFICATIONS, TMDB_METHOD_MOVIE_CERTIFICATIONS);
return mapJsonResult(apiUrl, CertificationResults.class);
}
/**
*
Get an up to date list of the officially supported tv certifications on TMDB.
*
* @return The tv certifications.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public CertificationResults getTvCertifications() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CERTIFICATIONS, TMDB_METHOD_TV_CERTIFICATIONS);
return mapJsonResult(apiUrl, CertificationResults.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbChanges.java
================================================
package info.movito.themoviedbapi;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import info.movito.themoviedbapi.model.changes.ChangesResultsPage;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for changes. See the
* documentation for more info.
*/
public class TmdbChanges extends AbstractTmdbApi {
protected static final String TMDB_METHOD_CHANGES = "changes";
protected static final String TMDB_METHOD_MOVIE = "movie";
protected static final String TMDB_METHOD_PERSON = "person";
protected static final String TMDB_METHOD_TV = "tv";
/**
* Create a new TmdbChanges instance to call the changes related TMDb API methods.
*/
TmdbChanges(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
Get a list of all the movie ids that have been changed in the past 24 hours.
*
* @param startDate nullable - The start date, in format: YYYY-MM-DD.
* @param endDate nullable - The end date, in format: YYYY-MM-DD.
* @param page nullable - The page of results to return. Default: 1.
* @return The changes results page.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ChangesResultsPage getMovieChangesList(String startDate, String endDate, Integer page) throws TmdbException {
if (calculateDaysDifference(startDate, endDate) > 14) {
throw new IllegalArgumentException("The date range must be less than or equal to 14 days.");
}
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, TMDB_METHOD_CHANGES)
.addQueryParam("start_date", startDate)
.addQueryParam("end_date", endDate)
.addPage(page);
return mapJsonResult(apiUrl, ChangesResultsPage.class);
}
/**
*
Get a list of all the people ids that have been changed in the past 24 hours.
*
* @param startDate nullable - The start date, in format: YYYY-MM-DD.
* @param endDate nullable - The end date, in format: YYYY-MM-DD.
* @param page nullable - The page of results to return. Default: 1.
* @return The changes results page.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ChangesResultsPage getPeopleChangesList(String startDate, String endDate, Integer page) throws TmdbException {
if (calculateDaysDifference(startDate, endDate) > 14) {
throw new IllegalArgumentException("The date range must be less than or equal to 14 days.");
}
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, TMDB_METHOD_CHANGES)
.addQueryParam("start_date", startDate)
.addQueryParam("end_date", endDate)
.addPage(page);
return mapJsonResult(apiUrl, ChangesResultsPage.class);
}
/**
*
Get a list of all the tv ids that have been changed in the past 24 hours.
*
* @param startDate nullable - The start date, in format: YYYY-MM-DD.
* @param endDate nullable - The end date, in format: YYYY-MM-DD.
* @param page nullable - The page of results to return. Default: 1.
* @return nullable - The changes results page.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ChangesResultsPage getTvChangesList(String startDate, String endDate, Integer page) throws TmdbException {
if (calculateDaysDifference(startDate, endDate) > 14) {
throw new IllegalArgumentException("The date range must be less than or equal to 14 days.");
}
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, TMDB_METHOD_CHANGES)
.addQueryParam("start_date", startDate)
.addQueryParam("end_date", endDate)
.addPage(page);
return mapJsonResult(apiUrl, ChangesResultsPage.class);
}
/**
* Calculate the difference in days between two date strings.
*
* @param startDateString the start date string, in format: YYYY-MM-DD.
* @param endDateString the end date string, in format: YYYY-MM-DD.
* @return the difference in days.
*/
private static long calculateDaysDifference(String startDateString, String endDateString) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(startDateString, formatter);
LocalDate endDate = LocalDate.parse(endDateString, formatter);
return ChronoUnit.DAYS.between(startDate, endDate);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbCollections.java
================================================
package info.movito.themoviedbapi;
import java.util.List;
import info.movito.themoviedbapi.model.collections.CollectionInfo;
import info.movito.themoviedbapi.model.collections.Images;
import info.movito.themoviedbapi.model.collections.Translation;
import info.movito.themoviedbapi.model.collections.Translations;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for collections. See the
* documentation for more info.
*/
public class TmdbCollections extends AbstractTmdbApi {
protected static final String TMDB_METHOD_COLLECTION = "collection";
/**
* Create a new TmdbCollections instance to call the collections related TMDb API methods.
*/
TmdbCollections(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param collectionId The collection id.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The collection info.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public CollectionInfo getDetails(Integer collectionId, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COLLECTION, collectionId)
.addLanguage(language);
return mapJsonResult(apiUrl, CollectionInfo.class);
}
/**
*
*
* @param collectionId The collection id.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it
* @return The images.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Images getImages(Integer collectionId, String language, String... includeImageLanguage) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COLLECTION, collectionId, "images")
.addLanguage(language)
.addQueryParamCommandSeparated("include_image_language", includeImageLanguage);
return mapJsonResult(apiUrl, Images.class);
}
/**
*
*
* @param collectionId The collection id.
* @return The translations.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public List getTranslations(Integer collectionId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COLLECTION, collectionId, "translations");
return mapJsonResult(apiUrl, Translations.class).getTranslations();
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbCompanies.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.companies.AlternativeNamesResultsPage;
import info.movito.themoviedbapi.model.companies.Company;
import info.movito.themoviedbapi.model.core.image.ImageResults;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for companies. See the
* documentation for more info.
*/
public class TmdbCompanies extends AbstractTmdbApi {
protected static final String TMDB_METHOD_COMPANY = "company";
/**
* Create a new TmdbCompany instance to call the company related TMDb API methods.
*/
TmdbCompanies(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param companyId The company ID
* @return The company details
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Company getDetails(Integer companyId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COMPANY, companyId);
return mapJsonResult(apiUrl, Company.class);
}
/**
*
*
* @param companyId The company ID
* @return The alternative company names
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AlternativeNamesResultsPage getAlternativeNames(Integer companyId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COMPANY, companyId, "alternative_names");
return mapJsonResult(apiUrl, AlternativeNamesResultsPage.class);
}
/**
*
*
* @param companyId The company ID
* @return The company logos
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ImageResults getImages(Integer companyId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COMPANY, companyId, "images");
return mapJsonResult(apiUrl, ImageResults.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbConfiguration.java
================================================
package info.movito.themoviedbapi;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import info.movito.themoviedbapi.model.configuration.Configuration;
import info.movito.themoviedbapi.model.configuration.Country;
import info.movito.themoviedbapi.model.configuration.Job;
import info.movito.themoviedbapi.model.configuration.Timezone;
import info.movito.themoviedbapi.model.core.Language;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for configuration. See the
* documentation for more info.
*/
public class TmdbConfiguration extends AbstractTmdbApi {
protected static final String TMDB_METHOD_CONFIGURATION = "configuration";
/**
* Create a new TmdbConfig instance to call the config related TMDb API methods.
*/
TmdbConfiguration(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @return The configuration details
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Configuration getDetails() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION);
return mapJsonResult(apiUrl, Configuration.class);
}
/**
*
Get the list of countries (ISO 3166-1 tags) used throughout TMDB.
*
* @param language nullable - The language to query the results in. Default: en-US.
* @return The configuration details
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public List getCountries(String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "countries")
.addLanguage(language);
return mapJsonResult(apiUrl, new TypeReference<>() {
});
}
/**
*
Get the list of jobs and departments we use on TMDb.
*
* @return The list of jobs and departments
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public List getJobs() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "jobs");
return mapJsonResult(apiUrl, new TypeReference<>() {
});
}
/**
*
Get the list of languages (ISO 639-1 tags) used throughout TMDB.
*
* @return The list of languages
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public List getLanguages() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "languages");
return mapJsonResult(apiUrl, new TypeReference<>() {
});
}
/**
*
Get the list of languages (ISO 639-1 tags) used throughout TMDB.
*
* @return The list of languages
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public List getPrimaryTranslations() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "primary_translations");
return mapJsonResult(apiUrl, new TypeReference<>() {
});
}
/**
*
*
* @return The list of timezones
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public List getTimezones() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "timezones");
return mapJsonResult(apiUrl, new TypeReference<>() {
});
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbDiscover.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.core.MovieResultsPage;
import info.movito.themoviedbapi.model.core.TvSeriesResultsPage;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.builders.discover.DiscoverMovieParamBuilder;
import info.movito.themoviedbapi.tools.builders.discover.DiscoverTvParamBuilder;
/**
* The movie database api for discover. See the
* documentation for more info.
*/
public class TmdbDiscover extends AbstractTmdbApi {
protected static final String TMDB_METHOD_DISCOVER = "discover";
protected static final String TMDB_METHOD_MOVIE = "movie";
protected static final String TMDB_METHOD_TV = "tv";
/**
* Create a new TmdbDiscover instance to call the discover related TMDb API methods.
*/
TmdbDiscover(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
Find movies using over 30 filters and sort options.
*
* @param builder A discover object containing the search criteria wanted
* @return the tv series results page.
*/
public TvSeriesResultsPage getTv(DiscoverTvParamBuilder builder) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_DISCOVER, TMDB_METHOD_TV)
.addPathParams(builder);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbFind.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.find.FindResults;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.model.time.ExternalSource;
/**
* The movie database api for find. See the
* documentation for more info.
*/
public class TmdbFind extends AbstractTmdbApi {
protected static final String TMDB_METHOD_FIND = "find";
/**
* Create a new TmdbFind instance to call the find related TMDb API methods.
*/
TmdbFind(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param externalId The external id of the movie, TV show or people.
* @param externalSource The external source of the id.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The find results
*/
public FindResults findById(String externalId, ExternalSource externalSource, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_FIND, externalId)
.addPathParam("external_source", externalSource.getValue())
.addLanguage(language);
return mapJsonResult(apiUrl, FindResults.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbGenre.java
================================================
package info.movito.themoviedbapi;
import java.util.List;
import info.movito.themoviedbapi.model.core.Genre;
import info.movito.themoviedbapi.model.core.Genres;
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);
}
/**
*
*
* @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")
.addLanguage(language);
return mapJsonResult(apiUrl, Genres.class).getGenres();
}
/**
*
*
* @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")
.addLanguage(language);
return mapJsonResult(apiUrl, Genres.class).getGenres();
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbGuestSessions.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.rated.RatedMovieResultsPage;
import info.movito.themoviedbapi.model.rated.RatedTvEpisodeResultsPage;
import info.movito.themoviedbapi.model.rated.RatedTvSeriesResultsPage;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.sortby.AccountSortBy;
/**
* The movie database api for guest sessions. See the
* documentation for more info.
*/
public class TmdbGuestSessions extends AbstractTmdbApi {
protected static final String TMDB_METHOD_GUEST_SESSIONS = "guest_session";
/**
* Create a new TmdbGuestSessions instance to call the guest sessions related TMDb API methods.
*/
public TmdbGuestSessions(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param guestSessionId The guest session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The rated movies of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public RatedMovieResultsPage getRatedMovies(int guestSessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GUEST_SESSIONS, guestSessionId, "rated/movies")
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, RatedMovieResultsPage.class);
}
/**
*
*
* @param guestSessionId The guest session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The rated tv series of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public RatedTvSeriesResultsPage getRatedTvSeries(int guestSessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GUEST_SESSIONS, guestSessionId, "rated/tv")
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, RatedTvSeriesResultsPage.class);
}
/**
*
*
* @param guestSessionId The guest session id of the user.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param sortBy nullable - The sort order of the results.
* @return The rated tv episodes of the user.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public RatedTvEpisodeResultsPage getRatedTvEpisodes(int guestSessionId, String language, Integer page,
AccountSortBy sortBy) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GUEST_SESSIONS, guestSessionId, "rated/tv/episodes")
.addLanguage(language)
.addPage(page)
.addSortBy(sortBy);
return mapJsonResult(apiUrl, RatedTvEpisodeResultsPage.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbKeywords.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.core.MovieDbResultsPage;
import info.movito.themoviedbapi.model.keywords.Keyword;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.builders.discover.DiscoverMovieParamBuilder;
/**
* The movie database api for keywords. See the
* documentation for more info.
*/
public class TmdbKeywords extends AbstractTmdbApi {
protected static final String TMDB_METHOD_KEYWORD = "keyword";
/**
* Create a new TmdbKeywords instance to call the keywords TMDb API methods.
*/
TmdbKeywords(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param keywordId The keyword id.
* @return The keyword details.
*/
public Keyword getDetails(int keywordId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_KEYWORD, keywordId);
return mapJsonResult(apiUrl, Keyword.class);
}
/**
* Get the list of movies for a particular keyword by id.
*
* @return List of movies with the keyword
* @deprecated use {@link TmdbDiscover#getMovie(DiscoverMovieParamBuilder)} instead.
*/
@Deprecated
public MovieDbResultsPage getKeywordMovies(String keywordId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_KEYWORD, keywordId, "movies")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, MovieDbResultsPage.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbLists.java
================================================
package info.movito.themoviedbapi;
import java.util.HashMap;
import info.movito.themoviedbapi.model.core.responses.ResponseStatus;
import info.movito.themoviedbapi.model.lists.ListDetails;
import info.movito.themoviedbapi.model.lists.ListItemStatus;
import info.movito.themoviedbapi.model.lists.MovieListCreationStatus;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.RequestType;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.util.JsonUtil;
/**
* The movie database api for lists. See the
* documentation for more info.
*/
public class TmdbLists extends AbstractTmdbApi {
protected static final String TMDB_METHOD_LIST = "list";
/**
* Create a new TmdbLists instance to call the lists TMDb API methods.
*/
public TmdbLists(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param listId The list id.
* @param sessionId The session id.
* @param movieId The movie id.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus addMovie(Integer listId, String sessionId, Integer movieId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "add_item")
.addPathParam("session_id", sessionId);
HashMap body = new HashMap<>();
body.put("media_id", movieId);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class);
}
/**
*
Use this method to check if an item has already been added to the list.
*
* @param listId The list id.
* @param language nullable - The language to query the results in. Default: en-US.
* @param movieId nullable - The movie id.
* @return The list item status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ListItemStatus checkItemStatus(Integer listId, String language, Integer movieId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "item_status")
.addLanguage(language)
.addQueryParam("movie_id", movieId);
return mapJsonResult(apiUrl, ListItemStatus.class);
}
/**
*
*
* @param listId The list id.
* @param sessionId The session id.
* @param confirm Confirm the clear.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus clear(Integer listId, String sessionId, Boolean confirm) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "clear")
.addPathParam("session_id", sessionId)
.addPathParam("confirm", confirm);
return mapJsonResult(apiUrl, null, RequestType.POST, ResponseStatus.class);
}
/**
*
*
* @param sessionId The session id.
* @param name The name of the list.
* @param description The description of the list.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieListCreationStatus create(String sessionId, String name, String description, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST)
.addPathParam("session_id", sessionId);
HashMap body = new HashMap<>();
body.put("name", name);
body.put("description", description);
body.put("language", language);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, MovieListCreationStatus.class);
}
/**
*
*
* @param listId The list id.
* @param sessionId The session id.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus delete(Integer listId, String sessionId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId)
.addPathParam("session_id", sessionId);
return mapJsonResult(apiUrl, null, RequestType.DELETE, ResponseStatus.class);
}
/**
*
*
* @param listId The list id.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The movie list.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ListDetails getDetails(Integer listId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId)
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, ListDetails.class);
}
/**
*
*
* @param listId The list id.
* @param sessionId The session id.
* @param movieId The movie id.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus removeMovie(Integer listId, String sessionId, Integer movieId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "remove_item")
.addPathParam("session_id", sessionId);
HashMap body = new HashMap<>();
body.put("media_id", movieId);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbMovieLists.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.core.MovieResultsPage;
import info.movito.themoviedbapi.model.movielists.MovieResultsPageWithDates;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for movie lists. See the
* documentation for more info.
*/
public class TmdbMovieLists extends AbstractTmdbApi {
protected static final String TMDB_METHOD_MOVIE_LISTS = "movie";
/**
* Create a new TmdbMovieLists instance to call the movie lists related TMDb API methods.
*/
TmdbMovieLists(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
Get a list of movies that are currently in theatres.
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US".
* @return The now playing movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPageWithDates getNowPlaying(String language, Integer page, String region) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_LISTS, "now_playing")
.addLanguage(language)
.addPage(page)
.addQueryParam("region", region);
return mapJsonResult(apiUrl, MovieResultsPageWithDates.class);
}
/**
*
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US".
* @return The popular movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage getPopular(String language, Integer page, String region) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_LISTS, "popular")
.addLanguage(language)
.addPage(page)
.addQueryParam("region", region);
return mapJsonResult(apiUrl, MovieResultsPage.class);
}
/**
*
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US".
* @return The top-rated movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage getTopRated(String language, Integer page, String region) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_LISTS, "top_rated")
.addLanguage(language)
.addPage(page)
.addQueryParam("region", region);
return mapJsonResult(apiUrl, MovieResultsPage.class);
}
/**
*
Get a list of movies that are being released soon.
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US".
* @return The upcoming movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPageWithDates getUpcoming(String language, Integer page, String region) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_LISTS, "upcoming")
.addLanguage(language)
.addPage(page)
.addQueryParam("region", region);
return mapJsonResult(apiUrl, MovieResultsPageWithDates.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbMovies.java
================================================
package info.movito.themoviedbapi;
import java.util.HashMap;
import info.movito.themoviedbapi.model.core.AccountStates;
import info.movito.themoviedbapi.model.core.MovieResultsPage;
import info.movito.themoviedbapi.model.core.ReviewResultsPage;
import info.movito.themoviedbapi.model.core.responses.ResponseStatus;
import info.movito.themoviedbapi.model.core.video.VideoResults;
import info.movito.themoviedbapi.model.core.watchproviders.ProviderResults;
import info.movito.themoviedbapi.model.movies.AlternativeTitles;
import info.movito.themoviedbapi.model.movies.Credits;
import info.movito.themoviedbapi.model.movies.ExternalIds;
import info.movito.themoviedbapi.model.movies.Images;
import info.movito.themoviedbapi.model.movies.KeywordResults;
import info.movito.themoviedbapi.model.movies.MovieDb;
import info.movito.themoviedbapi.model.movies.MovieListResultsPage;
import info.movito.themoviedbapi.model.movies.ReleaseDateResults;
import info.movito.themoviedbapi.model.movies.Translations;
import info.movito.themoviedbapi.model.movies.changes.ChangeResults;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.RequestType;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.appendtoresponse.MovieAppendToResponse;
import info.movito.themoviedbapi.util.JsonUtil;
/**
* The movie database api for movies. See the
* documentation for more info.
*/
public class TmdbMovies extends AbstractTmdbApi {
protected static final String TMDB_METHOD_MOVIE = "movie";
/**
* Create a new TmdbMovies instance to call the movie related TMDb API methods.
*/
public TmdbMovies(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @param appendToResponse nullable - additional namespaces to append to the result (20 max).
* @return The movie details.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieDb getDetails(int movieId, String language, MovieAppendToResponse... appendToResponse) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId)
.addLanguage(language)
.addAppendToResponses(appendToResponse);
return mapJsonResult(apiUrl, MovieDb.class);
}
/**
*
Get the rating, watchlist and favourite status of an account.
*
* @param movieId The TMDb id of the movie.
* @param sessionId nullable - The session id of the user.
* @param guestSessionId nullable - The guest session id of the user.
* @return The account states of the movie.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AccountStates getAccountStates(int movieId, String sessionId, String guestSessionId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "account_states")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
return mapJsonResult(apiUrl, AccountStates.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @param country nullable - The country to query the results in (ISO-3166-1), e.g. "US".
* @return The alternative titles of the movie.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AlternativeTitles getAlternativeTitles(int movieId, String country) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "alternative_titles")
.addQueryParam("country", country);
return mapJsonResult(apiUrl, AlternativeTitles.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @param startDate nullable - The start date, in format: YYYY-MM-DD.
* @param endDate nullable - The end date, in format: YYYY-MM-DD.
* @param page nullable - The page of results to return. Default: 1.
* @return The movie changes.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ChangeResults getChanges(int movieId, String startDate, String endDate, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "changes")
.addQueryParam("start_date", startDate)
.addQueryParam("end_date", endDate)
.addPage(page);
return mapJsonResult(apiUrl, ChangeResults.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The movie credits.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Credits getCredits(int movieId, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "credits")
.addLanguage(language);
return mapJsonResult(apiUrl, Credits.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @return The external IDs.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ExternalIds getExternalIds(int movieId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "external_ids");
return mapJsonResult(apiUrl, ExternalIds.class);
}
/**
*
*
* @param movieId The movie id.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it
* @return The images.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Images getImages(int movieId, String language, String... includeImageLanguage) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "images")
.addLanguage(language)
.addQueryParamCommandSeparated("include_image_language", includeImageLanguage);
return mapJsonResult(apiUrl, Images.class);
}
/**
*
*
* @param movieId The movie id.
* @return The keywords.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public KeywordResults getKeywords(int movieId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "keywords");
return mapJsonResult(apiUrl, KeywordResults.class);
}
/**
*
*
* @return The latest movie.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieDb getLatest() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, "latest");
return mapJsonResult(apiUrl, MovieDb.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The movie lists.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieListResultsPage getLists(int movieId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "lists")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, MovieListResultsPage.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The recommended movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage getRecommendations(int movieId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "recommendations")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, MovieResultsPage.class);
}
/**
*
Get the release dates and certifications for a movie.
*
* @param movieId The TMDb id of the movie.
* @return The release dates and certifications.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ReleaseDateResults getReleaseDates(int movieId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "release_dates");
return mapJsonResult(apiUrl, ReleaseDateResults.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The movie reviews.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ReviewResultsPage getReviews(int movieId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "reviews")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, ReviewResultsPage.class);
}
/**
*
Get the similar movies based on genres and keywords.
*
* @param movieId The TMDb id of the movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The similar movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage getSimilar(int movieId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "similar")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, MovieResultsPage.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @return The translations.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Translations getTranslations(int movieId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "translations");
return mapJsonResult(apiUrl, Translations.class);
}
/**
*
*
* @param movieId The TMDb id of the movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The videos.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public VideoResults getVideos(int movieId, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "videos")
.addLanguage(language);
return mapJsonResult(apiUrl, VideoResults.class);
}
/**
*
Get the list of streaming providers we have for a movie.
*
In order to use this data you must attribute the source of the data as JustWatch. If TMDb find any usage not complying with these
* terms TMDb will revoke access to the API.
*
* @param movieId The TMDb id of the movie.
* @return The watch providers.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ProviderResults getWatchProviders(int movieId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "watch/providers");
return mapJsonResult(apiUrl, ProviderResults.class);
}
/**
*
Rate a movie and save it to your rated list.
*
Note: if no guestSessionId or sessionId are provided, the method will add the rating to the API key
* holder's account.
*
* @param movieId The TMDb id of the movie.
* @param guestSessionId nullable - The guest session id of the user.
* @param sessionId nullable - The session id of the user.
* @param rating The rating of the movie. Must be: 0 < rating ≤ 10.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus addRating(int movieId, String guestSessionId, String sessionId, double rating) throws TmdbException {
if (rating < 0 || rating > 10) {
throw new IllegalArgumentException("Rating must be: 0 < rating <= 10");
}
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "rating")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
HashMap body = new HashMap<>();
body.put("value", rating);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class);
}
/**
*
Delete a user rating.
*
Note: if no guestSessionId or sessionId are provided, the method will delete the rating for the API key
* holder's account.
*
* @param movieId The TMDb id of the movie.
* @param guestSessionId nullable - The guest session id of the user.
* @param sessionId nullable - The session id of the user.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus deleteRating(int movieId, String guestSessionId, String sessionId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "rating")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
return mapJsonResult(apiUrl, null, RequestType.DELETE, ResponseStatus.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbNetworks.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.core.image.ImageResults;
import info.movito.themoviedbapi.model.networks.AlternativeNamesResults;
import info.movito.themoviedbapi.model.networks.Network;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for networks. See the
* documentation for more info.
*/
public class TmdbNetworks extends AbstractTmdbApi {
protected static final String TMDB_METHOD_NETWORK = "network";
/**
* Create a new TmdbNetworks instance to call the network related TMDb API methods.
*/
public TmdbNetworks(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param networkId The network id.
* @return The network details.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Network getDetails(int networkId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_NETWORK, networkId);
return mapJsonResult(apiUrl, Network.class);
}
/**
*
*
* @param networkId The network id.
* @return The alternative names of the network.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AlternativeNamesResults getAlternativeNames(int networkId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_NETWORK, networkId, "alternative_names");
return mapJsonResult(apiUrl, AlternativeNamesResults.class);
}
/**
*
*
* @param networkId The network id.
* @return The images of the network.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ImageResults getImages(int networkId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_NETWORK, networkId, "images");
return mapJsonResult(apiUrl, ImageResults.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbPeople.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.movies.changes.ChangeResults;
import info.movito.themoviedbapi.model.people.ExternalIds;
import info.movito.themoviedbapi.model.people.PersonDb;
import info.movito.themoviedbapi.model.people.PersonImages;
import info.movito.themoviedbapi.model.people.Translations;
import info.movito.themoviedbapi.model.people.credits.CombinedPersonCredits;
import info.movito.themoviedbapi.model.people.credits.MovieCredits;
import info.movito.themoviedbapi.model.people.credits.TvCredits;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.appendtoresponse.PersonAppendToResponse;
/**
* The movie database api for people. See the
* documentation for more info.
*/
public class TmdbPeople extends AbstractTmdbApi {
protected static final String TMDB_METHOD_PERSON = "person";
/**
* Create a new TmdbPeople instance to call the people related TMDb API methods.
*/
TmdbPeople(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param personId The TMDb id of the person.
* @param language nullable - The language to query the results in. Default: en-US.
* @param appendToResponse nullable - additional namespaces to append to the result (20 max).
* @return The person details.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public PersonDb getDetails(int personId, String language, PersonAppendToResponse... appendToResponse) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId)
.addLanguage(language)
.addAppendToResponses(appendToResponse);
return mapJsonResult(apiUrl, PersonDb.class);
}
/**
*
*
* @param personId The TMDb id of the person.
* @param startDate nullable - The start date, in format: YYYY-MM-DD.
* @param endDate nullable - The end date, in format: YYYY-MM-DD.
* @param page nullable - The page of results to return. Default: 1.
* @return The person changes.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ChangeResults getChanges(int personId, String startDate, String endDate, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "changes")
.addQueryParam("start_date", startDate)
.addQueryParam("end_date", endDate)
.addPage(page);
return mapJsonResult(apiUrl, ChangeResults.class);
}
/**
*
Get the combined movie and TV credits that belong to a person.
*
* @param personId The TMDb id of the person.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The combined person credits.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public CombinedPersonCredits getCombinedCredits(int personId, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "combined_credits")
.addLanguage(language);
return mapJsonResult(apiUrl, CombinedPersonCredits.class);
}
/**
*
*
* @param personId The TMDb id of the person.
* @return The external IDs.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ExternalIds getExternalIds(int personId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "external_ids");
return mapJsonResult(apiUrl, ExternalIds.class);
}
/**
*
*
* @param personId The TMDb id of the person.
* @return The profile images.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public PersonImages getImages(int personId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "images");
return mapJsonResult(apiUrl, PersonImages.class);
}
/**
*
Get the newest created person. This is a live response and will continuously change.
*
* @return The latest person.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public PersonDb getLatest() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, "latest");
return mapJsonResult(apiUrl, PersonDb.class);
}
/**
*
*
* @param personId The TMDb id of the person.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The movie credits.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieCredits getMovieCredits(int personId, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "movie_credits")
.addLanguage(language);
return mapJsonResult(apiUrl, MovieCredits.class);
}
/**
*
*
* @param personId The TMDb id of the person.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The TV credits.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvCredits getTvCredits(int personId, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "tv_credits")
.addLanguage(language);
return mapJsonResult(apiUrl, TvCredits.class);
}
/**
*
*
* @param personId The TMDb id of the person.
* @return The translations.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Translations getTranslations(int personId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "translations");
return mapJsonResult(apiUrl, Translations.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbPeopleLists.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.core.popularperson.PopularPersonResultsPage;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for people lists. See the
* documentation for more info.
*/
public class TmdbPeopleLists extends AbstractTmdbApi {
protected static final String TMDB_METHOD_PEOPLE_LISTS = "person/popular";
TmdbPeopleLists(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The popular people.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public PopularPersonResultsPage getPopular(String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PEOPLE_LISTS)
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, PopularPersonResultsPage.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbReviews.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.reviews.Review;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for reviews. See the
* documentation for more info.
*/
public class TmdbReviews extends AbstractTmdbApi {
protected static final String TMDB_METHOD_MOVIE_REVIEW = "reviews";
/**
* Create a new TmdbReviews instance to call the reviews related TMDb API methods.
*/
TmdbReviews(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param query The query to search for.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeAdult nullable - Whether to include adult results in the search.
* @param page nullable - The page of results to return. Default: 1.
* @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US".
* @return The collection results.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public CollectionResultsPage searchCollection(String query, String language, Boolean includeAdult, Integer page, String region)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_COLLECTION)
.addPathParam(PARAM_QUERY, query)
.addQueryParam("include_adult", includeAdult)
.addQueryParam("region", region)
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, CollectionResultsPage.class);
}
/**
*
Search for companies by their original and alternative names.
*
* @param query The query to search for.
* @param page nullable - The page of results to return. Default: 1.
* @return The company results.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public CompanyResultsPage searchCompany(String query, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, "company")
.addPathParam(PARAM_QUERY, query)
.addPage(page);
return mapJsonResult(apiUrl, CompanyResultsPage.class);
}
/**
*
*
* @param query The query to search for.
* @param page nullable - The page of results to return. Default: 1.
* @return The keyword results.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public KeywordResultsPage searchKeyword(String query, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, "keyword")
.addPathParam(PARAM_QUERY, query)
.addPage(page);
return mapJsonResult(apiUrl, KeywordResultsPage.class);
}
/**
*
Search for movies by their original, translated and alternative titles.
*
* @param query The query to search for.
* @param includeAdult nullable - Whether to include adult results in the search.
* @param language nullable - The language to query the results in. Default: en-US.
* @param primaryReleaseYear nullable - Filter the results so that only the primary release year matches this value.
* @param page nullable - The page of results to return. Default: 1.
* @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US".
* @param year nullable - Filter the results so that only the release year matches this value.
* @return The movie results.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage searchMovie(String query, Boolean includeAdult, String language, String primaryReleaseYear, Integer page,
String region, String year) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_MOVIE)
.addPathParam(PARAM_QUERY, query)
.addQueryParam("include_adult", includeAdult)
.addQueryParam("primary_release_year", primaryReleaseYear)
.addQueryParam("region", region)
.addQueryParam("year", year)
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, MovieResultsPage.class);
}
/**
*
Use multi search when you want to search for movies, TV shows and people in a single request.
*
* @param query The query to search for.
* @param includeAdult nullable - Whether to include adult results in the search.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The multi results.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MultiResultsPage searchMulti(String query, Boolean includeAdult, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_MULTI)
.addPathParam(PARAM_QUERY, query)
.addQueryParam("include_adult", includeAdult)
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, MultiResultsPage.class);
}
/**
*
Search for people by their name and also known as names.
*
* @param query The query to search for.
* @param includeAdult nullable - Whether to include adult results in the search.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The person results.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public PopularPersonResultsPage searchPerson(String query, Boolean includeAdult, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_PERSON)
.addPathParam(PARAM_QUERY, query)
.addQueryParam("include_adult", includeAdult)
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, PopularPersonResultsPage.class);
}
/**
*
Search for TV shows by their original, translated and also known as names.
*
* @param query The query to search for.
* @param firstAirDateYear nullable - Filter the results so that only the first air date year matches this value.
* @param includeAdult nullable - Whether to include adult results in the search.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param year nullable - Filter the results so that only the release year matches this value.
* @return The TV series results.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage searchTv(String query, Integer firstAirDateYear, Boolean includeAdult, String language, Integer page,
Integer year) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_TV)
.addPathParam(PARAM_QUERY, query)
.addQueryParam("first_air_date_year", firstAirDateYear)
.addQueryParam("include_adult", includeAdult)
.addQueryParam("year", year)
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbTrending.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.core.MovieResultsPage;
import info.movito.themoviedbapi.model.core.TvSeriesResultsPage;
import info.movito.themoviedbapi.model.core.multi.MultiResultsPage;
import info.movito.themoviedbapi.model.core.popularperson.PopularPersonResultsPage;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.model.time.TimeWindow;
/**
* The movie database api for trending media. See the
* documentation for more info.
*/
public class TmdbTrending extends AbstractTmdbApi {
protected static final String TMDB_METHOD_TRENDING = "trending";
/**
* Create a new TmdbTrending instance to call the rending TMDb API methods.
*/
TmdbTrending(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param timeWindow The time window for the trending media.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The trending media.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MultiResultsPage getAll(TimeWindow timeWindow, String language) throws TmdbException {
return getAll(timeWindow, language, 1);
}
/**
*
*
* @param timeWindow The time window for the trending media.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The trending media.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MultiResultsPage getAll(TimeWindow timeWindow, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "all", timeWindow.getValue())
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, MultiResultsPage.class);
}
/**
*
*
* @param timeWindow The time window for the trending movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The trending movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage getMovies(TimeWindow timeWindow, String language) throws TmdbException {
return getMovies(timeWindow, language, 1);
}
/**
*
*
* @param timeWindow The time window for the trending movie.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The trending movies.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public MovieResultsPage getMovies(TimeWindow timeWindow, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "movie", timeWindow.getValue())
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, MovieResultsPage.class);
}
/**
*
*
* @param timeWindow The time window for the trending people.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The trending people.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public PopularPersonResultsPage getPeople(TimeWindow timeWindow, String language) throws TmdbException {
return getPeople(timeWindow, language, 1);
}
/**
*
*
* @param timeWindow The time window for the trending people.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The trending people.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public PopularPersonResultsPage getPeople(TimeWindow timeWindow, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "person", timeWindow.getValue())
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, PopularPersonResultsPage.class);
}
/**
*
*
* @param timeWindow The time window for the trending tv.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The trending tv.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getTv(TimeWindow timeWindow, String language) throws TmdbException {
return getTv(timeWindow, language, 1);
}
/**
*
*
* @param timeWindow The time window for the trending tv.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The trending tv.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getTv(TimeWindow timeWindow, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "tv", timeWindow.getValue())
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbTvEpisodeGroups.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.tv.episodegroups.TvEpisodeGroups;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for tv episode groups. See the
* documentation for more info.
*/
public class TmdbTvEpisodeGroups extends AbstractTmdbApi {
protected static final String TMDB_METHOD_TV_EPISODE_GROUPS = "tv/episode_group";
/**
* Create a new TmdbTvEpisodeGroups instance to call the tv episode groups TMDb API methods.
*/
TmdbTvEpisodeGroups(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param tvEpisodeGroupId The id of the tv episode group.
* @return The tv episode group details.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvEpisodeGroups getDetails(String tvEpisodeGroupId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV_EPISODE_GROUPS, tvEpisodeGroupId);
return mapJsonResult(apiUrl, TvEpisodeGroups.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbTvEpisodes.java
================================================
package info.movito.themoviedbapi;
import java.util.HashMap;
import info.movito.themoviedbapi.model.core.AccountStates;
import info.movito.themoviedbapi.model.core.responses.ResponseStatus;
import info.movito.themoviedbapi.model.core.video.VideoResults;
import info.movito.themoviedbapi.model.tv.core.ChangeResults;
import info.movito.themoviedbapi.model.tv.core.Translations;
import info.movito.themoviedbapi.model.tv.episode.EpisodeCredits;
import info.movito.themoviedbapi.model.tv.episode.ExternalIds;
import info.movito.themoviedbapi.model.tv.episode.Images;
import info.movito.themoviedbapi.model.tv.episode.TvEpisodeDb;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.RequestType;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.appendtoresponse.TvEpisodesAppendToResponse;
import info.movito.themoviedbapi.util.JsonUtil;
import static info.movito.themoviedbapi.TmdbTvSeasons.TMDB_METHOD_TV_SEASON;
import static info.movito.themoviedbapi.TmdbTvSeries.TMDB_METHOD_TV;
/**
* The movie database api for tv episodes. See the
* documentation for more info.
*/
public class TmdbTvEpisodes extends AbstractTmdbApi {
public static final String TMDB_METHOD_TV_EPISODE = "episode";
/**
* Create a new TmdbTvEpisodes instance to call the tv episodes TMDb API methods.
*/
TmdbTvEpisodes(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param appendToResponse nullable - additional namespaces to append to the result (20 max).
* @return The tv episode details.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvEpisodeDb getDetails(int seriesId, int seasonNumber, int episodeNumber, String language,
TvEpisodesAppendToResponse... appendToResponse) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber)
.addLanguage(language)
.addAppendToResponses(appendToResponse);
return mapJsonResult(apiUrl, TvEpisodeDb.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @param sessionId nullable - The session id of the user.
* @param guestSessionId nullable - The guest session id of the user.
* @return The account states.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AccountStates getAccountStates(int seriesId, int seasonNumber, int episodeNumber, String sessionId, String guestSessionId)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(
TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "account_states")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
return mapJsonResult(apiUrl, AccountStates.class);
}
/**
*
*
* @param episodeId The TMDb id of the tv episode.
* @return The change results.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ChangeResults getChanges(int episodeId)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, TMDB_METHOD_TV_EPISODE, episodeId, "changes");
return mapJsonResult(apiUrl, ChangeResults.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The credits.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public EpisodeCredits getCredits(int seriesId, int seasonNumber, int episodeNumber, String language)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(
TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "credits")
.addLanguage(language);
return mapJsonResult(apiUrl, EpisodeCredits.class);
}
/**
*
Get a list of external IDs that have been added to a TV episode.
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @return The external IDs.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ExternalIds getExternalIds(int seriesId, int seasonNumber, int episodeNumber)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(
TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "external_ids");
return mapJsonResult(apiUrl, ExternalIds.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it
* @return The images.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Images getImages(int seriesId, int seasonNumber, int episodeNumber, String language, String... includeImageLanguage)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(
TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "images")
.addLanguage(language)
.addQueryParamCommandSeparated("include_image_language", includeImageLanguage);
return mapJsonResult(apiUrl, Images.class);
}
/**
*
Get the translations that have been added to a TV episode.
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @return The translations.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Translations getTranslations(int seriesId, int seasonNumber, int episodeNumber)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(
TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "translations");
return mapJsonResult(apiUrl, Translations.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeVideoLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it
* @return The videos.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public VideoResults getVideos(int seriesId, int seasonNumber, int episodeNumber, String language, String... includeVideoLanguage)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(
TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "videos")
.addLanguage(language)
.addQueryParamCommandSeparated("include_video_language", includeVideoLanguage);
return mapJsonResult(apiUrl, VideoResults.class);
}
/**
*
Rate a TV episode and save it to your rated list.
*
Note: if no guestSessionId or sessionId are provided, the method will add the rating to the API key
* holder's account.
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @param guestSessionId nullable - The guest session id of the user.
* @param sessionId nullable - The session id of the user.
* @param rating The rating of the tv episode. Must be: 0 < rating ≤ 10.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus addRating(int seriesId, int seasonNumber, int episodeNumber, String guestSessionId, String sessionId,
double rating) throws TmdbException {
if (rating < 0 || rating > 10) {
throw new IllegalArgumentException("Rating must be: 0 < rating <= 10");
}
ApiUrl apiUrl = new ApiUrl(
TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "rating")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
HashMap body = new HashMap<>();
body.put("value", rating);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class);
}
/**
*
Delete your rating on a TV episode.
*
Note: if no guestSessionId or sessionId are provided, the method will delete the rating for the API key
* holder's account.
*
* @param seriesId The TMDb id of the tv series.
* @param seasonNumber The season number of the tv series.
* @param episodeNumber The episode number of the tv series.
* @param guestSessionId nullable - The guest session id of the user.
* @param sessionId nullable - The session id of the user.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus deleteRating(int seriesId, int seasonNumber, int episodeNumber, String guestSessionId, String sessionId)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(
TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "rating")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
return mapJsonResult(apiUrl, null, RequestType.DELETE, ResponseStatus.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbTvSeasons.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.core.video.VideoResults;
import info.movito.themoviedbapi.model.core.watchproviders.ProviderResults;
import info.movito.themoviedbapi.model.tv.core.Translations;
import info.movito.themoviedbapi.model.tv.core.credits.AggregateCredits;
import info.movito.themoviedbapi.model.tv.core.credits.Credits;
import info.movito.themoviedbapi.model.tv.season.AccountStateResults;
import info.movito.themoviedbapi.model.tv.season.ChangeResults;
import info.movito.themoviedbapi.model.tv.season.ExternalIds;
import info.movito.themoviedbapi.model.tv.season.Images;
import info.movito.themoviedbapi.model.tv.season.TvSeasonDb;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.appendtoresponse.TvSeasonsAppendToResponse;
import static info.movito.themoviedbapi.TmdbTvSeries.TMDB_METHOD_TV;
/**
* The movie database api for tv seasons. See the
* documentation for more info.
*/
public class TmdbTvSeasons extends AbstractTmdbApi {
public static final String TMDB_METHOD_TV_SEASON = "season";
/**
* Create a new TmdbTvSeasons instance to call the tv seasons TMDb API methods.
*/
TmdbTvSeasons(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @param language nullable - The language to query the results in. Default: en-US.
* @param appendToResponse nullable - additional namespaces to append to the result (20 max).
* @return The TV season details.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeasonDb getDetails(int seriesId, int seasonNumber, String language, TvSeasonsAppendToResponse... appendToResponse)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber)
.addLanguage(language)
.addAppendToResponses(appendToResponse);
return mapJsonResult(apiUrl, TvSeasonDb.class);
}
/**
*
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @param sessionId nullable - The session id of the user.
* @param guestSessionId nullable - The guest session id of the user.
* @return The account states.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AccountStateResults getAccountStates(int seriesId, int seasonNumber, String sessionId, String guestSessionId)
throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "account_states")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
return mapJsonResult(apiUrl, AccountStateResults.class);
}
/**
*
Get the aggregate credits (cast and crew) that have been added to a TV season.
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The aggregate credits.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AggregateCredits getAggregateCredits(int seriesId, int seasonNumber, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "aggregate_credits")
.addLanguage(language);
return mapJsonResult(apiUrl, AggregateCredits.class);
}
/**
*
*
* @param seasonId The TMDb id of the TV season.
* @param startDate nullable - The start date, in format: YYYY-MM-DD.
* @param endDate nullable - The end date, in format: YYYY-MM-DD.
* @param page nullable - The page of results to return. Default: 1.
* @return The changes.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ChangeResults getChanges(int seasonId, String startDate, String endDate, int page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, TMDB_METHOD_TV_SEASON, seasonId, "changes")
.addQueryParam("start_date", startDate)
.addQueryParam("end_date", endDate)
.addPage(page);
return mapJsonResult(apiUrl, ChangeResults.class);
}
/**
*
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The credits.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Credits getCredits(int seriesId, int seasonNumber, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "credits")
.addLanguage(language);
return mapJsonResult(apiUrl, Credits.class);
}
/**
*
Get a list of external IDs that have been added to a TV season.
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @return The external IDs.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ExternalIds getExternalIds(int seriesId, int seasonNumber) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "external_ids");
return mapJsonResult(apiUrl, ExternalIds.class);
}
/**
*
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it
* @return The images.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Images getImages(int seriesId, int seasonNumber, String language, String... includeImageLanguage) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "images")
.addLanguage(language)
.addQueryParamCommandSeparated("include_image_language", includeImageLanguage);
return mapJsonResult(apiUrl, Images.class);
}
/**
*
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @return The translations.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Translations getTranslations(int seriesId, int seasonNumber) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "translations");
return mapJsonResult(apiUrl, Translations.class);
}
/**
*
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeVideoLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it
* @return The videos.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public VideoResults getVideos(int seriesId, int seasonNumber, String language, String... includeVideoLanguage) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "videos")
.addLanguage(language)
.addQueryParamCommandSeparated("include_video_language", includeVideoLanguage);
return mapJsonResult(apiUrl, VideoResults.class);
}
/**
*
Get the list of streaming providers we have for a TV season.
*
In order to use this data you must attribute the source of the data as JustWatch. If TMDb find any usage not complying with these
* terms TMDb will revoke access to the API.
*
* @param seriesId The TMDb id of the TV series.
* @param seasonNumber The season number.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The watch providers.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ProviderResults getWatchProviders(int seriesId, int seasonNumber, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "watch/providers")
.addLanguage(language);
return mapJsonResult(apiUrl, ProviderResults.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbTvSeries.java
================================================
package info.movito.themoviedbapi;
import java.util.HashMap;
import info.movito.themoviedbapi.model.core.AccountStates;
import info.movito.themoviedbapi.model.core.ReviewResultsPage;
import info.movito.themoviedbapi.model.core.TvKeywords;
import info.movito.themoviedbapi.model.core.TvSeriesResultsPage;
import info.movito.themoviedbapi.model.core.responses.ResponseStatus;
import info.movito.themoviedbapi.model.core.video.VideoResults;
import info.movito.themoviedbapi.model.core.watchproviders.ProviderResults;
import info.movito.themoviedbapi.model.tv.core.ChangeResults;
import info.movito.themoviedbapi.model.tv.core.credits.AggregateCredits;
import info.movito.themoviedbapi.model.tv.core.credits.Credits;
import info.movito.themoviedbapi.model.tv.series.AlternativeTitleResults;
import info.movito.themoviedbapi.model.tv.series.ContentRatingResults;
import info.movito.themoviedbapi.model.tv.series.EpisodeGroupResults;
import info.movito.themoviedbapi.model.tv.series.ExternalIds;
import info.movito.themoviedbapi.model.tv.series.Images;
import info.movito.themoviedbapi.model.tv.series.ScreenedTheatricallyResults;
import info.movito.themoviedbapi.model.tv.series.Translations;
import info.movito.themoviedbapi.model.tv.series.TvSeriesDb;
import info.movito.themoviedbapi.model.tv.series.TvSeriesListResultsPage;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.RequestType;
import info.movito.themoviedbapi.tools.TmdbException;
import info.movito.themoviedbapi.tools.appendtoresponse.TvSeriesAppendToResponse;
import info.movito.themoviedbapi.util.JsonUtil;
/**
* The movie database api for tv series. See the
* documentation for more info.
*/
public class TmdbTvSeries extends AbstractTmdbApi {
public static final String TMDB_METHOD_TV = "tv";
/**
* Create a new TmdbTvSeries instance to call the tv series TMDb API methods.
*/
TmdbTvSeries(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param appendToResponse nullable - additional namespaces to append to the result (20 max).
* @return The tv series details.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesDb getDetails(int seriesId, String language, TvSeriesAppendToResponse... appendToResponse) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId)
.addLanguage(language)
.addAppendToResponses(appendToResponse);
return mapJsonResult(apiUrl, TvSeriesDb.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param sessionId nullable - The session id of the user.
* @param guestSessionId nullable - The guest session id of the user.
* @return The account states of the tv series.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AccountStates getAccountStates(int seriesId, String sessionId, String guestSessionId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "account_states")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
return mapJsonResult(apiUrl, AccountStates.class);
}
/**
*
Get the aggregate credits (cast and crew) that have been added to a TV show.
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AggregateCredits getAggregateCredits(int seriesId, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "aggregate_credits")
.addLanguage(language);
return mapJsonResult(apiUrl, AggregateCredits.class);
}
/**
*
Get the alternative titles that have been added to a TV show.
*
* @param seriesId The TMDb id of the tv series.
* @return The alternative titles of the tv series.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public AlternativeTitleResults getAlternativeTitles(int seriesId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "alternative_titles");
return mapJsonResult(apiUrl, AlternativeTitleResults.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param startDate nullable - The start date, in format: YYYY-MM-DD.
* @param endDate nullable - The end date, in format: YYYY-MM-DD.
* @param page nullable - The page of results to return. Default: 1.
* @return The tv series changes.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ChangeResults getChanges(int seriesId, String startDate, String endDate, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "changes")
.addQueryParam("start_date", startDate)
.addQueryParam("end_date", endDate)
.addPage(page);
return mapJsonResult(apiUrl, ChangeResults.class);
}
/**
*
Get the content ratings that have been added to a TV show.
*
* @param seriesId The TMDb id of the tv series.
* @return The tv series content ratings.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ContentRatingResults getContentRatings(int seriesId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "content_ratings");
return mapJsonResult(apiUrl, ContentRatingResults.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @return The tv series credits.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Credits getCredits(int seriesId, String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "credits")
.addLanguage(language);
return mapJsonResult(apiUrl, Credits.class);
}
/**
*
Get the episode groups that have been added to a TV show.
*
* @param seriesId The TMDb id of the tv series.
* @return The tv series episode groups.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public EpisodeGroupResults getEpisodeGroups(int seriesId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "episode_groups");
return mapJsonResult(apiUrl, EpisodeGroupResults.class);
}
/**
*
Get a list of external IDs that have been added to a TV show.
*
* @param seriesId The TMDb id of the tv series.
* @return The external IDs.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ExternalIds getExternalIds(int seriesId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "external_ids");
return mapJsonResult(apiUrl, ExternalIds.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it
* @return The tv series images.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Images getImages(int seriesId, String language, String... includeImageLanguage) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "images")
.addLanguage(language)
.addQueryParamCommandSeparated("include_image_language", includeImageLanguage);
return mapJsonResult(apiUrl, Images.class);
}
/**
*
Get a list of keywords that have been added to a TV show.
*
* @param seriesId The TMDb id of the tv series.
* @return The tv series keywords.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvKeywords getKeywords(int seriesId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "keywords");
return mapJsonResult(apiUrl, TvKeywords.class);
}
/**
*
*
* @return The latest tv series.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesDb getLatest() throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "latest");
return mapJsonResult(apiUrl, TvSeriesDb.class);
}
/**
*
Get the lists that a TV series has been added to..
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The tv series lists.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesListResultsPage getLists(int seriesId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "lists")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, TvSeriesListResultsPage.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The tv series lists.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getRecommendations(int seriesId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "recommendations")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
/**
*
Get the reviews that have been added to a TV show.
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The tv series reviews.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ReviewResultsPage getReviews(int seriesId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "reviews")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, ReviewResultsPage.class);
}
/**
*
Get the seasons and episodes that have screened theatrically.
*
* @param seriesId The TMDb id of the tv series.
* @return The tv series seasons and episodes that have screened theatrically.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ScreenedTheatricallyResults getScreenedTheatrically(int seriesId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "screened_theatrically");
return mapJsonResult(apiUrl, ScreenedTheatricallyResults.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return The similar tv series.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getSimilar(int seriesId, String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "similar")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
/**
*
Get the translations that have been added to a TV show.
*
* @param seriesId The TMDb id of the tv series.
* @return The translations.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public Translations getTranslations(int seriesId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "translations");
return mapJsonResult(apiUrl, Translations.class);
}
/**
*
*
* @param seriesId The TMDb id of the tv series.
* @param language nullable - The language to query the results in. Default: en-US.
* @param includeVideoLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it
* @return The videos.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public VideoResults getVideos(int seriesId, String language, String... includeVideoLanguage) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "videos")
.addLanguage(language)
.addQueryParamCommandSeparated("include_image_language", includeVideoLanguage);
return mapJsonResult(apiUrl, VideoResults.class);
}
/**
*
Get the list of streaming providers we have for a TV show.
*
In order to use this data you must attribute the source of the data as JustWatch. If TMDb find any usage not complying with these
* terms TMDb will revoke access to the API.
*
* @param seriesId The TMDb id of the tv series.
* @return The watch providers.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ProviderResults getWatchProviders(int seriesId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "watch/providers");
return mapJsonResult(apiUrl, ProviderResults.class);
}
/**
*
Rate a TV show and save it to your rated list.
*
Note: if no guestSessionId or sessionId are provided, the method will add the rating to the API key
* holder's account.
*
* @param seriesId The TMDb id of the tv series.
* @param guestSessionId nullable - The guest session id of the user.
* @param sessionId nullable - The session id of the user.
* @param rating The rating of the tv series. Must be: 0 < rating ≤ 10.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus addRating(int seriesId, String guestSessionId, String sessionId, double rating) throws TmdbException {
if (rating < 0 || rating > 10) {
throw new IllegalArgumentException("Rating must be: 0 < rating <= 10");
}
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "rating")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
HashMap body = new HashMap<>();
body.put("value", rating);
String jsonBody = JsonUtil.toJson(body);
return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class);
}
/**
*
Delete a user rating.
*
Note: if no guestSessionId or sessionId are provided, the method will delete the rating for the API key
* holder's account.
*
* @param seriesId The TMDb id of the tv series.
* @param guestSessionId nullable - The guest session id of the user.
* @param sessionId nullable - The session id of the user.
* @return The response status.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public ResponseStatus deleteRating(int seriesId, String guestSessionId, String sessionId) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "rating")
.addQueryParam("session_id", sessionId)
.addQueryParam("guest_session_id", guestSessionId);
return mapJsonResult(apiUrl, null, RequestType.DELETE, ResponseStatus.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbTvSeriesLists.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.core.TvSeriesResultsPage;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
import static info.movito.themoviedbapi.TmdbTvSeries.TMDB_METHOD_TV;
/**
* The movie database api for tv series lists. See the
* documentation for more info.
*/
public class TmdbTvSeriesLists extends AbstractTmdbApi {
/**
* Create a new TmdbTvSeriesLists instance to call the tv series lists TMDb API methods.
*/
TmdbTvSeriesLists(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param timezone nullable - The timezone to use when querying the air dates.
* @return a list of TV shows airing today.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getAiringToday(String language, Integer page, String timezone) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "airing_today")
.addLanguage(language)
.addPage(page)
.addQueryParam("timezone", timezone);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
/**
*
Get a list of TV shows that air in the next 7 days.
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @param timezone nullable - The timezone to use when querying the air dates.
* @return a list of TV shows that air in the next 7 days.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getOnTheAir(String language, Integer page, String timezone) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "on_the_air")
.addLanguage(language)
.addPage(page)
.addQueryParam("timezone", timezone);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
/**
*
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return a list of TV shows ordered by popularity.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getPopular(String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "popular")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
/**
*
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param page nullable - The page of results to return. Default: 1.
* @return a list of TV shows ordered by rating.
* @throws TmdbException If there was an error making the request or mapping the response.
*/
public TvSeriesResultsPage getTopRated(String language, Integer page) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "top_rated")
.addLanguage(language)
.addPage(page);
return mapJsonResult(apiUrl, TvSeriesResultsPage.class);
}
}
================================================
FILE: src/main/java/info/movito/themoviedbapi/TmdbWatchProviders.java
================================================
package info.movito.themoviedbapi;
import info.movito.themoviedbapi.model.watchproviders.AvailableRegionResults;
import info.movito.themoviedbapi.model.watchproviders.ProviderResults;
import info.movito.themoviedbapi.tools.ApiUrl;
import info.movito.themoviedbapi.tools.TmdbException;
/**
* The movie database api for watch providers. See the
* documentation for more info.
*/
public class TmdbWatchProviders extends AbstractTmdbApi {
protected static final String TMDB_METHOD_WATCH_PROVIDERS = "watch/providers";
/**
* Create a new TmdbWatchProviders instance to call the watch providers TMDb API methods.
*/
TmdbWatchProviders(TmdbApi tmdbApi) {
super(tmdbApi);
}
/**
*
Get the list of the countries we have watch provider (OTT/streaming) data for.
*
* @param language nullable - The language to query the results in. Default: en-US.
*/
public AvailableRegionResults getAvailableRegions(String language) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_WATCH_PROVIDERS)
.addLanguage(language);
return mapJsonResult(apiUrl, AvailableRegionResults.class);
}
/**
*
Get the list of streaming providers we have for movies.
*
* @param language nullable - The language to query the results in. Default: en-US.
* @param watchRegion nullable - The watch region, e.g. "AD"
*/
public ProviderResults getMovieProviders(String language, String watchRegion) throws TmdbException {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_WATCH_PROVIDERS, "movie")
.addLanguage(language)
.addQueryParam("watch_region", watchRegion);
return mapJsonResult(apiUrl, ProviderResults.class);
}
/**
*
Get the list of streaming providers we have for TV shows.
*
In order to use this data you must attribute the source of the data as JustWatch. If TMDb find any usage not complying with these
* terms TMDb will revoke access to the API.