diff --git a/src/main/java/com/omertron/themoviedbapi/Compare.java b/src/main/java/com/omertron/themoviedbapi/Compare.java
new file mode 100644
index 000000000..8719734dc
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/Compare.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi;
+
+import com.omertron.themoviedbapi.model.movie.MovieDb;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Compare various objects to see if the are logically the same.
+ *
+ * Allows for some variance of the details
+ *
+ * @author Stuart.Boston
+ */
+public class Compare {
+
+ // Constants
+ private static final int YEAR_LENGTH = 4;
+
+ private Compare() {
+ throw new UnsupportedOperationException("Utility class");
+ }
+
+ /**
+ * Compare the MovieDB object with a title & year
+ *
+ * @param moviedb The moviedb object to compare too
+ * @param title The title of the movie to compare
+ * @param year The year of the movie to compare exact match
+ * @return True if there is a match, False otherwise.
+ */
+ public static boolean movies(final MovieDb moviedb, final String title, final String year) {
+ return movies(moviedb, title, year, 0, true);
+ }
+
+ /**
+ * Compare the MovieDB object with a title & year
+ *
+ * @param moviedb The moviedb object to compare too
+ * @param title The title of the movie to compare
+ * @param year The year of the movie to compare
+ * @param maxDistance The Levenshtein Distance between the two titles. 0 =
+ * exact match
+ * @param caseSensitive true if the comparison is to be case sensitive
+ * @return True if there is a match, False otherwise.
+ */
+ public static boolean movies(final MovieDb moviedb, final String title, final String year, int maxDistance, boolean caseSensitive) {
+ if ((moviedb == null) || (StringUtils.isBlank(title))) {
+ return false;
+ }
+
+ String primaryTitle, firstCompareTitle, secondCompareTitle;
+ if (caseSensitive) {
+ primaryTitle = title;
+ firstCompareTitle = moviedb.getOriginalTitle();
+ secondCompareTitle = moviedb.getTitle();
+ } else {
+ primaryTitle = title.toLowerCase();
+ firstCompareTitle = moviedb.getTitle().toLowerCase();
+ secondCompareTitle = moviedb.getOriginalTitle().toLowerCase();
+ }
+
+ if (isValidYear(year) && isValidYear(moviedb.getReleaseDate())) {
+ // Compare with year
+ String movieYear = moviedb.getReleaseDate().substring(0, YEAR_LENGTH);
+ return movieYear.equals(year) && compareTitles(primaryTitle, firstCompareTitle, secondCompareTitle, maxDistance);
+ }
+
+ // Compare without year
+ return compareTitles(primaryTitle, firstCompareTitle, secondCompareTitle, maxDistance);
+ }
+
+ /**
+ * Compare a title with two other titles.
+ *
+ * @param primaryTitle Primary title
+ * @param firstCompareTitle First title to compare with
+ * @param secondCompareTitle Second title to compare with
+ * @param maxDistance Maximum difference between the titles
+ * @return
+ */
+ private static boolean compareTitles(String primaryTitle, String firstCompareTitle, String secondCompareTitle, int maxDistance) {
+ // Compare with the first title
+ if (compareDistance(primaryTitle, firstCompareTitle, maxDistance)) {
+ return true;
+ }
+
+ // Compare with the other title
+ return compareDistance(primaryTitle, secondCompareTitle, maxDistance);
+ }
+
+ /**
+ * Compare the MovieDB object with a title & year, case sensitive
+ *
+ * @param moviedb
+ * @param title
+ * @param year
+ * @param maxDistance
+ * @return
+ */
+ public static boolean movies(final MovieDb moviedb, final String title, final String year, int maxDistance) {
+ return Compare.movies(moviedb, title, year, maxDistance, true);
+ }
+
+ /**
+ * Compare the Levenshtein Distance between the two strings
+ *
+ * @param title1
+ * @param title2
+ * @param distance
+ */
+ private static boolean compareDistance(final String title1, final String title2, int distance) {
+ return StringUtils.getLevenshteinDistance(title1, title2) <= distance;
+ }
+
+ /**
+ * Check the year is not blank or UNKNOWN
+ *
+ * @param year
+ */
+ private static boolean isValidYear(final String year) {
+ return StringUtils.isNotBlank(year) && !"UNKNOWN".equals(year);
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
index 18c27adc2..b5a0d1a06 100644
--- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
+++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
@@ -19,104 +19,109 @@
*/
package com.omertron.themoviedbapi;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.omertron.themoviedbapi.model.Account;
-import com.omertron.themoviedbapi.model.AlternativeTitle;
-import com.omertron.themoviedbapi.model.Artwork;
-import com.omertron.themoviedbapi.model.ArtworkType;
-import com.omertron.themoviedbapi.model.ChangeKeyItem;
-import com.omertron.themoviedbapi.model.ChangedItem;
-import com.omertron.themoviedbapi.model.ChangedMovie;
-import com.omertron.themoviedbapi.model.Collection;
-import com.omertron.themoviedbapi.model.CollectionInfo;
-import com.omertron.themoviedbapi.model.Company;
-import com.omertron.themoviedbapi.model.Discover;
+import com.omertron.themoviedbapi.enumeration.ExternalSource;
+import com.omertron.themoviedbapi.enumeration.MediaType;
+import com.omertron.themoviedbapi.enumeration.SearchType;
+import com.omertron.themoviedbapi.enumeration.SortBy;
+import com.omertron.themoviedbapi.methods.TmdbAccount;
+import com.omertron.themoviedbapi.methods.TmdbAuthentication;
+import com.omertron.themoviedbapi.methods.TmdbCertifications;
+import com.omertron.themoviedbapi.methods.TmdbChanges;
+import com.omertron.themoviedbapi.methods.TmdbCollections;
+import com.omertron.themoviedbapi.methods.TmdbCompanies;
+import com.omertron.themoviedbapi.methods.TmdbConfiguration;
+import com.omertron.themoviedbapi.methods.TmdbCredits;
+import com.omertron.themoviedbapi.methods.TmdbDiscover;
+import com.omertron.themoviedbapi.methods.TmdbFind;
+import com.omertron.themoviedbapi.methods.TmdbGenres;
+import com.omertron.themoviedbapi.methods.TmdbKeywords;
+import com.omertron.themoviedbapi.methods.TmdbLists;
+import com.omertron.themoviedbapi.methods.TmdbMovies;
+import com.omertron.themoviedbapi.methods.TmdbNetworks;
+import com.omertron.themoviedbapi.methods.TmdbPeople;
+import com.omertron.themoviedbapi.methods.TmdbReviews;
+import com.omertron.themoviedbapi.methods.TmdbSearch;
+import com.omertron.themoviedbapi.methods.TmdbTV;
+import com.omertron.themoviedbapi.model.Certification;
+import com.omertron.themoviedbapi.model.FindResults;
import com.omertron.themoviedbapi.model.Genre;
-import com.omertron.themoviedbapi.model.JobDepartment;
-import com.omertron.themoviedbapi.model.Keyword;
-import com.omertron.themoviedbapi.model.KeywordMovie;
-import com.omertron.themoviedbapi.model.ListItemStatus;
-import com.omertron.themoviedbapi.model.MovieDb;
-import com.omertron.themoviedbapi.model.MovieDbList;
-import com.omertron.themoviedbapi.model.MovieDbListStatus;
-import com.omertron.themoviedbapi.model.MovieList;
-import com.omertron.themoviedbapi.model.Person;
-import com.omertron.themoviedbapi.model.PersonCredit;
-import com.omertron.themoviedbapi.model.ReleaseInfo;
-import com.omertron.themoviedbapi.model.Reviews;
import com.omertron.themoviedbapi.model.StatusCode;
-import com.omertron.themoviedbapi.model.TmdbConfiguration;
-import com.omertron.themoviedbapi.model.TokenAuthorisation;
-import com.omertron.themoviedbapi.model.TokenSession;
-import com.omertron.themoviedbapi.model.Translation;
-import com.omertron.themoviedbapi.model.Video;
+import com.omertron.themoviedbapi.model.account.Account;
+import com.omertron.themoviedbapi.model.artwork.Artwork;
+import com.omertron.themoviedbapi.model.artwork.ArtworkMedia;
+import com.omertron.themoviedbapi.model.authentication.TokenAuthorisation;
+import com.omertron.themoviedbapi.model.authentication.TokenSession;
+import com.omertron.themoviedbapi.model.change.ChangeListItem;
+import com.omertron.themoviedbapi.model.collection.Collection;
+import com.omertron.themoviedbapi.model.collection.CollectionInfo;
+import com.omertron.themoviedbapi.model.company.Company;
+import com.omertron.themoviedbapi.model.config.Configuration;
+import com.omertron.themoviedbapi.model.config.JobDepartment;
+import com.omertron.themoviedbapi.model.discover.Discover;
+import com.omertron.themoviedbapi.model.keyword.Keyword;
+import com.omertron.themoviedbapi.model.list.ListItem;
+import com.omertron.themoviedbapi.model.list.UserList;
+import com.omertron.themoviedbapi.model.media.MediaBasic;
+import com.omertron.themoviedbapi.model.media.MediaCreditList;
+import com.omertron.themoviedbapi.model.media.MediaState;
+import com.omertron.themoviedbapi.model.media.AlternativeTitle;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.model.movie.MovieDb;
+import com.omertron.themoviedbapi.model.movie.ReleaseInfo;
+import com.omertron.themoviedbapi.model.media.Translation;
+import com.omertron.themoviedbapi.model.media.Video;
+import com.omertron.themoviedbapi.model.network.Network;
+import com.omertron.themoviedbapi.model.person.ContentRating;
+import com.omertron.themoviedbapi.model.person.CreditInfo;
+import com.omertron.themoviedbapi.model.person.ExternalID;
+import com.omertron.themoviedbapi.model.person.Person;
+import com.omertron.themoviedbapi.model.person.PersonCredits;
+import com.omertron.themoviedbapi.model.person.PersonFind;
+import com.omertron.themoviedbapi.model.review.Review;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import com.omertron.themoviedbapi.model.tv.TVInfo;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.results.TmdbResultsMap;
-import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.tools.MethodBase;
-import com.omertron.themoviedbapi.tools.MethodSub;
-import com.omertron.themoviedbapi.tools.Param;
-import com.omertron.themoviedbapi.tools.TmdbParameters;
-import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.wrapper.WrapperChanges;
-import com.omertron.themoviedbapi.wrapper.WrapperCollection;
-import com.omertron.themoviedbapi.wrapper.WrapperCompany;
-import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies;
-import com.omertron.themoviedbapi.wrapper.WrapperConfig;
-import com.omertron.themoviedbapi.wrapper.WrapperGenres;
-import com.omertron.themoviedbapi.wrapper.WrapperImages;
-import com.omertron.themoviedbapi.wrapper.WrapperJobList;
-import com.omertron.themoviedbapi.wrapper.WrapperKeywordMovies;
-import com.omertron.themoviedbapi.wrapper.WrapperKeywords;
-import com.omertron.themoviedbapi.wrapper.WrapperMovie;
-import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts;
-import com.omertron.themoviedbapi.wrapper.WrapperMovieChanges;
-import com.omertron.themoviedbapi.wrapper.WrapperMovieDbList;
-import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
-import com.omertron.themoviedbapi.wrapper.WrapperMovieList;
-import com.omertron.themoviedbapi.wrapper.WrapperPerson;
-import com.omertron.themoviedbapi.wrapper.WrapperPersonCredits;
-import com.omertron.themoviedbapi.wrapper.WrapperPersonList;
-import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
-import com.omertron.themoviedbapi.wrapper.WrapperReviews;
-import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
-import com.omertron.themoviedbapi.wrapper.WrapperVideos;
-import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.yamj.api.common.exception.ApiExceptionType;
import org.yamj.api.common.http.SimpleHttpClientBuilder;
/**
* The MovieDb API
*
- * This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3
+ * This is for version 3 of the API as specified here:
+ * http://help.themoviedb.org/kb/api/about-3
*
* @author stuart.boston
*/
public class TheMovieDbApi {
- private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApi.class);
- private String apiKey;
- private TmdbConfiguration tmdbConfig;
private HttpTools httpTools;
- // Jackson JSON configuration
- private static ObjectMapper mapper = new ObjectMapper();
- // Constants
- private static final String MOVIE_ID = "movie_id";
- private static final int YEAR_LENGTH = 4;
- private static final int RATING_MAX = 10;
- private static final int POST_SUCCESS_STATUS_CODE = 12;
+ // Sub-methods
+ private static TmdbAccount tmdbAccount;
+ private static TmdbAuthentication tmdbAuth;
+ private static TmdbCertifications tmdbCertifications;
+ private static TmdbChanges tmdbChanges;
+ private static TmdbCollections tmdbCollections;
+ private static TmdbCompanies tmdbCompany;
+ private static TmdbConfiguration tmdbConfiguration;
+ private static TmdbCredits tmdbCredits;
+ private static TmdbDiscover tmdbDiscover;
+ private static TmdbFind tmdbFind;
+ private static TmdbGenres tmdbGenre;
+ private static TmdbKeywords tmdbKeywords;
+ private static TmdbLists tmdbList;
+ private static TmdbMovies tmdbMovies;
+ private static TmdbNetworks tmdbNetworks;
+ private static TmdbPeople tmdbPeople;
+ private static TmdbReviews tmdbReviews;
+ private static TmdbSearch tmdbSearch;
+ private static TmdbTV tmdbTv;
/**
* API for The Movie Db.
@@ -136,181 +141,228 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public TheMovieDbApi(String apiKey, HttpClient httpClient) throws MovieDbException {
- this.apiKey = apiKey;
this.httpTools = new HttpTools(httpClient);
-
- URL configUrl = new ApiUrl(apiKey, MethodBase.CONFIGURATION).buildUrl();
- String webpage = httpTools.getRequest(configUrl);
-
- try {
- WrapperConfig wc = mapper.readValue(webpage, WrapperConfig.class);
- tmdbConfig = wc.getTmdbConfiguration();
- } catch (IOException ex) {
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to read configuration", configUrl, ex);
- }
+ initialise(apiKey, httpTools);
}
/**
- * Compare the MovieDB object with a title & year
+ * Initialise the sub-classes once the API key and http client are known
+ *
+ * @param apiKey
+ * @param httpTools
+ */
+ private void initialise(String apiKey, HttpTools httpTools) {
+ tmdbAccount = new TmdbAccount(apiKey, httpTools);
+ tmdbAuth = new TmdbAuthentication(apiKey, httpTools);
+ tmdbCertifications = new TmdbCertifications(apiKey, httpTools);
+ tmdbChanges = new TmdbChanges(apiKey, httpTools);
+ tmdbCollections = new TmdbCollections(apiKey, httpTools);
+ tmdbCompany = new TmdbCompanies(apiKey, httpTools);
+ tmdbConfiguration = new TmdbConfiguration(apiKey, httpTools);
+ tmdbCredits = new TmdbCredits(apiKey, httpTools);
+ tmdbDiscover = new TmdbDiscover(apiKey, httpTools);
+ tmdbFind = new TmdbFind(apiKey, httpTools);
+ tmdbGenre = new TmdbGenres(apiKey, httpTools);
+ tmdbKeywords = new TmdbKeywords(apiKey, httpTools);
+ tmdbList = new TmdbLists(apiKey, httpTools);
+ tmdbMovies = new TmdbMovies(apiKey, httpTools);
+ tmdbNetworks = new TmdbNetworks(apiKey, httpTools);
+ tmdbPeople = new TmdbPeople(apiKey, httpTools);
+ tmdbReviews = new TmdbReviews(apiKey, httpTools);
+ tmdbSearch = new TmdbSearch(apiKey, httpTools);
+ tmdbTv = new TmdbTV(apiKey, httpTools);
+ }
+
+ //
+ /**
+ * Get the basic information for an account. You will need to have a valid
+ * session id.
*
- * @param moviedb The moviedb object to compare too
- * @param title The title of the movie to compare
- * @param year The year of the movie to compare exact match
- * @return True if there is a match, False otherwise.
+ * @param sessionId
+ * @return
+ * @throws MovieDbException
*/
- public static boolean compareMovies(MovieDb moviedb, String title, String year) {
- return compareMovies(moviedb, title, year, 0);
+ public Account getAccount(String sessionId) throws MovieDbException {
+ return tmdbAccount.getAccount(sessionId);
}
/**
- * Compare the MovieDB object with a title & year
+ * Get all lists of a given user
*
- * @param moviedb The moviedb object to compare too
- * @param title The title of the movie to compare
- * @param year The year of the movie to compare
- * @param maxDistance The Levenshtein Distance between the two titles. 0 = exact match
- * @param caseSensitive true if the comparison is to be case sensitive
- * @return True if there is a match, False otherwise.
+ * @param sessionId
+ * @param accountId
+ * @return The lists
+ * @throws MovieDbException
*/
- public static boolean compareMovies(MovieDb moviedb, String title, String year, int maxDistance, boolean caseSensitive) {
- if ((moviedb == null) || (StringUtils.isBlank(title))) {
- return Boolean.FALSE;
- }
-
- String cmpTitle, cmpOtherTitle, cmpOriginalTitle;
- if (caseSensitive) {
- cmpTitle = title;
- cmpOtherTitle = moviedb.getOriginalTitle();
- cmpOriginalTitle = moviedb.getTitle();
- } else {
- cmpTitle = title.toLowerCase();
- cmpOtherTitle = moviedb.getTitle().toLowerCase();
- cmpOriginalTitle = moviedb.getOriginalTitle().toLowerCase();
- }
+ public List getUserLists(String sessionId, int accountId) throws MovieDbException {
+ return tmdbAccount.getUserLists(sessionId, accountId);
+ }
- if (isValidYear(year) && isValidYear(moviedb.getReleaseDate())) {
- // Compare with year
- String movieYear = moviedb.getReleaseDate().substring(0, YEAR_LENGTH);
- if (movieYear.equals(year)) {
- if (compareDistance(cmpOriginalTitle, cmpTitle, maxDistance)) {
- return Boolean.TRUE;
- }
+ /**
+ * Get the account favourite movies
+ *
+ * @param sessionId
+ * @param accountId
+ * @return
+ * @throws MovieDbException
+ */
+ public List getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
+ return tmdbAccount.getFavoriteMovies(sessionId, accountId);
+ }
- if (compareDistance(cmpOtherTitle, cmpTitle, maxDistance)) {
- return Boolean.TRUE;
- }
- }
- }
+ /**
+ * Add or remove a movie to an accounts favourite list.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param mediaId
+ * @param mediaType
+ * @param isFavorite
+ * @return
+ * @throws MovieDbException
+ */
+ public StatusCode modifyFavoriteStatus(String sessionId, int accountId, Integer mediaId, MediaType mediaType, boolean isFavorite) throws MovieDbException {
+ return tmdbAccount.modifyFavoriteStatus(sessionId, accountId, mediaType, mediaId, isFavorite);
+ }
- // Compare without year
- if (compareDistance(cmpOriginalTitle, cmpTitle, maxDistance)) {
- return Boolean.TRUE;
- }
+ /**
+ * Get the list of rated movies (and associated rating) for an account.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param page
+ * @param sortBy
+ * @param language
+ * @return
+ * @throws MovieDbException
+ */
+ public List getRatedMovies(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
+ return tmdbAccount.getRatedMovies(sessionId, accountId, page, sortBy, language);
+ }
- if (compareDistance(cmpOtherTitle, cmpTitle, maxDistance)) {
- return Boolean.TRUE;
- }
+ /**
+ * Get the list of rated TV shows (and associated rating) for an account.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param page
+ * @param sortBy
+ * @param language
+ * @return
+ * @throws MovieDbException
+ */
+ public List getRatedTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
+ return tmdbAccount.getRatedTV(sessionId, accountId, page, sortBy, language);
+ }
- return Boolean.FALSE;
+ /**
+ * Get the list of movies on an accounts watchlist.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param page
+ * @param sortBy
+ * @param language
+ * @return The watchlist of the user
+ * @throws MovieDbException
+ */
+ public List getWatchListMovie(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
+ return tmdbAccount.getWatchListMovie(sessionId, accountId, page, sortBy, language);
}
/**
- * Compare the MovieDB object with a title & year, case sensitive
+ * Get the list of movies on an accounts watchlist.
*
- * @param moviedb
- * @param title
- * @param year
- * @param maxDistance
- * @return
+ * @param sessionId
+ * @param accountId
+ * @param page
+ * @param sortBy
+ * @param language
+ * @return The watchlist of the user
+ * @throws MovieDbException
*/
- public static boolean compareMovies(MovieDb moviedb, String title, String year, int maxDistance) {
- return compareMovies(moviedb, title, year, maxDistance, true);
+ public List getWatchListTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
+ return tmdbAccount.getWatchListTV(sessionId, accountId, page, sortBy, language);
}
/**
- * Compare the Levenshtein Distance between the two strings
+ * Add a movie to an accounts watch list.
*
- * @param title1
- * @param title2
- * @param distance
+ * @param sessionId
+ * @param accountId
+ * @param mediaId
+ * @param mediaType
+ * @return
+ * @throws MovieDbException
*/
- private static boolean compareDistance(String title1, String title2, int distance) {
- return StringUtils.getLevenshteinDistance(title1, title2) <= distance;
+ public StatusCode addToWatchList(String sessionId, int accountId, MediaType mediaType, Integer mediaId) throws MovieDbException {
+ return tmdbAccount.modifyWatchList(sessionId, accountId, mediaType, mediaId, true);
}
/**
- * Check the year is not blank or UNKNOWN
+ * Remove a movie from an accounts watch list.
*
- * @param year
+ * @param sessionId
+ * @param accountId
+ * @param mediaId
+ * @param mediaType
+ * @return
+ * @throws MovieDbException
*/
- private static boolean isValidYear(String year) {
- return StringUtils.isNotBlank(year) && !"UNKNOWN".equals(year);
+ public StatusCode removeFromWatchList(String sessionId, int accountId, MediaType mediaType, Integer mediaId) throws MovieDbException {
+ return tmdbAccount.modifyWatchList(sessionId, accountId, mediaType, mediaId, false);
}
- //
/**
- * Get the configuration information
+ * Get the list of favorite TV series for an account.
*
+ * @param sessionId
+ * @param accountId
* @return
+ * @throws MovieDbException
*/
- public TmdbConfiguration getConfiguration() {
- return tmdbConfig;
+ public List getFavoriteTv(String sessionId, int accountId) throws MovieDbException {
+ return tmdbAccount.getFavoriteTv(sessionId, accountId);
}
/**
- * Generate the full image URL from the size and image path
+ * Get a list of rated movies for a specific guest session id.
*
- * @param imagePath
- * @param requiredSize
+ * @param guestSessionId
+ * @param language
+ * @param page
+ * @param sortBy only CREATED_AT_ASC or CREATED_AT_DESC is supported
* @return
* @throws MovieDbException
*/
- public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException {
- if (!tmdbConfig.isValidSize(requiredSize)) {
- throw new MovieDbException(ApiExceptionType.INVALID_IMAGE, requiredSize);
- }
-
- StringBuilder sb = new StringBuilder(tmdbConfig.getBaseUrl());
- sb.append(requiredSize);
- sb.append(imagePath);
- try {
- return new URL(sb.toString());
- } catch (MalformedURLException ex) {
- LOG.warn("Failed to create image URL: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.INVALID_URL, sb.toString(), "", ex);
- }
+ public List getGuestRatedMovies(String guestSessionId, String language, Integer page, SortBy sortBy) throws MovieDbException {
+ return tmdbAccount.getGuestRatedMovies(guestSessionId, language, page, sortBy);
}
//
- //
+ //
/**
- * This method is used to generate a valid request token for user based authentication.
+ * This method is used to generate a valid request token for user based
+ * authentication.
*
* A request token is required in order to request a session id.
*
- * You can generate any number of request tokens but they will expire after 60 minutes.
+ * You can generate any number of request tokens but they will expire after
+ * 60 minutes.
*
- * As soon as a valid session id has been created the token will be destroyed.
+ * As soon as a valid session id has been created the token will be
+ * destroyed.
*
* @return
* @throws MovieDbException
*/
public TokenAuthorisation getAuthorisationToken() throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- URL url = new ApiUrl(apiKey, MethodBase.AUTH).setSubMethod(MethodSub.TOKEN_NEW).buildUrl(parameters);
-
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, TokenAuthorisation.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get Authorisation Token: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, webpage, url, ex);
- }
+ return tmdbAuth.getAuthorisationToken();
}
/**
- * This method is used to generate a session id for user based authentication.
+ * This method is used to generate a session id for user based
+ * authentication.
*
* A session id is required in order to use any of the write methods.
*
@@ -319,27 +371,12 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
-
- if (!token.getSuccess()) {
- LOG.warn("Session token was not successful!");
- throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, "Authorisation token was not successful!");
- }
-
- parameters.add(Param.TOKEN, token.getRequestToken());
- URL url = new ApiUrl(apiKey, MethodBase.AUTH).setSubMethod(MethodSub.SESSION_NEW).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, TokenSession.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get Session Token: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ return tmdbAuth.getSessionToken(token);
}
/**
- * This method is used to generate a session id for user based authentication. User must provide their username and password
+ * This method is used to generate a session id for user based
+ * authentication. User must provide their username and password
*
* A session id is required in order to use any of the write methods.
*
@@ -350,174 +387,449 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public TokenAuthorisation getSessionTokenLogin(TokenAuthorisation token, String username, String password) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
+ return tmdbAuth.getSessionTokenLogin(token, username, password);
+ }
- if (!token.getSuccess()) {
- LOG.warn("Session token was not successful!");
- throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, "Authorisation token was not successful!");
- }
+ /**
+ * This method is used to generate a guest session id.
+ *
+ * A guest session can be used to rate movies without having a registered
+ * TMDb user account.
+ *
+ * You should only generate a single guest session per user (or device) as
+ * you will be able to attach the ratings to a TMDb user account in the
+ * future.
+ *
+ * There are also IP limits in place so you should always make sure it's the
+ * end user doing the guest session actions.
+ *
+ * If a guest session is not used for the first time within 24 hours, it
+ * will be automatically discarded.
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public TokenSession getGuestSessionToken() throws MovieDbException {
+ return tmdbAuth.getGuestSessionToken();
+ }
+ //
- parameters.add(Param.TOKEN, token.getRequestToken());
- parameters.add(Param.USERNAME, username);
- parameters.add(Param.PASSWORD, password);
+ //
+ /**
+ * Get a list of movies certification.
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public TmdbResultsMap> getMoviesCertification() throws MovieDbException {
+ return tmdbCertifications.getMoviesCertification();
+ }
- URL url = new ApiUrl(apiKey, MethodBase.AUTH).setSubMethod(MethodSub.TOKEN_VALIDATE).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
+ /**
+ * Get a list of tv certification.
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public TmdbResultsMap> getTvCertification() throws MovieDbException {
+ return tmdbCertifications.getTvCertification();
+ }
+ //
- try {
- return mapper.readValue(webpage, TokenAuthorisation.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get Session Token: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ //
+ /**
+ * Get a list of Movie IDs that have been edited.
+ *
+ * You can then use the movie changes API to get the actual data that has
+ * been changed.
+ *
+ * @param page
+ * @param startDate the start date of the changes, optional
+ * @param endDate the end date of the changes, optional
+ * @return List of changed movie
+ * @throws MovieDbException
+ */
+ public List getMovieChangeList(Integer page, String startDate, String endDate) throws MovieDbException {
+ return tmdbChanges.getChangeList(MethodBase.MOVIE, page, startDate, endDate);
}
/**
- * This method is used to generate a guest session id.
+ * Get a list of TV IDs that have been edited.
*
- * A guest session can be used to rate movies without having a registered TMDb user account.
+ * You can then use the TV changes API to get the actual data that has been
+ * changed.
+ *
+ * @param page
+ * @param startDate the start date of the changes, optional
+ * @param endDate the end date of the changes, optional
+ * @return List of changed movie
+ * @throws MovieDbException
+ */
+ public List getTvChangeList(Integer page, String startDate, String endDate) throws MovieDbException {
+ return tmdbChanges.getChangeList(MethodBase.TV, page, startDate, endDate);
+ }
+
+ /**
+ * Get a list of Person IDs that have been edited.
*
- * You should only generate a single guest session per user (or device) as you will be able to attach the ratings to a TMDb user
- * account in the future.
+ * You can then use the person changes API to get the actual data that has
+ * been changed.
*
- * There are also IP limits in place so you should always make sure it's the end user doing the guest session actions.
+ * @param page
+ * @param startDate the start date of the changes, optional
+ * @param endDate the end date of the changes, optional
+ * @return List of changed movie
+ * @throws MovieDbException
+ */
+ public List getPersonChangeList(Integer page, String startDate, String endDate) throws MovieDbException {
+ return tmdbChanges.getChangeList(MethodBase.PERSON, page, startDate, endDate);
+ }
+ //
+
+ //
+ /**
+ * This method is used to retrieve all of the basic information about a
+ * movie collection.
*
- * If a guest session is not used for the first time within 24 hours, it will be automatically discarded.
+ * You can get the ID needed for this method by making a getMovieInfo
+ * request for the belongs_to_collection.
*
+ * @param collectionId
+ * @param language
* @return
* @throws MovieDbException
*/
- public TokenSession getGuestSessionToken() throws MovieDbException {
- URL url = new ApiUrl(apiKey, MethodBase.AUTH).setSubMethod(MethodSub.GUEST_SESSION).buildUrl();
- String webpage = httpTools.getRequest(url);
+ public CollectionInfo getCollectionInfo(int collectionId, String language) throws MovieDbException {
+ return tmdbCollections.getCollectionInfo(collectionId, language);
+ }
- try {
- return mapper.readValue(webpage, TokenSession.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get Guest Session Token: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ /**
+ * Get all of the images for a particular collection by collection id.
+ *
+ * @param collectionId
+ * @param language
+ * @return
+ * @throws MovieDbException
+ */
+ public TmdbResultsList getCollectionImages(int collectionId, String language) throws MovieDbException {
+ return tmdbCollections.getCollectionImages(collectionId, language);
}
+ //
+ //
/**
- * Get the basic information for an account. You will need to have a valid session id.
+ * This method is used to retrieve the basic information about a production
+ * company on TMDb.
*
- * @param sessionId
+ * @param companyId
* @return
* @throws MovieDbException
*/
- public Account getAccount(String sessionId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
+ public Company getCompanyInfo(int companyId) throws MovieDbException {
+ return tmdbCompany.getCompanyInfo(companyId);
+ }
- URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
+ /**
+ * This method is used to retrieve the movies associated with a company.
+ *
+ * These movies are returned in order of most recently released to oldest.
+ * The default response will return 20 movies per page.
+ *
+ * @param companyId
+ * @param language
+ * @param page
+ * @return
+ * @throws MovieDbException
+ */
+ public List getCompanyMovies(int companyId, String language, Integer page) throws MovieDbException {
+ return tmdbCompany.getCompanyMovies(companyId, language, page);
+ }
+ //
- try {
- return mapper.readValue(webpage, Account.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get Account: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ //
+ /**
+ * Get the configuration information
+ *
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ public Configuration getConfiguration() throws MovieDbException {
+ return tmdbConfiguration.getConfig();
}
/**
- * Get the account favourite movies
+ * Generate the full image URL from the size and image path
*
- * @param sessionId
- * @param accountId
+ * @param imagePath
+ * @param requiredSize
* @return
* @throws MovieDbException
*/
- public List getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
+ public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException {
+ return tmdbConfiguration.getConfig().createImageUrl(imagePath, requiredSize);
+ }
- URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.FAVORITE_MOVIES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
+ /**
+ * Get a list of valid jobs
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public TmdbResultsList getJobs() throws MovieDbException {
+ return tmdbConfiguration.getJobs();
+ }
- try {
- return mapper.readValue(webpage, WrapperMovie.class).getMovies();
- } catch (IOException ex) {
- LOG.warn("Failed to get favorite movies: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ /**
+ * Get the list of supported timezones for the API methods that support
+ * them.
+ *
+ * @return @throws MovieDbException
+ */
+ public Map> getTimezones() throws MovieDbException {
+ return tmdbConfiguration.getTimezones();
}
+ //
- public StatusCode changeFavoriteStatus(String sessionId, int accountId, Integer movieId, boolean isFavorite) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
+ //
+ /**
+ * Get the detailed information about a particular credit record.
+ *
+ * This is currently only supported with the new credit model found in TV.
+ *
+ * These IDs can be found from any TV credit response as well as the
+ * TV_credits and combined_credits methods for people.
+ * The episodes object returns a list of episodes and are generally going to
+ * be guest stars.
+ * The season array will return a list of season numbers.
+ * Season credits are credits that were marked with the "add to every
+ * season" option in the editing interface and are assumed to be "season
+ * regulars".
+ *
+ * @param creditId
+ * @param language
+ * @return
+ * @throws MovieDbException
+ */
+ public CreditInfo getCreditInfo(String creditId, String language) throws MovieDbException {
+ return tmdbCredits.getCreditInfo(creditId, language);
+ }
+ //
- Map body = new HashMap();
- body.put(MOVIE_ID, movieId);
- body.put("favorite", isFavorite);
- String jsonBody = convertToJson(body);
+ //
+ /**
+ * Discover movies by different types of data like average rating, number of
+ * votes, genres and certifications.
+ *
+ * @param discover A discover object containing the search criteria required
+ * @return
+ * @throws MovieDbException
+ */
+ public List getDiscoverMovies(Discover discover) throws MovieDbException {
+ return tmdbDiscover.getDiscoverMovies(discover);
+ }
- URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.FAVORITE).buildUrl(parameters);
- String webpage = httpTools.postRequest(url, jsonBody);
+ /**
+ * Discover movies by different types of data like average rating, number of
+ * votes, genres and certifications.
+ *
+ * @param discover A discover object containing the search criteria required
+ * @return
+ * @throws MovieDbException
+ */
+ public List getDiscoverTV(Discover discover) throws MovieDbException {
+ return tmdbDiscover.getDiscoverTV(discover);
+ }
+ //
- try {
- return mapper.readValue(webpage, StatusCode.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get favorite status: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ //
+ /**
+ * You con use this method to find movies, tv series or persons using
+ * external ids.
+ *
+ * Supported query ids are
+ *
+ * - Movies: imdb_id
+ * - People: imdb_id, freebase_mid, freebase_id, tvrage_id
+ * - TV Series: imdb_id, freebase_mid, freebase_id, tvdb_id,
+ * tvrage_id
+ * - TV Seasons: freebase_mid, freebase_id, tvdb_id, tvrage_id
+ * - TV Episodes: imdb_id, freebase_mid, freebase_id, tvdb_id,
+ * tvrage_idimdb_id, freebase_mid, freebase_id, tvrage_id, tvdb_id.
+ *
+ *
+ * For details see http://docs.themoviedb.apiary.io/#find
+ *
+ * @param id the external id
+ * @param externalSource one of {@link ExternalSource}.
+ * @param language the language
+ * @return
+ * @throws MovieDbException
+ */
+ public FindResults find(String id, ExternalSource externalSource, String language) throws MovieDbException {
+ return tmdbFind.find(id, externalSource, language);
}
+ //
+ //
/**
- * Add a movie to an accounts watch list.
+ * Get the list of Movie genres.
*
- * @param sessionId
- * @param accountId
- * @param movieId
+ * @param language
* @return
* @throws MovieDbException
*/
- public StatusCode addToWatchList(String sessionId, int accountId, Integer movieId) throws MovieDbException {
- return modifyWatchList(sessionId, accountId, movieId, true);
+ public TmdbResultsList getGenreMovieList(String language) throws MovieDbException {
+ return tmdbGenre.getGenreMovieList(language);
}
/**
- * Remove a movie from an accounts watch list.
+ * Get the list of TV genres..
*
- * @param sessionId
- * @param accountId
- * @param movieId
+ * @param language
* @return
* @throws MovieDbException
*/
- public StatusCode removeFromWatchList(String sessionId, int accountId, Integer movieId) throws MovieDbException {
- return modifyWatchList(sessionId, accountId, movieId, false);
+ public TmdbResultsList getGenreTVList(String language) throws MovieDbException {
+ return tmdbGenre.getGenreTVList(language);
}
- private StatusCode modifyWatchList(String sessionId, int accountId, Integer movieId, boolean add) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
+ /**
+ * Get a list of movies per genre.
+ *
+ * It is important to understand that only movies with more than 10 votes
+ * get listed.
+ *
+ * This prevents movies from 1 10/10 rating from being listed first and for
+ * the first 5 pages.
+ *
+ * @param genreId
+ * @param language
+ * @param page
+ * @param includeAllMovies
+ * @param includeAdult
+ * @return
+ * @throws MovieDbException
+ */
+ public List getGenreMovies(int genreId, String language, Integer page, Boolean includeAllMovies, Boolean includeAdult) throws MovieDbException {
+ return tmdbGenre.getGenreMovies(genreId, language, page, includeAllMovies, includeAdult);
+ }
+ //
- Map body = new HashMap();
- body.put(MOVIE_ID, movieId);
- body.put("movie_watchlist", add);
- String jsonBody = convertToJson(body);
+ //
+ /**
+ * Get the basic information for a specific keyword id.
+ *
+ * @param keywordId
+ * @return
+ * @throws MovieDbException
+ */
+ public Keyword getKeyword(String keywordId) throws MovieDbException {
+ return tmdbKeywords.getKeyword(keywordId);
+ }
- URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.MOVIE_WATCHLIST).buildUrl(parameters);
- String webpage = httpTools.postRequest(url, jsonBody);
+ /**
+ * Get the list of movies for a particular keyword by id.
+ *
+ * @param keywordId
+ * @param language
+ * @param page
+ * @return List of movies with the keyword
+ * @throws MovieDbException
+ */
+ public TmdbResultsList getKeywordMovies(String keywordId, String language, Integer page) throws MovieDbException {
+ return tmdbKeywords.getKeywordMovies(keywordId, language, page);
+ }
+ //
+
+ //
+ /**
+ * Get a list by its ID
+ *
+ * @param listId
+ * @return The list and its items
+ * @throws MovieDbException
+ */
+ public ListItem getList(String listId) throws MovieDbException {
+ return tmdbList.getList(listId);
+ }
- try {
- return mapper.readValue(webpage, StatusCode.class);
- } catch (IOException ex) {
- LOG.warn("Failed to modify watch list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ /**
+ * This method lets users create a new list. A valid session id is required.
+ *
+ * @param sessionId
+ * @param name
+ * @param description
+ * @return The list id
+ * @throws MovieDbException
+ */
+ public String createList(String sessionId, String name, String description) throws MovieDbException {
+ return tmdbList.createList(sessionId, name, description);
+ }
+
+ /**
+ * This method lets users delete a list that they created. A valid session
+ * id is required.
+ *
+ * @param sessionId
+ * @param listId
+ * @return
+ * @throws MovieDbException
+ */
+ public StatusCode deleteList(String sessionId, String listId) throws MovieDbException {
+ return tmdbList.deleteList(sessionId, listId);
+ }
+
+ /**
+ * Check to see if an item is already on a list.
+ *
+ * @param listId
+ * @param mediaId
+ * @return true if the item is on the list
+ * @throws MovieDbException
+ */
+ public boolean checkItemStatus(String listId, Integer mediaId) throws MovieDbException {
+ return tmdbList.checkItemStatus(listId, mediaId);
+ }
+
+ /**
+ * This method lets users add new items to a list that they created.
+ *
+ * A valid session id is required.
+ *
+ * @param sessionId
+ * @param listId
+ * @param mediaId
+ * @return true if the movie is on the list
+ * @throws MovieDbException
+ */
+ public StatusCode addItemToList(String sessionId, String listId, Integer mediaId) throws MovieDbException {
+ return tmdbList.addItem(sessionId, listId, mediaId);
+ }
+
+ /**
+ * This method lets users remove items from a list that they created.
+ *
+ * A valid session id is required.
+ *
+ * @param sessionId
+ * @param listId
+ * @param mediaId
+ * @return true if the movie is on the list
+ * @throws MovieDbException
+ */
+ public StatusCode removeItemFromList(String sessionId, String listId, Integer mediaId) throws MovieDbException {
+ return tmdbList.removeItem(sessionId, listId, mediaId);
}
//
- //
+ //
/**
* This method is used to retrieve all of the basic movie information.
*
* It will return the single highest rated poster and backdrop.
*
- * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found.
+ * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies
+ * found.
*
* @param movieId
* @param language
@@ -526,24 +838,7 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public MovieDb getMovieInfo(int movieId, String language, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, movieId);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
- try {
- MovieDb movie = mapper.readValue(webpage, MovieDb.class);
- if (movie == null || movie.getId() == 0) {
- LOG.warn("No movie found for ID '{}'", movieId);
- throw new MovieDbException(ApiExceptionType.ID_NOT_FOUND, "No movie found for ID: " + movieId, url);
- }
- return movie;
- } catch (IOException ex) {
- LOG.warn("Failed to get movie info: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ return tmdbMovies.getMovieInfo(movieId, language, appendToResponse);
}
/**
@@ -551,7 +846,8 @@ public class TheMovieDbApi {
*
* It will return the single highest rated poster and backdrop.
*
- * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found.
+ * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies
+ * found.
*
* @param imdbId
* @param language
@@ -560,29 +856,27 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public MovieDb getMovieInfoImdb(String imdbId, String language, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, imdbId);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
+ return tmdbMovies.getMovieInfoImdb(imdbId, language, appendToResponse);
+ }
- try {
- MovieDb movie = mapper.readValue(webpage, MovieDb.class);
- if (movie == null || movie.getId() == 0) {
- LOG.warn("No movie found for IMDB ID: '{}'", imdbId);
- throw new MovieDbException(ApiExceptionType.ID_NOT_FOUND, "No movie found for IMDB ID: " + imdbId, url);
- }
- return movie;
- } catch (IOException ex) {
- LOG.warn("Failed to get movie info: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie info", url, ex);
- }
+ /**
+ * This method lets a user get the status of whether or not the movie has
+ * been rated or added to their favourite or movie watch list.
+ *
+ * A valid session id is required.
+ *
+ * @param movieId
+ * @param sessionId
+ * @return
+ * @throws MovieDbException
+ */
+ public MediaState getMovieAccountState(int movieId, String sessionId) throws MovieDbException {
+ return tmdbMovies.getMovieAccountState(movieId, sessionId);
}
/**
- * This method is used to retrieve all of the alternative titles we have for a particular movie.
+ * This method is used to retrieve all of the alternative titles we have for
+ * a particular movie.
*
* @param movieId
* @param country
@@ -591,55 +885,24 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public TmdbResultsList getMovieAlternativeTitles(int movieId, String country, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, movieId);
- parameters.add(Param.COUNTRY, country);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.ALT_TITLES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
- try {
- WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getTitles());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get movie alternative titles: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ return tmdbMovies.getMovieAlternativeTitles(movieId, country, appendToResponse);
}
/**
- * Get the cast information for a specific movie id.
- *
- * TODO: Add a function to enrich the data with the people methods
+ * Get the cast and crew information for a specific movie id.
*
* @param movieId
* @param appendToResponse
* @return
* @throws MovieDbException
*/
- public TmdbResultsList getMovieCasts(int movieId, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, movieId);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.CASTS).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperMovieCasts wrapper = mapper.readValue(webpage, WrapperMovieCasts.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getAll());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get movie casts: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public MediaCreditList getMovieCredits(int movieId, String... appendToResponse) throws MovieDbException {
+ return tmdbMovies.getMovieCredits(movieId, appendToResponse);
}
/**
- * This method should be used when you’re wanting to retrieve all of the images for a particular movie.
+ * This method should be used when you’re wanting to retrieve all of the
+ * images for a particular movie.
*
* @param movieId
* @param language
@@ -648,27 +911,12 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public TmdbResultsList getMovieImages(int movieId, String language, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, movieId);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.IMAGES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getAll());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get movie images: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ return tmdbMovies.getMovieImages(movieId, language, appendToResponse);
}
/**
- * This method is used to retrieve all of the keywords that have been added to a particular movie.
+ * This method is used to retrieve all of the keywords that have been added
+ * to a particular movie.
*
* Currently, only English keywords exist.
*
@@ -678,26 +926,12 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public TmdbResultsList getMovieKeywords(int movieId, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, movieId);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.KEYWORDS).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperMovieKeywords wrapper = mapper.readValue(webpage, WrapperMovieKeywords.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getKeywords());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get movie keywords: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ return tmdbMovies.getMovieKeywords(movieId, appendToResponse);
}
/**
- * This method is used to retrieve all of the release and certification data we have for a specific movie.
+ * This method is used to retrieve all of the release and certification data
+ * we have for a specific movie.
*
* @param movieId
* @param language
@@ -706,27 +940,12 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public TmdbResultsList getMovieReleaseInfo(int movieId, String language, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, movieId);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.RELEASES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperReleaseInfo wrapper = mapper.readValue(webpage, WrapperReleaseInfo.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getCountries());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get movie release information: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ return tmdbMovies.getMovieReleaseInfo(movieId, language, appendToResponse);
}
/**
- * This method is used to retrieve all of the trailers for a particular movie.
+ * This method is used to retrieve all of the trailers for a particular
+ * movie.
*
* Supported sites are YouTube and QuickTime.
*
@@ -736,28 +955,13 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
- public TmdbResultsList
+ //
/**
- * Get the list of rated movies (and associated rating) for an account.
+ * This method is used to retrieve the basic information about a TV network.
+ *
+ * You can use this ID to search for TV shows with the discover method.
*
- * @param sessionId
- * @param accountId
+ * @param networkId
* @return
* @throws MovieDbException
*/
- public List getRatedMovies(String sessionId, int accountId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
-
- URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.RATED_MOVIES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, WrapperMovie.class).getMovies();
- } catch (IOException ex) {
- LOG.warn("Failed to get rated movies: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public Network getNetworkInfo(int networkId) throws MovieDbException {
+ return tmdbNetworks.getNetworkInfo(networkId);
}
+ //
+ //
/**
- * This method lets users rate a movie.
+ * Get the general person information for a specific id.
*
- * A valid session id is required.
- *
- * @param sessionId
- * @param movieId
- * @param rating
+ * @param personId
+ * @param appendToResponse
* @return
* @throws MovieDbException
*/
- public boolean postMovieRating(String sessionId, Integer movieId, Integer rating) throws MovieDbException {
- if (rating < 0 || rating > RATING_MAX) {
- throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Rating out of range");
- }
-
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(movieId, MethodSub.RATING).buildUrl(parameters);
-
- String jsonBody = convertToJson(Collections.singletonMap("value", rating));
- String webpage = httpTools.postRequest(url, jsonBody);
-
- try {
- StatusCode status = mapper.readValue(webpage, StatusCode.class);
- LOG.info("Status: {}", status);
- int code = status.getStatusCode();
- return code == POST_SUCCESS_STATUS_CODE;
- } catch (IOException ex) {
- LOG.warn("Failed to post movie rating: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public Person getPersonInfo(int personId, String... appendToResponse) throws MovieDbException {
+ return tmdbPeople.getPersonInfo(personId, appendToResponse);
}
- //
- //
/**
- * This method is used to retrieve all of the basic information about a movie collection.
+ * Get the movie credits for a specific person id.
*
- * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection.
- *
- * @param collectionId
+ * @param personId
* @param language
+ * @param appendToResponse
* @return
* @throws MovieDbException
*/
- public CollectionInfo getCollectionInfo(int collectionId, String language) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, collectionId);
- parameters.add(Param.LANGUAGE, language);
-
- URL url = new ApiUrl(apiKey, MethodBase.COLLECTION).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, CollectionInfo.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get collection information: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public PersonCredits getPersonMovieCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
+ return tmdbPeople.getPersonMovieCredits(personId, language, appendToResponse);
}
/**
- * Get all of the images for a particular collection by collection id.
+ * Get the TV credits for a specific person id.
*
- * @param collectionId
+ * To get the expanded details for each record, call the /credit method with
+ * the provided credit_id.
+ *
+ * This will provide details about which episode and/or season the credit is
+ * for.
+ *
+ * @param personId
* @param language
+ * @param appendToResponse
* @return
* @throws MovieDbException
*/
- public TmdbResultsList getCollectionImages(int collectionId, String language) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, collectionId);
- parameters.add(Param.LANGUAGE, language);
-
- URL url = new ApiUrl(apiKey, MethodBase.COLLECTION).setSubMethod(MethodSub.IMAGES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getAll(ArtworkType.POSTER, ArtworkType.BACKDROP));
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get collection images: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public PersonCredits getPersonTVCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
+ return tmdbPeople.getPersonTVCredits(personId, language, appendToResponse);
}
- //
- //
/**
- * This method is used to retrieve all of the basic person information.
+ * Get the combined (movie and TV) credits for a specific person id.
*
- * It will return the single highest rated profile image.
+ * To get the expanded details for each TV record, call the /credit method
+ * with the provided credit_id.
+ *
+ * This will provide details about which episode and/or season the credit is
+ * for.
*
* @param personId
+ * @param language
* @param appendToResponse
* @return
* @throws MovieDbException
*/
- public Person getPersonInfo(int personId, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, personId);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.PERSON).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, Person.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get person info: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public PersonCredits getPersonCombinedCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
+ return tmdbPeople.getPersonCombinedCredits(personId, language, appendToResponse);
}
/**
- * This method is used to retrieve all of the cast & crew information for the person.
- *
- * It will return the single highest rated poster for each movie record.
+ * Get the external ids for a specific person id.
*
* @param personId
- * @param appendToResponse
* @return
* @throws MovieDbException
*/
- public TmdbResultsList getPersonCredits(int personId, String... appendToResponse) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, personId);
- parameters.add(Param.APPEND, appendToResponse);
-
- URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.CREDITS).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperPersonCredits wrapper = mapper.readValue(webpage, WrapperPersonCredits.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getAll());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get person credits: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public ExternalID getPersonExternalIds(int personId) throws MovieDbException {
+ return tmdbPeople.getPersonExternalIds(personId);
}
/**
- * This method is used to retrieve all of the profile images for a person.
+ * Get the images for a specific person id.
*
* @param personId
* @return
* @throws MovieDbException
*/
public TmdbResultsList getPersonImages(int personId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, personId);
-
- URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.IMAGES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
+ return tmdbPeople.getPersonImages(personId);
+ }
- try {
- WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getAll(ArtworkType.PROFILE));
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get person images: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ /**
+ * Get the images that have been tagged with a specific person id.
+ *
+ * We return all of the image results with a media object mapped for each
+ * image.
+ *
+ * @param personId
+ * @param page
+ * @param language
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ public TmdbResultsList getPersonTaggedImages(int personId, Integer page, String language) throws MovieDbException {
+ return tmdbPeople.getPersonTaggedImages(personId, page, language);
}
/**
@@ -1258,30 +1253,19 @@ public class TheMovieDbApi {
*
* By default, only the last 24 hours of changes are returned.
*
- * The maximum number of days that can be returned in a single request is 14.
+ * The maximum number of days that can be returned in a single request is
+ * 14.
*
* The language is present on fields that are translatable.
*
* @param personId
* @param startDate
* @param endDate
- * @throws MovieDbException
- */
- public void getPersonChanges(int personId, String startDate, String endDate) throws MovieDbException {
- LOG.trace("getPersonChanges: id: {}, start: {}, end: {}", personId, startDate, endDate);
- throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Not implemented yet", "");
- }
-
- /**
- * Get the list of popular people on The Movie Database.
- *
- * This list refreshes every day.
- *
* @return
- * @throws MovieDbException
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public TmdbResultsList getPersonPopular() throws MovieDbException {
- return getPersonPopular(0);
+ public WrapperChanges getPersonChanges(int personId, String startDate, String endDate) throws MovieDbException {
+ return tmdbPeople.getPersonChanges(personId, startDate, endDate);
}
/**
@@ -1293,22 +1277,8 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
- public TmdbResultsList getPersonPopular(int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.POPULAR).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperPersonList wrapper = mapper.readValue(webpage, WrapperPersonList.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getPersonList());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get popular person: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList getPersonPopular(Integer page) throws MovieDbException {
+ return tmdbPeople.getPersonPopular(page);
}
/**
@@ -1318,711 +1288,397 @@ public class TheMovieDbApi {
* @throws MovieDbException
*/
public Person getPersonLatest() throws MovieDbException {
- URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.LATEST).buildUrl();
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, Person.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get latest person: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ return tmdbPeople.getPersonLatest();
}
//
- //
+ //
/**
- * This method is used to retrieve the basic information about a production company on TMDb.
*
- * @param companyId
- * @return
- * @throws MovieDbException
+ * @param reviewId
+ * @return @throws MovieDbException
*/
- public Company getCompanyInfo(int companyId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, companyId);
-
- URL url = new ApiUrl(apiKey, MethodBase.COMPANY).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, Company.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get company information: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public Review getReviews(String reviewId) throws MovieDbException {
+ return tmdbReviews.getReview(reviewId);
}
+ //
+ //
/**
- * This method is used to retrieve the movies associated with a company.
+ * Search Companies.
*
- * These movies are returned in order of most recently released to oldest. The default response will return 20 movies per page.
+ * You can use this method to search for production companies that are part
+ * of TMDb. The company IDs will map to those returned on movie calls.
*
- * TODO: Implement more than 20 movies
+ * http://help.themoviedb.org/kb/api/search-companies
*
- * @param companyId
- * @param language
+ * @param query
* @param page
* @return
* @throws MovieDbException
*/
- public TmdbResultsList getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, companyId);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.COMPANY).setSubMethod(MethodSub.MOVIES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperCompanyMovies wrapper = mapper.readValue(webpage, WrapperCompanyMovies.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getResults());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get company movies: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList searchCompanies(String query, Integer page) throws MovieDbException {
+ return tmdbSearch.searchCompanies(query, page);
}
- //
- //
/**
- * You can use this method to retrieve the list of genres used on TMDb.
- *
- * These IDs will correspond to those found in movie calls.
+ * Search for collections by name.
*
+ * @param query
* @param language
+ * @param page
* @return
* @throws MovieDbException
*/
- public TmdbResultsList getGenreList(String language) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.LANGUAGE, language);
-
- URL url = new ApiUrl(apiKey, MethodBase.GENRE).setSubMethod(MethodSub.LIST).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperGenres wrapper = mapper.readValue(webpage, WrapperGenres.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getGenres());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get genre list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList searchCollection(String query, Integer page, String language) throws MovieDbException {
+ return tmdbSearch.searchCollection(query, page, language);
}
/**
- * Get a list of movies per genre.
- *
- * It is important to understand that only movies with more than 10 votes get listed.
- *
- * This prevents movies from 1 10/10 rating from being listed first and for the first 5 pages.
+ * Search for keywords by name
*
- * @param genreId
- * @param language
+ * @param query
* @param page
- * @param includeAllMovies
* @return
* @throws MovieDbException
*/
- public TmdbResultsList getGenreMovies(int genreId, String language, int page, boolean includeAllMovies) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, genreId);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.PAGE, page);
- parameters.add(Param.INCLUDE_ALL_MOVIES, includeAllMovies);
-
- URL url = new ApiUrl(apiKey, MethodBase.GENRE).setSubMethod(MethodSub.MOVIES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
+ public TmdbResultsList searchKeyword(String query, Integer page) throws MovieDbException {
+ return tmdbSearch.searchKeyword(query, page);
+ }
- try {
- WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getMovies());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get genre movie list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ /**
+ * Search for lists by name and description.
+ *
+ * @param query
+ * @param includeAdult
+ * @param page
+ * @return
+ * @throws MovieDbException
+ */
+ public TmdbResultsList searchList(String query, Integer page, Boolean includeAdult) throws MovieDbException {
+ return tmdbSearch.searchList(query, page, includeAdult);
}
- //
- //
/**
- * Search Movies This is a good starting point to start finding movies on TMDb.
+ * Search Movies This is a good starting point to start finding movies on
+ * TMDb.
*
- * @param movieName
- * @param searchYear Limit the search to the provided year. Zero (0) will get all years
+ * @param query
+ * @param searchYear Limit the search to the provided year. Zero (0) will
+ * get all years
* @param language The language to include. Can be blank/null.
* @param includeAdult true or false to include adult titles in the search
- * @param page The page of results to return. 0 to get the default (first page)
+ * @param page The page of results to return. 0 to get the default (first
+ * page)
+ * @param primaryReleaseYear
+ * @param searchType
* @return
* @throws MovieDbException
*/
- public TmdbResultsList searchMovie(String movieName, int searchYear, String language, boolean includeAdult, int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.QUERY, movieName);
- parameters.add(Param.YEAR, searchYear);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.ADULT, includeAdult);
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.SEARCH).setSubMethod(MethodSub.MOVIE).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getMovies());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to find movie: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
-
+ public TmdbResultsList searchMovie(String query,
+ Integer page,
+ String language,
+ Boolean includeAdult,
+ Integer searchYear,
+ Integer primaryReleaseYear,
+ SearchType searchType) throws MovieDbException {
+ return tmdbSearch.searchMovie(query, page, language, includeAdult, searchYear, primaryReleaseYear, searchType);
}
/**
- * Search for collections by name.
+ * Search the movie, tv show and person collections with a single query.
+ *
+ * Each item returned in the result array has a media_type field that maps
+ * to either movie, tv or person.
+ *
+ * Each mapped result is the same response you would get from each
+ * independent search
*
* @param query
- * @param language
* @param page
+ * @param language
+ * @param includeAdult
* @return
* @throws MovieDbException
*/
- public TmdbResultsList searchCollection(String query, String language, int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.QUERY, query);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.SEARCH).setSubMethod(MethodSub.COLLECTION).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperCollection wrapper = mapper.readValue(webpage, WrapperCollection.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getResults());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to find collection: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList searchMulti(String query, Integer page, String language, Boolean includeAdult) throws MovieDbException {
+ return tmdbSearch.searchMulti(query, page, language, includeAdult);
}
/**
* This is a good starting point to start finding people on TMDb.
*
- * The idea is to be a quick and light method so you can iterate through people quickly.
+ * The idea is to be a quick and light method so you can iterate through
+ * people quickly.
*
- * @param personName
+ * @param query
* @param includeAdult
* @param page
+ * @param searchType
* @return
* @throws MovieDbException
*/
- public TmdbResultsList searchPeople(String personName, boolean includeAdult, int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.QUERY, personName);
- parameters.add(Param.ADULT, includeAdult);
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.SEARCH).setSubMethod(MethodSub.PERSON).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperPerson wrapper = mapper.readValue(webpage, WrapperPerson.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getResults());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to find person: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList searchPeople(String query, Integer page, Boolean includeAdult, SearchType searchType) throws MovieDbException {
+ return tmdbSearch.searchPeople(query, page, includeAdult, searchType);
}
/**
- * Search for lists by name and description.
+ * Search for TV shows by title.
*
* @param query
- * @param language
* @param page
+ * @param language
+ * @param firstAirDateYear
+ * @param searchType
* @return
- * @throws MovieDbException
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public TmdbResultsList searchList(String query, String language, int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.QUERY, query);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.SEARCH).setSubMethod(MethodSub.LIST).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getMovieList());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to find list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList searchTV(String query, Integer page, String language, Integer firstAirDateYear, SearchType searchType) throws MovieDbException {
+ return tmdbSearch.searchTV(query, page, language, firstAirDateYear, searchType);
}
+ //
+ //
/**
- * Search Companies.
- *
- * You can use this method to search for production companies that are part of TMDb. The company IDs will map to those returned
- * on movie calls.
- *
- * http://help.themoviedb.org/kb/api/search-companies
+ * Get the primary information about a TV series by id.
*
- * @param companyName
- * @param page
+ * @param tvID
+ * @param language
+ * @param appendToResponse
* @return
- * @throws MovieDbException
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public TmdbResultsList searchCompanies(String companyName, int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.QUERY, companyName);
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.SEARCH).setSubMethod(MethodSub.COMPANY).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getResults());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to find company: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TVInfo getTVInfo(int tvID, String language, String... appendToResponse) throws MovieDbException {
+ return tmdbTv.getTVInfo(tvID, language, appendToResponse);
}
/**
- * Search for keywords by name
+ * This method lets users get the status of whether or not the TV show has
+ * been rated or added to their favourite or watch lists.
*
- * @param query
- * @param page
+ * A valid session id is required.
+ *
+ * @param tvID
+ * @param sessionID
* @return
- * @throws MovieDbException
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public TmdbResultsList searchKeyword(String query, int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.QUERY, query);
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.SEARCH).setSubMethod(MethodSub.KEYWORD).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperKeywords wrapper = mapper.readValue(webpage, WrapperKeywords.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getResults());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to find keyword: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public MediaState getTVAccountState(int tvID, String sessionID) throws MovieDbException {
+ return tmdbTv.getTVAccountState(tvID, sessionID);
}
- //
- //
/**
- * Get a list by its ID
+ * Get the alternative titles for a specific show ID.
*
- * @param listId
- * @return The list and its items
- * @throws MovieDbException
+ * @param tvID
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public MovieDbList getList(String listId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, listId);
-
- URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, MovieDbList.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList getTVAlternativeTitles(int tvID) throws MovieDbException {
+ return tmdbTv.getTVAlternativeTitles(tvID);
}
/**
- * Get all lists of a given user
+ * Get the changes for a specific TV show id.
*
- * @param sessionId
- * @param accountID
- * @return The lists
- * @throws MovieDbException
+ * @param tvID
+ * @param startDate
+ * @param endDate
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public List getUserLists(String sessionId, int accountID) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
-
- URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountID, MethodSub.LISTS).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, WrapperMovieDbList.class).getLists();
- } catch (IOException ex) {
- LOG.warn("Failed to get user list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public WrapperChanges getTVChanges(int tvID, String startDate, String endDate) throws MovieDbException {
+ return tmdbTv.getTVChanges(tvID, startDate, endDate);
}
/**
- * This method lets users create a new list. A valid session id is required.
+ * Get the content ratings for a specific TV show id.
*
- * @param sessionId
- * @param name
- * @param description
- * @return The list id
- * @throws MovieDbException
+ * @param tvID
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public String createList(String sessionId, String name, String description) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
-
- Map body = new HashMap();
- body.put("name", StringUtils.trimToEmpty(name));
- body.put("description", StringUtils.trimToEmpty(description));
- String jsonBody = convertToJson(body);
-
- URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters);
- String webpage = httpTools.postRequest(url, jsonBody);
-
- try {
- return mapper.readValue(webpage, MovieDbListStatus.class).getListId();
- } catch (IOException ex) {
- LOG.warn("Failed to create list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList getTVContentRatings(int tvID) throws MovieDbException {
+ return tmdbTv.getTVContentRatings(tvID);
}
/**
- * Check to see if a movie ID is already added to a list.
+ * Get the cast & crew information about a TV series.
*
- * @param listId
- * @param movieId
- * @return true if the movie is on the list
- * @throws MovieDbException
+ * @param tvID
+ * @param language
+ * @param appendToResponse
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public boolean isMovieOnList(String listId, Integer movieId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, movieId);
-
- URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(listId, MethodSub.ITEM_STATUS).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, ListItemStatus.class).isItemPresent();
- } catch (IOException ex) {
- LOG.warn("Failed to get item status: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public MediaCreditList getTVCredits(int tvID, String language, String... appendToResponse) throws MovieDbException {
+ return tmdbTv.getTVCredits(tvID, language, appendToResponse);
}
/**
- * This method lets users add new movies to a list that they created. A valid session id is required.
+ * Get the external ids that we have stored for a TV series.
*
- * @param sessionId
- * @param listId
- * @param movieId
- * @return true if the movie is on the list
- * @throws MovieDbException
+ * @param tvID
+ * @param language
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public StatusCode addMovieToList(String sessionId, String listId, Integer movieId) throws MovieDbException {
- return modifyMovieList(sessionId, listId, movieId, MethodSub.ADD_ITEM);
+ public ExternalID getTVExternalIDs(int tvID, String language) throws MovieDbException {
+ return tmdbTv.getTVExternalIDs(tvID, language);
}
/**
- * This method lets users remove movies from a list that they created. A valid session id is required.
+ * Get the images (posters and backdrops) for a TV series.
*
- * @param sessionId
- * @param listId
- * @param movieId
- * @return true if the movie is on the list
- * @throws MovieDbException
+ * @param tvID
+ * @param language
+ * @param includeImageLanguage
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public StatusCode removeMovieFromList(String sessionId, String listId, Integer movieId) throws MovieDbException {
- return modifyMovieList(sessionId, listId, movieId, MethodSub.REMOVE_ITEM);
+ public TmdbResultsList getTVImages(int tvID, String language, String... includeImageLanguage) throws MovieDbException {
+ return tmdbTv.getTVImages(tvID, language, includeImageLanguage);
}
- private StatusCode modifyMovieList(String sessionId, String listId, Integer movieId, MethodSub operation) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
-
- String jsonBody = convertToJson(Collections.singletonMap("media_id", String.valueOf(movieId)));
-
- URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(listId, operation).buildUrl(parameters);
- String webpage = httpTools.postRequest(url, jsonBody);
-
- try {
- return mapper.readValue(webpage, StatusCode.class);
- } catch (IOException ex) {
- LOG.warn("Failed to remove movie from list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ /**
+ * Get the plot keywords for a specific TV show id.
+ *
+ * @param tvID
+ * @param appendToResponse
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ public TmdbResultsList getTVKeywords(int tvID, String... appendToResponse) throws MovieDbException {
+ return tmdbTv.getTVKeywords(tvID, appendToResponse);
}
/**
- * Get the list of movies on an accounts watchlist.
+ * This method lets users rate a TV show.
*
- * @param sessionId
- * @param accountId
- * @return The watchlist of the user
- * @throws MovieDbException
+ * A valid session id or guest session id is required.
+ *
+ * @param tvID
+ * @param rating
+ * @param sessionID
+ * @param guestSessionID
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public List getWatchList(String sessionId, int accountId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.SESSION, sessionId);
-
- URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.MOVIE_WATCHLIST).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, WrapperMovie.class).getMovies();
- } catch (IOException ex) {
- LOG.warn("Failed to get watch list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public StatusCode postTVRating(int tvID, int rating, String sessionID, String guestSessionID) throws MovieDbException {
+ return tmdbTv.postTVRating(tvID, rating, sessionID, guestSessionID);
}
/**
- * This method lets users delete a list that they created. A valid session id is required.
+ * Get the similar TV shows for a specific tv id.
*
- * @param sessionId
- * @param listId
+ * @param tvID
+ * @param page
+ * @param language
+ * @param appendToResponse
* @return
- * @throws MovieDbException
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public StatusCode deleteMovieList(String sessionId, String listId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, listId);
- parameters.add(Param.SESSION, sessionId);
-
- URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters);
- String webpage = httpTools.deleteRequest(url);
-
- try {
- return mapper.readValue(webpage, StatusCode.class);
- } catch (IOException ex) {
- LOG.warn("Failed to delete movie list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList getTVSimilar(int tvID, Integer page, String language, String... appendToResponse) throws MovieDbException {
+ return tmdbTv.getTVSimilar(tvID, page, language, appendToResponse);
}
- //
- //
/**
- * Get the basic information for a specific keyword id.
+ * Get the list of translations that exist for a TV series. These
+ * translations cascade down to the episode level.
*
- * @param keywordId
+ * @param tvID
* @return
- * @throws MovieDbException
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public Keyword getKeyword(String keywordId) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, keywordId);
-
- URL url = new ApiUrl(apiKey, MethodBase.KEYWORD).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- return mapper.readValue(webpage, Keyword.class);
- } catch (IOException ex) {
- LOG.warn("Failed to get keyword: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
-
+ public TmdbResultsList getTVTranslations(int tvID) throws MovieDbException {
+ return tmdbTv.getTVTranslations(tvID);
}
/**
- * Get the list of movies for a particular keyword by id.
+ * Get the videos that have been added to a TV series (trailers, opening
+ * credits, etc...)
*
- * @param keywordId
+ * @param tvID
* @param language
- * @param page
- * @return List of movies with the keyword
- * @throws MovieDbException
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public TmdbResultsList getKeywordMovies(String keywordId, String language, int page) throws MovieDbException {
- TmdbParameters parameters = new TmdbParameters();
- parameters.add(Param.ID, keywordId);
- parameters.add(Param.LANGUAGE, language);
- parameters.add(Param.PAGE, page);
-
- URL url = new ApiUrl(apiKey, MethodBase.KEYWORD).setSubMethod(MethodSub.MOVIES).buildUrl(parameters);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperKeywordMovies wrapper = mapper.readValue(webpage, WrapperKeywordMovies.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getResults());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get keyword movies: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
-
+ public TmdbResultsList getTVVideos(int tvID, String language) throws MovieDbException {
+ return tmdbTv.getTVVideos(tvID, language);
}
- //
- //
/**
- * Get a list of movie ids that have been edited. By default we show the last 24 hours and only 100 items per page. The maximum
- * number of days that can be returned in a single request is 14. You can then use the movie changes API to get the actual data
- * that has been changed. Please note that the change log system to support this was changed on October 5, 2012 and will only
- * show movies that have been edited since.
+ * Get the latest TV show id.
*
- * @param page
- * @param startDate the start date of the changes, optional
- * @param endDate the end date of the changes, optional
- * @return List of changed movie
- * @throws MovieDbException
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public TmdbResultsList getMovieChangesList(int page, String startDate, String endDate) throws MovieDbException {
- TmdbParameters params = new TmdbParameters();
- params.add(Param.PAGE, page);
- params.add(Param.START_DATE, startDate);
- params.add(Param.END_DATE, endDate);
-
- URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.CHANGES).buildUrl(params);
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperMovieChanges wrapper = mapper.readValue(webpage, WrapperMovieChanges.class);
-
- TmdbResultsList results = new TmdbResultsList(wrapper.getResults());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get movie changes: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TVInfo getLatestTV() throws MovieDbException {
+ return tmdbTv.getLatestTV();
}
- public void getPersonChangesList(int page, String startDate, String endDate) throws MovieDbException {
- LOG.trace("getPersonChangesList: page: {}, start: {}, end: {}", page, startDate, endDate);
- throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Not implemented yet", "");
+ /**
+ * Get the list of TV shows that are currently on the air.
+ *
+ * This query looks for any TV show that has an episode with an air date in
+ * the next 7 days.
+ *
+ * @param page
+ * @param language
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ public TmdbResultsList getTVOnTheAir(Integer page, String language) throws MovieDbException {
+ return tmdbTv.getTVOnTheAir(page, language);
}
- //
- //
- public TmdbResultsList getJobs() throws MovieDbException {
- URL url = new ApiUrl(apiKey, MethodBase.JOB).setSubMethod(MethodSub.LIST).buildUrl();
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperJobList wrapper = mapper.readValue(webpage, WrapperJobList.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getJobs());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get job list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ /**
+ * Get the list of TV shows that air today.
+ *
+ * Without a specified timezone, this query defaults to EST
+ *
+ * @param page
+ * @param language
+ * @param timezone
+ * @return
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ public TmdbResultsList getTVAiringToday(Integer page, String language, String timezone) throws MovieDbException {
+ return tmdbTv.getTVAiringToday(page, language, timezone);
}
- //
- //
/**
- * Discover movies by different types of data like average rating, number of votes, genres and certifications.
- *
- * You can alternatively create a "discover" object and pass it to this method to cut out the requirement for all of these
- * parameters
- *
- * @param page Minimum value is 1
- * @param language ISO 639-1 code.
- * @param sortBy Available options are vote_average.desc, vote_average.asc, release_date.desc, release_date.asc,
- * popularity.desc, popularity.asc
- * @param includeAdult Toggle the inclusion of adult titles
- * @param year Filter the results release dates to matches that include this value
- * @param primaryReleaseYear Filter the results so that only the primary release date year has this value
- * @param voteCountGte Only include movies that are equal to, or have a vote count higher than this value
- * @param voteAverageGte Only include movies that are equal to, or have a higher average rating than this value
- * @param withGenres Only include movies with the specified genres. Expected value is an integer (the id of a genre). Multiple
- * values can be specified. Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR'.
- * @param releaseDateGte The minimum release to include. Expected format is YYYY-MM-DD
- * @param releaseDateLte The maximum release to include. Expected format is YYYY-MM-DD
- * @param certificationCountry Only include movies with certifications for a specific country. When this value is specified,
- * 'certificationLte' is required. A ISO 3166-1 is expected.
- * @param certificationLte Only include movies with this certification and lower. Expected value is a valid certification for
- * the specified 'certificationCountry'.
- * @param withCompanies Filter movies to include a specific company. Expected value is an integer (the id of a company). They
- * can be comma separated to indicate an 'AND' query.
- * @return
- * @throws MovieDbException
- */
- public TmdbResultsList getDiscover(int page, String language, String sortBy, boolean includeAdult, int year,
- int primaryReleaseYear, int voteCountGte, float voteAverageGte, String withGenres, String releaseDateGte,
- String releaseDateLte, String certificationCountry, String certificationLte, String withCompanies) throws MovieDbException {
-
- Discover discover = new Discover();
- discover.page(page)
- .language(language)
- .sortBy(sortBy)
- .includeAdult(includeAdult)
- .year(year)
- .primaryReleaseYear(primaryReleaseYear)
- .voteCountGte(voteCountGte)
- .voteAverageGte(voteAverageGte)
- .withGenres(withGenres)
- .releaseDateGte(releaseDateGte)
- .releaseDateLte(releaseDateLte)
- .certificationCountry(certificationCountry)
- .certificationLte(certificationLte)
- .withCompanies(withCompanies);
-
- return getDiscover(discover);
- }
-
- /**
- * Discover movies by different types of data like average rating, number of votes, genres and certifications.
+ * Get the list of top rated TV shows.
*
- * @param discover A discover object containing the search criteria required
+ * By default, this list will only include TV shows that have 2 or more
+ * votes.
+ *
+ * This list refreshes every day.
+ *
+ * @param page
+ * @param language
* @return
- * @throws MovieDbException
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public TmdbResultsList getDiscover(Discover discover) throws MovieDbException {
- URL url = new ApiUrl(apiKey, MethodBase.DISCOVER).setSubMethod(MethodSub.MOVIE).buildUrl(discover.getParams());
- String webpage = httpTools.getRequest(url);
-
- try {
- WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
- TmdbResultsList results = new TmdbResultsList(wrapper.getMovies());
- results.copyWrapper(wrapper);
- return results;
- } catch (IOException ex) {
- LOG.warn("Failed to get discover list: {}", ex.getMessage(), ex);
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
- }
+ public TmdbResultsList getTVTopRated(Integer page, String language) throws MovieDbException {
+ return tmdbTv.getTVTopRated(page, language);
}
- //
/**
- * Use Jackson to convert Map to JSON string.
+ * Get the list of popular TV shows. This list refreshes every day.
*
- * @param map
+ * @param page
+ * @param language
* @return
- * @throws MovieDbException
+ * @throws com.omertron.themoviedbapi.MovieDbException
*/
- public static String convertToJson(Map map) throws MovieDbException {
- try {
- return mapper.writeValueAsString(map);
- } catch (JsonProcessingException jpe) {
- throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "JSON conversion failed", "", jpe);
- }
+ public TmdbResultsList getTVPopular(Integer page, String language) throws MovieDbException {
+ return tmdbTv.getTVPopular(page, language);
}
+
+ //
+ //
+ //
+ //
+ //
}
diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/ArtworkType.java b/src/main/java/com/omertron/themoviedbapi/enumeration/ArtworkType.java
new file mode 100644
index 000000000..3ade5fcb8
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/enumeration/ArtworkType.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.enumeration;
+
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * ArtworkType enum List of the artwork types that are available
+ */
+public enum ArtworkType {
+
+ /**
+ * Poster artwork
+ */
+ POSTER,
+ /**
+ * Fanart/backdrop
+ */
+ BACKDROP,
+ /**
+ * Person image
+ */
+ PROFILE,
+ /**
+ * Still (Video image)
+ */
+ STILL;
+
+ /**
+ * Convert a string into an Enum type
+ *
+ * @param artworkType
+ * @return
+ * @throws IllegalArgumentException If type is not recognised
+ *
+ */
+ public static ArtworkType fromString(String artworkType) {
+ if (StringUtils.isNotBlank(artworkType)) {
+ try {
+ return ArtworkType.valueOf(artworkType.trim().toUpperCase());
+ } catch (IllegalArgumentException ex) {
+ throw new IllegalArgumentException("ArtworkType " + artworkType + " does not exist.", ex);
+ }
+ }
+ throw new IllegalArgumentException("ArtworkType must not be null");
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonType.java b/src/main/java/com/omertron/themoviedbapi/enumeration/CreditType.java
similarity index 80%
rename from src/main/java/com/omertron/themoviedbapi/model/PersonType.java
rename to src/main/java/com/omertron/themoviedbapi/enumeration/CreditType.java
index daf8816ee..72ffd3b31 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/PersonType.java
+++ b/src/main/java/com/omertron/themoviedbapi/enumeration/CreditType.java
@@ -17,17 +17,14 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.model;
+package com.omertron.themoviedbapi.enumeration;
/**
- * @author stuart.boston
+ *
+ * @author Stuart
*/
-public enum PersonType {
+public enum CreditType {
- // A member of the cast
CAST,
- // A member of the crew
- CREW,
- // No specific type
- PERSON
+ CREW;
}
diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/ExternalSource.java b/src/main/java/com/omertron/themoviedbapi/enumeration/ExternalSource.java
new file mode 100644
index 000000000..772e7255b
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/enumeration/ExternalSource.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.enumeration;
+
+/**
+ *
+ * @author Stuart
+ */
+public enum ExternalSource {
+
+ FREEBASE_ID,
+ FREEBASE_MID,
+ IMDB_ID,
+ TVDB_ID,
+ TVRAGE_ID;
+
+ public String getPropertyString() {
+ return this.name().toLowerCase();
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/MediaType.java b/src/main/java/com/omertron/themoviedbapi/enumeration/MediaType.java
new file mode 100644
index 000000000..839a41ed6
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/enumeration/MediaType.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.enumeration;
+
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Media type options
+ *
+ * @author Stuart
+ */
+public enum MediaType {
+
+ /**
+ * Movie media type
+ */
+ MOVIE,
+ /**
+ * TV Show media type
+ */
+ TV,
+ /**
+ * TV Episode media type
+ */
+ EPISODE;
+
+ /**
+ * Convert a string into an Enum type
+ *
+ * @param mediaType
+ * @return
+ * @throws IllegalArgumentException If type is not recognised
+ *
+ */
+ public static MediaType fromString(String mediaType) {
+ if (StringUtils.isNotBlank(mediaType)) {
+ try {
+ return MediaType.valueOf(mediaType.trim().toUpperCase());
+ } catch (IllegalArgumentException ex) {
+ throw new IllegalArgumentException("MediaType " + mediaType + " does not exist.", ex);
+ }
+ }
+ throw new IllegalArgumentException("MediaType must not be null");
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java b/src/main/java/com/omertron/themoviedbapi/enumeration/SearchType.java
similarity index 77%
rename from src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java
rename to src/main/java/com/omertron/themoviedbapi/enumeration/SearchType.java
index 091319f1a..c367bed08 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java
+++ b/src/main/java/com/omertron/themoviedbapi/enumeration/SearchType.java
@@ -17,17 +17,19 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.model;
+package com.omertron.themoviedbapi.enumeration;
/**
- * ArtworkType enum List of the artwork types that are available
+ *
+ * @author Stuart
*/
-public enum ArtworkType {
+public enum SearchType {
+
+ PHRASE,
+ NGRAM;
+
+ public String getPropertyString() {
+ return this.name().toLowerCase();
+ }
- // Poster artwork
- POSTER,
- // Fanart/backdrop
- BACKDROP,
- // Person image
- PROFILE
}
diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/SortBy.java b/src/main/java/com/omertron/themoviedbapi/enumeration/SortBy.java
new file mode 100644
index 000000000..b80de72d9
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/enumeration/SortBy.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.enumeration;
+
+public enum SortBy {
+
+ CREATED_AT_ASC,
+ CREATED_AT_DESC,
+ POPULARITY_ASC,
+ POPULARITY_DESC,
+ RELEASE_DATE_ASC,
+ RELEASE_DATE_DESC,
+ REVENUE_ASC,
+ REVENUE_DESC,
+ PRIMARY_RELEASE_DATE_ASC,
+ PRIMARY_RELEASE_DATE_DESC,
+ ORIGINAL_TITLE_ASC,
+ ORIGINAL_TITLE_DESC,
+ VOTE_AVERAGE_ASC,
+ VOTE_AVERAGE_DESC,
+ VOTE_COUNT_ASC,
+ VOTE_COUNT_DESC;
+
+ public String getPropertyString() {
+ return this.name().toLowerCase().replace("_asc", ".asc").replaceAll("_desc", ".desc");
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java
new file mode 100644
index 000000000..7766c4630
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.artwork.ArtworkMedia;
+import com.omertron.themoviedbapi.model.change.ChangeListItem;
+import com.omertron.themoviedbapi.model.collection.Collection;
+import com.omertron.themoviedbapi.model.company.Company;
+import com.omertron.themoviedbapi.model.keyword.Keyword;
+import com.omertron.themoviedbapi.model.list.UserList;
+import com.omertron.themoviedbapi.model.media.AlternativeTitle;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.model.movie.MovieDb;
+import com.omertron.themoviedbapi.model.person.ContentRating;
+import com.omertron.themoviedbapi.model.person.Person;
+import com.omertron.themoviedbapi.model.person.PersonFind;
+import com.omertron.themoviedbapi.model.review.Review;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import com.omertron.themoviedbapi.model.tv.TVInfo;
+import com.omertron.themoviedbapi.tools.HttpTools;
+import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.yamj.api.common.exception.ApiExceptionType;
+
+/**
+ * Abstract methods
+ *
+ * @author Stuart
+ */
+public class AbstractMethod {
+
+ // The API key to be used
+ protected final String apiKey;
+ // The HttpTools to use
+ protected final HttpTools httpTools;
+ // Jackson JSON configuration
+ protected static final ObjectMapper MAPPER = new ObjectMapper();
+ private static final Map TYPE_REFS = new HashMap();
+
+ static {
+ TYPE_REFS.put(MovieBasic.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(TVBasic.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(UserList.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(Company.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(Collection.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(Keyword.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(MovieDb.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(Person.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(PersonFind.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(Review.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(ChangeListItem.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(ArtworkMedia.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(ContentRating.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(TVInfo.class, new TypeReference>() {
+ });
+ TYPE_REFS.put(AlternativeTitle.class, new TypeReference>() {
+ });
+
+ }
+
+ /**
+ * Default constructor for the methods
+ *
+ * @param apiKey
+ * @param httpTools
+ */
+ public AbstractMethod(String apiKey, HttpTools httpTools) {
+ this.apiKey = apiKey;
+ this.httpTools = httpTools;
+ }
+
+ /**
+ * Helper function to get a pre-generated TypeReference for a class
+ *
+ * @param aClass
+ * @return
+ * @throws MovieDbException
+ */
+ protected static TypeReference getTypeReference(Class aClass) throws MovieDbException {
+ if (TYPE_REFS.containsKey(aClass)) {
+ return TYPE_REFS.get(aClass);
+ } else {
+ throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Class type reference for '" + aClass.getSimpleName() + "' not found!");
+ }
+ }
+
+ /**
+ * Process the wrapper list and return the results
+ *
+ * @param Type of list to process
+ * @param typeRef
+ * @param url URL of the page (Error output only)
+ * @param errorMessageSuffix Error message to output (Error output only)
+ * @return
+ * @throws MovieDbException
+ */
+ protected List processWrapperList(TypeReference typeRef, URL url, String errorMessageSuffix) throws MovieDbException {
+ WrapperGenericList val = processWrapper(typeRef, url, errorMessageSuffix);
+ return val.getResults();
+ }
+
+ /**
+ * Process the wrapper list and return the whole wrapper
+ *
+ * @param Type of list to process
+ * @param typeRef
+ * @param url URL of the page (Error output only)
+ * @param errorMessageSuffix Error message to output (Error output only)
+ * @return
+ * @throws MovieDbException
+ */
+ protected WrapperGenericList processWrapper(TypeReference typeRef, URL url, String errorMessageSuffix) throws MovieDbException {
+ String webpage = httpTools.getRequest(url);
+ try {
+ // Due to type erasure, this doesn't work
+ // TypeReference> typeRef = new TypeReference>() {};
+ return MAPPER.readValue(webpage, typeRef);
+ } catch (IOException ex) {
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get " + errorMessageSuffix, url, ex);
+ }
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java
new file mode 100644
index 000000000..7f5eab05c
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbAccount.java
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.enumeration.MediaType;
+import com.omertron.themoviedbapi.enumeration.SortBy;
+import com.omertron.themoviedbapi.model.StatusCode;
+import com.omertron.themoviedbapi.model.account.Account;
+import com.omertron.themoviedbapi.model.list.UserList;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import com.omertron.themoviedbapi.tools.ApiUrl;
+import com.omertron.themoviedbapi.tools.HttpTools;
+import com.omertron.themoviedbapi.tools.MethodBase;
+import com.omertron.themoviedbapi.tools.MethodSub;
+import com.omertron.themoviedbapi.tools.Param;
+import com.omertron.themoviedbapi.tools.PostBody;
+import com.omertron.themoviedbapi.tools.PostTools;
+import com.omertron.themoviedbapi.tools.TmdbParameters;
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import org.yamj.api.common.exception.ApiExceptionType;
+
+/**
+ * Class to hold the Account Methods
+ *
+ * @author stuart.boston
+ */
+public class TmdbAccount extends AbstractMethod {
+
+ /**
+ * Constructor
+ *
+ * @param apiKey
+ * @param httpTools
+ */
+ public TmdbAccount(String apiKey, HttpTools httpTools) {
+ super(apiKey, httpTools);
+ }
+
+ /**
+ * Get the basic information for an account. You will need to have a valid
+ * session id.
+ *
+ * @param sessionId
+ * @return
+ * @throws MovieDbException
+ */
+ public Account getAccount(String sessionId) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).buildUrl(parameters);
+ String webpage = httpTools.getRequest(url);
+
+ try {
+ return MAPPER.readValue(webpage, Account.class);
+ } catch (IOException ex) {
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Account", url, ex);
+ }
+ }
+
+ /**
+ * Get all lists of a given user
+ *
+ * @param sessionId
+ * @param accountId
+ * @return The lists
+ * @throws MovieDbException
+ */
+ public List getUserLists(String sessionId, int accountId) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.LISTS).buildUrl(parameters);
+ return processWrapperList(getTypeReference(UserList.class), url, "user list");
+ }
+
+ /**
+ * Get the list of favorite movies for an account.
+ *
+ * @param sessionId
+ * @param accountId
+ * @return
+ * @throws MovieDbException
+ */
+ public List getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.FAVORITE_MOVIES).buildUrl(parameters);
+ return processWrapperList(getTypeReference(MovieBasic.class), url, "favorite movies");
+ }
+
+ /**
+ * Get the list of favorite TV series for an account.
+ *
+ * @param sessionId
+ * @param accountId
+ * @return
+ * @throws MovieDbException
+ */
+ public List getFavoriteTv(String sessionId, int accountId) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.FAVORITE_TV).buildUrl(parameters);
+ return processWrapperList(getTypeReference(TVBasic.class), url, "favorite TV shows");
+ }
+
+ /**
+ * Add or remove a movie to an accounts favorite list.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param mediaType
+ * @param mediaId
+ * @param setFavorite
+ * @return
+ * @throws MovieDbException
+ */
+ public StatusCode modifyFavoriteStatus(String sessionId, int accountId, MediaType mediaType, int mediaId, boolean setFavorite) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+
+ String jsonBody = new PostTools()
+ .add(PostBody.MEDIA_TYPE, mediaType.toString().toLowerCase())
+ .add(PostBody.MEDIA_ID, mediaId)
+ .add(PostBody.FAVORITE, setFavorite)
+ .build();
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.FAVORITE).buildUrl(parameters);
+ String webpage = httpTools.postRequest(url, jsonBody);
+
+ try {
+ return MAPPER.readValue(webpage, StatusCode.class);
+ } catch (IOException ex) {
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to set favorite status", url, ex);
+ }
+ }
+
+ /**
+ * Get the list of rated movies (and associated rating) for an account.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param page
+ * @param sortBy
+ * @param language
+ * @return
+ * @throws MovieDbException
+ */
+ public List getRatedMovies(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+ parameters.add(Param.PAGE, page);
+ parameters.add(Param.SORT_BY, sortBy);
+ parameters.add(Param.LANGUAGE, language);
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.RATED_MOVIES).buildUrl(parameters);
+ return processWrapperList(getTypeReference(MovieBasic.class), url, "rated movies");
+ }
+
+ /**
+ * Get the list of rated TV shows (and associated rating) for an account.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param page
+ * @param sortBy
+ * @param language
+ * @return
+ * @throws MovieDbException
+ */
+ public List getRatedTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+ parameters.add(Param.PAGE, page);
+ parameters.add(Param.SORT_BY, sortBy);
+ parameters.add(Param.LANGUAGE, language);
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.RATED_TV).buildUrl(parameters);
+ return processWrapperList(getTypeReference(TVBasic.class), url, "rated TV shows");
+ }
+
+ /**
+ * Get the list of movies on an accounts watch list.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param page
+ * @param sortBy
+ * @param language
+ * @return The watch list of the user
+ * @throws MovieDbException
+ */
+ public List getWatchListMovie(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+ parameters.add(Param.PAGE, page);
+ parameters.add(Param.SORT_BY, sortBy);
+ parameters.add(Param.LANGUAGE, language);
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.WATCHLIST_MOVIES).buildUrl(parameters);
+ return processWrapperList(getTypeReference(MovieBasic.class), url, "movie watch list");
+ }
+
+ /**
+ * Get the list of movies on an accounts watch list.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param page
+ * @param sortBy
+ * @param language
+ * @return The watch list of the user
+ * @throws MovieDbException
+ */
+ public List getWatchListTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+ parameters.add(Param.PAGE, page);
+ parameters.add(Param.SORT_BY, sortBy);
+ parameters.add(Param.LANGUAGE, language);
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.WATCHLIST_TV).buildUrl(parameters);
+ return processWrapperList(getTypeReference(TVBasic.class), url, "TV watch list");
+ }
+
+ /**
+ * Add or remove a movie to an accounts watch list.
+ *
+ * @param sessionId
+ * @param accountId
+ * @param movieId
+ * @param mediaType
+ * @param addToWatchlist
+ * @return
+ * @throws MovieDbException
+ */
+ public StatusCode modifyWatchList(String sessionId, int accountId, MediaType mediaType, Integer movieId, boolean addToWatchlist) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.SESSION_ID, sessionId);
+ parameters.add(Param.ID, accountId);
+
+ String jsonBody = new PostTools()
+ .add(PostBody.MEDIA_TYPE, mediaType.toString().toLowerCase())
+ .add(PostBody.MEDIA_ID, movieId)
+ .add(PostBody.WATCHLIST, addToWatchlist)
+ .build();
+
+ URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.WATCHLIST).buildUrl(parameters);
+ String webpage = httpTools.postRequest(url, jsonBody);
+
+ try {
+ return MAPPER.readValue(webpage, StatusCode.class);
+ } catch (IOException ex) {
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to modify watch list", url, ex);
+ }
+ }
+
+ /**
+ * Get a list of rated movies for a specific guest session id.
+ *
+ * @param guestSessionId
+ * @param language
+ * @param page
+ * @param sortBy only CREATED_AT_ASC or CREATED_AT_DESC is supported
+ * @return
+ * @throws MovieDbException
+ */
+ public List getGuestRatedMovies(String guestSessionId, String language, Integer page, SortBy sortBy) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.ID, guestSessionId);
+ parameters.add(Param.LANGUAGE, language);
+ parameters.add(Param.PAGE, page);
+ if (sortBy != null) {
+ // Only created_at is supported
+ parameters.add(Param.SORT_BY, "created_at");
+
+ if (sortBy.getPropertyString().endsWith("asc")) {
+ parameters.add(Param.SORT_ORDER, "asc");
+ } else {
+ parameters.add(Param.SORT_ORDER, "desc");
+ }
+ }
+
+ URL url = new ApiUrl(apiKey, MethodBase.GUEST_SESSION).subMethod(MethodSub.RATED_MOVIES_GUEST).buildUrl(parameters);
+ return processWrapperList(getTypeReference(MovieBasic.class), url, "Guest Session Movies");
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbAuthentication.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbAuthentication.java
new file mode 100644
index 000000000..247cc7dec
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbAuthentication.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.authentication.TokenAuthorisation;
+import com.omertron.themoviedbapi.model.authentication.TokenSession;
+import com.omertron.themoviedbapi.tools.ApiUrl;
+import com.omertron.themoviedbapi.tools.HttpTools;
+import com.omertron.themoviedbapi.tools.MethodBase;
+import com.omertron.themoviedbapi.tools.MethodSub;
+import com.omertron.themoviedbapi.tools.Param;
+import com.omertron.themoviedbapi.tools.TmdbParameters;
+import java.io.IOException;
+import java.net.URL;
+import org.yamj.api.common.exception.ApiExceptionType;
+
+/**
+ * Class to hold the Authentication Methods
+ *
+ * @author stuart.boston
+ */
+public class TmdbAuthentication extends AbstractMethod {
+
+ /**
+ * Constructor
+ *
+ * @param apiKey
+ * @param httpTools
+ */
+ public TmdbAuthentication(String apiKey, HttpTools httpTools) {
+ super(apiKey, httpTools);
+ }
+
+ /**
+ * This method is used to generate a valid request token for user based authentication.
+ *
+ * A request token is required in order to request a session id.
+ *
+ * You can generate any number of request tokens but they will expire after 60 minutes.
+ *
+ * As soon as a valid session id has been created the token will be destroyed.
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public TokenAuthorisation getAuthorisationToken() throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ URL url = new ApiUrl(apiKey, MethodBase.AUTH).subMethod(MethodSub.TOKEN_NEW).buildUrl(parameters);
+
+ String webpage = httpTools.getRequest(url);
+
+ try {
+ return MAPPER.readValue(webpage, TokenAuthorisation.class);
+ } catch (IOException ex) {
+ throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, "Failed to get Authorisation Token", url, ex);
+ }
+ }
+
+ /**
+ * This method is used to generate a session id for user based authentication.
+ *
+ * A session id is required in order to use any of the write methods.
+ *
+ * @param token
+ * @return
+ * @throws MovieDbException
+ */
+ public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+
+ if (!token.getSuccess()) {
+ throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, "Authorisation token was not successful!");
+ }
+
+ parameters.add(Param.TOKEN, token.getRequestToken());
+ URL url = new ApiUrl(apiKey, MethodBase.AUTH).subMethod(MethodSub.SESSION_NEW).buildUrl(parameters);
+ String webpage = httpTools.getRequest(url);
+
+ try {
+ return MAPPER.readValue(webpage, TokenSession.class);
+ } catch (IOException ex) {
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Session Token", url, ex);
+ }
+ }
+
+ /**
+ * This method is used to generate a session id for user based authentication. User must provide their username and password
+ *
+ * A session id is required in order to use any of the write methods.
+ *
+ * @param token Session token
+ * @param username User's username
+ * @param password User's password
+ * @return
+ * @throws MovieDbException
+ */
+ public TokenAuthorisation getSessionTokenLogin(TokenAuthorisation token, String username, String password) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+
+ if (!token.getSuccess()) {
+ throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, "Authorisation token was not successful!");
+ }
+
+ parameters.add(Param.TOKEN, token.getRequestToken());
+ parameters.add(Param.USERNAME, username);
+ parameters.add(Param.PASSWORD, password);
+
+ URL url = new ApiUrl(apiKey, MethodBase.AUTH).subMethod(MethodSub.TOKEN_VALIDATE).buildUrl(parameters);
+ String webpage = httpTools.getRequest(url);
+
+ try {
+ return MAPPER.readValue(webpage, TokenAuthorisation.class);
+ } catch (IOException ex) {
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Session Token", url, ex);
+ }
+ }
+
+ /**
+ * This method is used to generate a guest session id.
+ *
+ * A guest session can be used to rate movies without having a registered TMDb user account.
+ *
+ * You should only generate a single guest session per user (or device) as you will be able to attach the ratings to a TMDb user
+ * account in the future.
+ *
+ * There are also IP limits in place so you should always make sure it's the end user doing the guest session actions.
+ *
+ * If a guest session is not used for the first time within 24 hours, it will be automatically discarded.
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public TokenSession getGuestSessionToken() throws MovieDbException {
+ URL url = new ApiUrl(apiKey, MethodBase.AUTH).subMethod(MethodSub.GUEST_SESSION).buildUrl();
+ String webpage = httpTools.getRequest(url);
+
+ try {
+ return MAPPER.readValue(webpage, TokenSession.class);
+ } catch (IOException ex) {
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Guest Session Token", url, ex);
+ }
+ }}
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbCertifications.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbCertifications.java
new file mode 100644
index 000000000..addd2a02e
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbCertifications.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.results.TmdbResultsMap;
+import com.omertron.themoviedbapi.tools.HttpTools;
+import java.util.List;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.omertron.themoviedbapi.model.Certification;
+import com.omertron.themoviedbapi.tools.ApiUrl;
+import com.omertron.themoviedbapi.tools.MethodBase;
+import com.omertron.themoviedbapi.tools.MethodSub;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+import org.yamj.api.common.exception.ApiExceptionType;
+
+/**
+ * Class to hold the Certification Methods
+ *
+ * @author stuart.boston
+ */
+public class TmdbCertifications extends AbstractMethod {
+
+ /**
+ * Constructor
+ *
+ * @param apiKey
+ * @param httpTools
+ */
+ public TmdbCertifications(String apiKey, HttpTools httpTools) {
+ super(apiKey, httpTools);
+ }
+
+ /**
+ * Get a list of movies certification.
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public TmdbResultsMap> getMoviesCertification() throws MovieDbException {
+ URL url = new ApiUrl(apiKey, MethodBase.CERTIFICATION).subMethod(MethodSub.MOVIE_LIST).buildUrl();
+ String webpage = httpTools.getRequest(url);
+
+ try {
+ JsonNode node = MAPPER.readTree(webpage);
+ Map> results = MAPPER.readValue(node.elements().next().traverse(), new TypeReference
@@ -379,8 +388,8 @@ public class MovieDb extends AbstractJsonMapping {
this.alternativeTitles = alternativeTitles;
}
- public void setCasts(WrapperMovieCasts casts) {
- this.casts = casts;
+ public void setCasts(MediaCreditList credits) {
+ this.casts = credits;
}
public void setImages(WrapperImages images) {
@@ -403,16 +412,19 @@ public class MovieDb extends AbstractJsonMapping {
this.translations = translations;
}
- public void setSimilarMovies(WrapperMovie similarMovies) {
- this.similarMovies = similarMovies;
+ @JsonSetter("similar_movies")
+ public void setSimilarMovies(WrapperGenericList similarMovies) {
+ this.similarMovies = similarMovies.getResults();
}
- public void setLists(WrapperMovieList lists) {
- this.lists = lists;
+ @JsonSetter("lists")
+ public void setLists(WrapperGenericList lists) {
+ this.lists = lists.getResults();
}
- public void setReviews(WrapperReviews reviews) {
- this.reviews = reviews;
+ @JsonSetter("reviews")
+ public void setReviews(WrapperGenericList reviews) {
+ this.reviews = reviews.getResults();
}
//
diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java b/src/main/java/com/omertron/themoviedbapi/model/movie/ProductionCompany.java
similarity index 90%
rename from src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java
rename to src/main/java/com/omertron/themoviedbapi/model/movie/ProductionCompany.java
index bd3e5e2f2..3da6fee9b 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/movie/ProductionCompany.java
@@ -17,9 +17,10 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.model;
+package com.omertron.themoviedbapi.model.movie;
import com.fasterxml.jackson.annotation.JsonRootName;
+import com.omertron.themoviedbapi.model.AbstractIdName;
/**
* @author stuart.boston
diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java b/src/main/java/com/omertron/themoviedbapi/model/movie/ProductionCountry.java
similarity index 95%
rename from src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java
rename to src/main/java/com/omertron/themoviedbapi/model/movie/ProductionCountry.java
index fa0cd54ba..b0c245945 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/movie/ProductionCountry.java
@@ -17,8 +17,9 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.model;
+package com.omertron.themoviedbapi.model.movie;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import org.apache.commons.lang3.builder.EqualsBuilder;
diff --git a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseInfo.java
similarity index 86%
rename from src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java
rename to src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseInfo.java
index 189b9a8a4..776c13b06 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseInfo.java
@@ -17,8 +17,9 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.model;
+package com.omertron.themoviedbapi.model.movie;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
@@ -39,6 +40,8 @@ public class ReleaseInfo extends AbstractJsonMapping {
private String certification;
@JsonProperty("release_date")
private String releaseDate;
+ @JsonProperty("primary")
+ private boolean primary;
public String getCertification() {
return certification;
@@ -64,6 +67,14 @@ public class ReleaseInfo extends AbstractJsonMapping {
this.releaseDate = releaseDate;
}
+ public boolean isPrimary() {
+ return primary;
+ }
+
+ public void setPrimary(boolean primary) {
+ this.primary = primary;
+ }
+
@Override
public boolean equals(Object obj) {
if (obj instanceof ReleaseInfo) {
@@ -72,6 +83,7 @@ public class ReleaseInfo extends AbstractJsonMapping {
.append(country, other.country)
.append(certification, other.certification)
.append(releaseDate, other.releaseDate)
+ .append(primary, other.primary)
.isEquals();
} else {
return false;
@@ -84,6 +96,7 @@ public class ReleaseInfo extends AbstractJsonMapping {
.append(country)
.append(certification)
.append(releaseDate)
+ .append(primary)
.toHashCode();
}
}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReviews.java b/src/main/java/com/omertron/themoviedbapi/model/network/Network.java
similarity index 66%
rename from src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReviews.java
rename to src/main/java/com/omertron/themoviedbapi/model/network/Network.java
index 0ffa79ee6..140fea951 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReviews.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/network/Network.java
@@ -17,28 +17,37 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.wrapper;
+package com.omertron.themoviedbapi.model.network;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Reviews;
-import java.io.Serializable;
-import java.util.List;
/**
- *
* @author stuart.boston
*/
-public class WrapperReviews extends AbstractWrapperAll implements Serializable {
+public class Network extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
- @JsonProperty("results")
- private List reviews;
- public List getReviews() {
- return reviews;
+ @JsonProperty("id")
+ private int id;
+ @JsonProperty("name")
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
}
- public void setReviews(List reviews) {
- this.reviews = reviews;
+ public String getName() {
+ return name;
}
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java b/src/main/java/com/omertron/themoviedbapi/model/person/ContentRating.java
similarity index 63%
rename from src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java
rename to src/main/java/com/omertron/themoviedbapi/model/person/ContentRating.java
index 2ff464822..68e405496 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/ContentRating.java
@@ -17,26 +17,35 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.wrapper;
+package com.omertron.themoviedbapi.model.person;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.MovieDb;
-import java.util.List;
/**
*
- * @author stuart.boston
+ * @author Stuart.Boston
*/
-public class WrapperCompanyMovies extends AbstractWrapperAll {
+public class ContentRating {
- @JsonProperty("results")
- private List results;
+ @JsonProperty("iso_3166_1")
+ private String language;
+ @JsonProperty("rating")
+ private String rating;
- public List getResults() {
- return results;
+ public String getLanguage() {
+ return language;
}
- public void setResults(List results) {
- this.results = results;
+ public void setLanguage(String language) {
+ this.language = language;
}
+
+ public String getRating() {
+ return rating;
+ }
+
+ public void setRating(String rating) {
+ this.rating = rating;
+ }
+
}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java b/src/main/java/com/omertron/themoviedbapi/model/person/CreditBasic.java
similarity index 51%
rename from src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java
rename to src/main/java/com/omertron/themoviedbapi/model/person/CreditBasic.java
index 192f7e437..2631ee0c6 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/CreditBasic.java
@@ -17,54 +17,59 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.model;
+package com.omertron.themoviedbapi.model.person;
import com.fasterxml.jackson.annotation.JsonProperty;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
+import com.fasterxml.jackson.annotation.JsonSetter;
+import com.omertron.themoviedbapi.enumeration.CreditType;
+import com.omertron.themoviedbapi.enumeration.MediaType;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
/**
- * @author Stuart
+ * @author stuart.boston
*/
-public class PersonCrew extends AbstractJsonMapping {
+public class CreditBasic extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
- /*
- * Properties
- */
+ private CreditType creditType;
+ private MediaType mediaType;
+
+ @JsonProperty("credit_id")
+ private String creditId;
@JsonProperty("id")
private int id;
+ @JsonProperty("poster_path")
+ private String posterPath;
+
+ //cast
+ @JsonProperty("character")
+ private String character;
+ //crew
@JsonProperty("department")
private String department;
@JsonProperty("job")
private String job;
- @JsonProperty("name")
- private String name;
- @JsonProperty("profile_path")
- private String profilePath;
- @JsonProperty("credit_id")
- private String creditId;
- public String getDepartment() {
- return department;
+ public CreditType getCreditType() {
+ return creditType;
}
- public int getId() {
- return id;
+ public void setCreditType(CreditType creditType) {
+ this.creditType = creditType;
}
- public String getJob() {
- return job;
+ public MediaType getMediaType() {
+ return mediaType;
}
- public String getName() {
- return name;
+ @JsonSetter("media_type")
+ public void setMediaType(String mediaType) {
+ this.mediaType = MediaType.fromString(mediaType);
}
- public String getProfilePath() {
- return profilePath;
+ public void setMediaType(MediaType mediaType) {
+ this.mediaType = mediaType;
}
public String getCreditId() {
@@ -75,49 +80,47 @@ public class PersonCrew extends AbstractJsonMapping {
this.creditId = creditId;
}
- public void setDepartment(String department) {
- this.department = StringUtils.trimToEmpty(department);
+ public int getId() {
+ return id;
}
public void setId(int id) {
this.id = id;
}
- public void setJob(String job) {
- this.job = StringUtils.trimToEmpty(job);
+ public String getPosterPath() {
+ return posterPath;
+ }
+
+ public void setPosterPath(String posterPath) {
+ this.posterPath = posterPath;
+ }
+
+ public String getCharacter() {
+ return character;
+ }
+
+ public void setCharacter(String character) {
+ this.character = character;
+ setCreditType(CreditType.CAST);
}
- public void setName(String name) {
- this.name = StringUtils.trimToEmpty(name);
+ public String getDepartment() {
+ return department;
}
- public void setProfilePath(String profilePath) {
- this.profilePath = StringUtils.trimToEmpty(profilePath);
+ public void setDepartment(String department) {
+ this.department = department;
+ setCreditType(CreditType.CREW);
}
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof PersonCrew) {
- final PersonCrew other = (PersonCrew) obj;
- return new EqualsBuilder()
- .append(id, other.id)
- .append(name, other.name)
- .append(department, other.department)
- .append(job, other.job)
- .isEquals();
- } else {
- return false;
- }
+ public String getJob() {
+ return job;
}
- @Override
- public int hashCode() {
- return new HashCodeBuilder()
- .append(id)
- .append(department)
- .append(job)
- .append(name)
- .append(profilePath)
- .toHashCode();
+ public void setJob(String job) {
+ this.job = job;
+ setCreditType(CreditType.CREW);
}
+
}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/CreditInfo.java b/src/main/java/com/omertron/themoviedbapi/model/person/CreditInfo.java
new file mode 100644
index 000000000..c8022df9c
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/CreditInfo.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.person;
+
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.tv.TVCredit;
+
+/**
+ * @author stuart.boston
+ */
+public class CreditInfo extends AbstractJsonMapping {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("credit_type")
+ private String creditType;
+ @JsonProperty("department")
+ private String department;
+ @JsonProperty("job")
+ private String job;
+ @JsonProperty("media_type")
+ private String mediaType;
+ @JsonProperty("person")
+ private PersonBasic person;
+ @JsonProperty("media")
+ private TVCredit media;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getCreditType() {
+ return creditType;
+ }
+
+ public void setCreditType(String creditType) {
+ this.creditType = creditType;
+ }
+
+ public String getDepartment() {
+ return department;
+ }
+
+ public void setDepartment(String department) {
+ this.department = department;
+ }
+
+ public String getJob() {
+ return job;
+ }
+
+ public void setJob(String job) {
+ this.job = job;
+ }
+
+ public String getMediaType() {
+ return mediaType;
+ }
+
+ public void setMediaType(String mediaType) {
+ this.mediaType = mediaType;
+ }
+
+ public PersonBasic getPerson() {
+ return person;
+ }
+
+ public void setPerson(PersonBasic person) {
+ this.person = person;
+ }
+
+ public TVCredit getMedia() {
+ return media;
+ }
+
+ public void setMedia(TVCredit media) {
+ this.media = media;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/CreditMovieBasic.java b/src/main/java/com/omertron/themoviedbapi/model/person/CreditMovieBasic.java
new file mode 100644
index 000000000..cd20d6718
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/CreditMovieBasic.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.person;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.enumeration.MediaType;
+
+/**
+ * @author stuart.boston
+ */
+public class CreditMovieBasic extends CreditBasic {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("adult")
+ private boolean adult;
+ @JsonProperty("original_title")
+ private String originalTitle;
+ @JsonProperty("release_date")
+ private String releaseDate;
+ @JsonProperty("title")
+ private String title;
+
+ public CreditMovieBasic() {
+ setMediaType(MediaType.MOVIE);
+ }
+
+ public boolean isAdult() {
+ return adult;
+ }
+
+ public void setAdult(boolean adult) {
+ this.adult = adult;
+ }
+
+ public String getOriginalTitle() {
+ return originalTitle;
+ }
+
+ public void setOriginalTitle(String originalTitle) {
+ this.originalTitle = originalTitle;
+ }
+
+ public String getReleaseDate() {
+ return releaseDate;
+ }
+
+ public void setReleaseDate(String releaseDate) {
+ this.releaseDate = releaseDate;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/CreditTVBasic.java b/src/main/java/com/omertron/themoviedbapi/model/person/CreditTVBasic.java
new file mode 100644
index 000000000..7703ea2fa
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/CreditTVBasic.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.person;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.enumeration.MediaType;
+
+/**
+ * @author stuart.boston
+ */
+public class CreditTVBasic extends CreditBasic {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("episode_count")
+ private int episodeCount;
+ @JsonProperty("first_air_date")
+ private String firstAirDate;
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("original_name")
+ private String originalName;
+
+ public CreditTVBasic() {
+ setMediaType(MediaType.TV);
+ }
+
+ public int getEpisodeCount() {
+ return episodeCount;
+ }
+
+ public void setEpisodeCount(int episodeCount) {
+ this.episodeCount = episodeCount;
+ }
+
+ public String getFirstAirDate() {
+ return firstAirDate;
+ }
+
+ public void setFirstAirDate(String firstAirDate) {
+ this.firstAirDate = firstAirDate;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOriginalName() {
+ return originalName;
+ }
+
+ public void setOriginalName(String originalName) {
+ this.originalName = originalName;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/ExternalID.java b/src/main/java/com/omertron/themoviedbapi/model/person/ExternalID.java
new file mode 100644
index 000000000..8f6cec73f
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/ExternalID.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.person;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
+
+/**
+ *
+ * @author Stuart
+ */
+public class ExternalID extends AbstractJsonMapping {
+
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("imdb_id")
+ private String imdbId;
+ @JsonProperty("freebase_mid")
+ private String freebaseMid;
+ @JsonProperty("freebase_id")
+ private String freebaseId;
+ @JsonProperty("tvdb_id")
+ private String tvdbId;
+ @JsonProperty("tvrage_id")
+ private String tvrageId;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getImdbId() {
+ return imdbId;
+ }
+
+ public void setImdbId(String imdbId) {
+ this.imdbId = imdbId;
+ }
+
+ public String getFreebaseMid() {
+ return freebaseMid;
+ }
+
+ public void setFreebaseMid(String freebaseMid) {
+ this.freebaseMid = freebaseMid;
+ }
+
+ public String getFreebaseId() {
+ return freebaseId;
+ }
+
+ public void setFreebaseId(String freebaseId) {
+ this.freebaseId = freebaseId;
+ }
+
+ public String getTvrageId() {
+ return tvrageId;
+ }
+
+ public void setTvrageId(String tvrageId) {
+ this.tvrageId = tvrageId;
+ }
+
+ public String getTvdbId() {
+ return tvdbId;
+ }
+
+ public void setTvdbId(String tvdbId) {
+ this.tvdbId = tvdbId;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/Person.java b/src/main/java/com/omertron/themoviedbapi/model/person/Person.java
new file mode 100644
index 000000000..30e6dd188
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/Person.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.person;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+/**
+ * @author stuart.boston
+ */
+public class Person extends PersonBasic {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("adult")
+ private boolean adult;
+ @JsonProperty("also_known_as")
+ private List alsoKnownAs;
+ @JsonProperty("biography")
+ private String biography;
+ @JsonProperty("birthday")
+ private String birthday;
+ @JsonProperty("deathday")
+ private String deathday;
+ @JsonProperty("homepage")
+ private String homepage;
+ @JsonProperty("imdb_id")
+ private String imdbId;
+ @JsonProperty("place_of_birth")
+ private String placeOfBirth;
+ @JsonProperty("popularity")
+ private float popularity;
+
+ public boolean isAdult() {
+ return adult;
+ }
+
+ public void setAdult(boolean adult) {
+ this.adult = adult;
+ }
+
+ public List getAlsoKnownAs() {
+ return alsoKnownAs;
+ }
+
+ public void setAlsoKnownAs(List alsoKnownAs) {
+ this.alsoKnownAs = alsoKnownAs;
+ }
+
+ public String getBiography() {
+ return biography;
+ }
+
+ public void setBiography(String biography) {
+ this.biography = biography;
+ }
+
+ public String getBirthday() {
+ return birthday;
+ }
+
+ public void setBirthday(String birthday) {
+ this.birthday = birthday;
+ }
+
+ public String getDeathday() {
+ return deathday;
+ }
+
+ public void setDeathday(String deathday) {
+ this.deathday = deathday;
+ }
+
+ public String getHomepage() {
+ return homepage;
+ }
+
+ public void setHomepage(String homepage) {
+ this.homepage = homepage;
+ }
+
+ public String getImdbId() {
+ return imdbId;
+ }
+
+ public void setImdbId(String imdbId) {
+ this.imdbId = imdbId;
+ }
+
+ public String getPlaceOfBirth() {
+ return placeOfBirth;
+ }
+
+ public void setPlaceOfBirth(String placeOfBirth) {
+ this.placeOfBirth = placeOfBirth;
+ }
+
+ public float getPopularity() {
+ return popularity;
+ }
+
+ public void setPopularity(float popularity) {
+ this.popularity = popularity;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/model/person/PersonBasic.java
similarity index 68%
rename from src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java
rename to src/main/java/com/omertron/themoviedbapi/model/person/PersonBasic.java
index 996c14636..604341582 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/PersonBasic.java
@@ -17,28 +17,25 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.wrapper;
+package com.omertron.themoviedbapi.model.person;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.MovieDb;
-import java.io.Serializable;
-import java.util.List;
+import com.omertron.themoviedbapi.model.AbstractIdName;
/**
- *
* @author stuart.boston
*/
-public class WrapperMovie extends AbstractWrapperAll implements Serializable {
+public class PersonBasic extends AbstractIdName {
private static final long serialVersionUID = 1L;
- @JsonProperty("results")
- private List movies;
+ @JsonProperty("profile_path")
+ private String profilePath;
- public List getMovies() {
- return movies;
+ public String getProfilePath() {
+ return profilePath;
}
- public void setMovies(List movies) {
- this.movies = movies;
+ public void setProfilePath(String profilePath) {
+ this.profilePath = profilePath;
}
}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/PersonCredits.java b/src/main/java/com/omertron/themoviedbapi/model/person/PersonCredits.java
new file mode 100644
index 000000000..ce5355349
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/PersonCredits.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.person;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSetter;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
+import java.util.List;
+
+/**
+ * @author stuart.boston
+ * @param
+ */
+public class PersonCredits extends AbstractJsonMapping {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("id")
+ private int id;
+ private List cast;
+ private List crew;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public List getCast() {
+ return cast;
+ }
+
+ @JsonSetter("cast")
+ public void setCast(List cast) {
+ this.cast = cast;
+ }
+
+ public List getCrew() {
+ return crew;
+ }
+
+ @JsonSetter("crew")
+ public void setCrew(List crew) {
+ this.crew = crew;
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/PersonCreditsMixIn.java b/src/main/java/com/omertron/themoviedbapi/model/person/PersonCreditsMixIn.java
new file mode 100644
index 000000000..a3fe866cb
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/PersonCreditsMixIn.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.person;
+
+import com.fasterxml.jackson.annotation.JsonSetter;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import java.util.List;
+
+/**
+ * Jackson mixin class to deserialize the combined credits
+ *
+ * @author Stuart.Boston
+ */
+public class PersonCreditsMixIn {
+
+ @JsonTypeInfo(
+ use = JsonTypeInfo.Id.NAME,
+ include = JsonTypeInfo.As.PROPERTY,
+ property = "media_type",
+ defaultImpl = CreditBasic.class
+ )
+ @JsonSubTypes({
+ @JsonSubTypes.Type(value = CreditMovieBasic.class, name = "movie"),
+ @JsonSubTypes.Type(value = CreditTVBasic.class, name = "tv")
+ })
+ @JsonSetter("cast")
+ public void setCast(List cast) {
+ // Mixin empty class
+ }
+
+ @JsonTypeInfo(
+ use = JsonTypeInfo.Id.NAME,
+ include = JsonTypeInfo.As.PROPERTY,
+ property = "media_type",
+ defaultImpl = CreditBasic.class
+ )
+ @JsonSubTypes({
+ @JsonSubTypes.Type(value = CreditMovieBasic.class, name = "movie"),
+ @JsonSubTypes.Type(value = CreditTVBasic.class, name = "tv")
+ })
+ @JsonSetter("crew")
+ public void setCrew(List crew) {
+ // Mixin empty class
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/PersonFind.java b/src/main/java/com/omertron/themoviedbapi/model/person/PersonFind.java
new file mode 100644
index 000000000..b5d04e7e0
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/person/PersonFind.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.person;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSetter;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.omertron.themoviedbapi.model.media.MediaBasic;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import com.omertron.themoviedbapi.model.tv.TVEpisodeBasic;
+import java.util.List;
+
+/**
+ * @author stuart.boston
+ */
+public class PersonFind extends PersonBasic {
+
+ private static final long serialVersionUID = 1L;
+ @JsonProperty("adult")
+ private Boolean adult;
+ @JsonProperty("popularity")
+ private Float popularity;
+ private List extends MediaBasic> knownFor;
+
+ public Boolean getAdult() {
+ return adult;
+ }
+
+ public void setAdult(Boolean adult) {
+ this.adult = adult;
+ }
+
+ public Float getPopularity() {
+ return popularity;
+ }
+
+ public void setPopularity(Float popularity) {
+ this.popularity = popularity;
+ }
+
+ public List extends MediaBasic> getKnownFor() {
+ return knownFor;
+ }
+
+ @JsonTypeInfo(
+ use = JsonTypeInfo.Id.NAME,
+ include = JsonTypeInfo.As.PROPERTY,
+ property = "media_type",
+ defaultImpl = MediaBasic.class
+ )
+ @JsonSubTypes({
+ @JsonSubTypes.Type(value = MovieBasic.class, name = "movie"),
+ @JsonSubTypes.Type(value = TVBasic.class, name = "tv"),
+ @JsonSubTypes.Type(value = TVEpisodeBasic.class, name = "episode")
+ })
+ @JsonSetter("known_for")
+ public void setKnownFor(List extends MediaBasic> knownFor) {
+ this.knownFor = knownFor;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/Reviews.java b/src/main/java/com/omertron/themoviedbapi/model/review/Review.java
similarity index 61%
rename from src/main/java/com/omertron/themoviedbapi/model/Reviews.java
rename to src/main/java/com/omertron/themoviedbapi/model/review/Review.java
index 13d78541d..a11986e69 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/Reviews.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/review/Review.java
@@ -17,26 +17,32 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.model;
+package com.omertron.themoviedbapi.model.review;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author Stuart
*/
-public class Reviews extends AbstractJsonMapping {
+public class Review extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
- /*
- * Properties
- */
@JsonProperty("id")
private String id;
@JsonProperty("author")
private String author;
@JsonProperty("content")
private String content;
+ @JsonProperty("iso_639_1")
+ private String langauage;
+ @JsonProperty("media_id")
+ private String mediaId;
+ @JsonProperty("media_title")
+ private String mediaTitle;
+ @JsonProperty("media_type")
+ private String mediaType;
@JsonProperty("url")
private String url;
@@ -44,31 +50,64 @@ public class Reviews extends AbstractJsonMapping {
return id;
}
+ public void setId(String id) {
+ this.id = id;
+ }
+
public String getAuthor() {
return author;
}
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
public String getContent() {
return content;
}
- public String getUrl() {
- return url;
+ public void setContent(String content) {
+ this.content = content;
}
- public void setId(String id) {
- this.id = id;
+ public String getLangauage() {
+ return langauage;
}
- public void setAuthor(String author) {
- this.author = author;
+ public void setLangauage(String langauage) {
+ this.langauage = langauage;
}
- public void setContent(String content) {
- this.content = content;
+ public String getMediaId() {
+ return mediaId;
+ }
+
+ public void setMediaId(String mediaId) {
+ this.mediaId = mediaId;
+ }
+
+ public String getMediaTitle() {
+ return mediaTitle;
+ }
+
+ public void setMediaTitle(String mediaTitle) {
+ this.mediaTitle = mediaTitle;
+ }
+
+ public String getMediaType() {
+ return mediaType;
+ }
+
+ public void setMediaType(String mediaType) {
+ this.mediaType = mediaType;
+ }
+
+ public String getUrl() {
+ return url;
}
public void setUrl(String url) {
this.url = url;
}
+
}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/tv/TVBasic.java b/src/main/java/com/omertron/themoviedbapi/model/tv/TVBasic.java
new file mode 100644
index 000000000..9e91d31cb
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/tv/TVBasic.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.tv;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.media.MediaBasic;
+import java.util.List;
+
+/**
+ * Basic TV information
+ *
+ * @author stuart.boston
+ */
+public class TVBasic extends MediaBasic {
+
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("original_name")
+ private String originalName;
+ @JsonProperty("first_air_date")
+ private String firstAirDate;
+ @JsonProperty("origin_country")
+ private List originCountry;
+ @JsonProperty("rating")
+ private float rating = -1f;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOriginalName() {
+ return originalName;
+ }
+
+ public void setOriginalName(String originalName) {
+ this.originalName = originalName;
+ }
+
+ public String getFirstAirDate() {
+ return firstAirDate;
+ }
+
+ public void setFirstAirDate(String firstAirDate) {
+ this.firstAirDate = firstAirDate;
+ }
+
+ public List getOriginCountry() {
+ return originCountry;
+ }
+
+ public void setOriginCountry(List originCountry) {
+ this.originCountry = originCountry;
+ }
+
+ public float getRating() {
+ return rating;
+ }
+
+ public void setRating(float rating) {
+ this.rating = rating;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/tv/TVCredit.java b/src/main/java/com/omertron/themoviedbapi/model/tv/TVCredit.java
new file mode 100644
index 000000000..fdaf30430
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/tv/TVCredit.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.tv;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.AbstractIdName;
+import java.util.List;
+
+/**
+ * TV Favorite information
+ *
+ * @author stuart.boston
+ */
+public class TVCredit extends AbstractIdName {
+
+ @JsonProperty("original_name")
+ private String originalName;
+ @JsonProperty("character")
+ private String character;
+ @JsonProperty("seasons")
+ private List seasons;
+ @JsonProperty("episodes")
+ private List episodes;
+
+ public String getOriginalName() {
+ return originalName;
+ }
+
+ public void setOriginalName(String originalName) {
+ this.originalName = originalName;
+ }
+
+ public String getCharacter() {
+ return character;
+ }
+
+ public void setCharacter(String character) {
+ this.character = character;
+ }
+
+ public List getSeasons() {
+ return seasons;
+ }
+
+ public void setSeasons(List seasons) {
+ this.seasons = seasons;
+ }
+
+ public List getEpisodes() {
+ return episodes;
+ }
+
+ public void setEpisodes(List episodes) {
+ this.episodes = episodes;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/tv/TVEpisodeBasic.java b/src/main/java/com/omertron/themoviedbapi/model/tv/TVEpisodeBasic.java
new file mode 100644
index 000000000..ebcd70c5d
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/tv/TVEpisodeBasic.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.tv;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.media.MediaBasic;
+
+/**
+ * TV Favorite information
+ *
+ * @author stuart.boston
+ */
+public class TVEpisodeBasic extends MediaBasic {
+
+ @JsonProperty("air_date")
+ private String airDate;
+ @JsonProperty("season_number")
+ private int seasonNumber;
+ @JsonProperty("episode_number")
+ private int episodeNumber;
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("overview")
+ private String overview;
+ @JsonProperty("still_path")
+ private String stillPath;
+ @JsonProperty("show_id")
+ private String showId;
+
+ public String getAirDate() {
+ return airDate;
+ }
+
+ public void setAirDate(String airDate) {
+ this.airDate = airDate;
+ }
+
+ public int getSeasonNumber() {
+ return seasonNumber;
+ }
+
+ public void setSeasonNumber(int seasonNumber) {
+ this.seasonNumber = seasonNumber;
+ }
+
+ public int getEpisodeNumber() {
+ return episodeNumber;
+ }
+
+ public void setEpisodeNumber(int episodeNumber) {
+ this.episodeNumber = episodeNumber;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOverview() {
+ return overview;
+ }
+
+ public void setOverview(String overview) {
+ this.overview = overview;
+ }
+
+ public String getStillPath() {
+ return stillPath;
+ }
+
+ public void setStillPath(String stillPath) {
+ this.stillPath = stillPath;
+ }
+
+ public String getShowId() {
+ return showId;
+ }
+
+ public void setShowId(String showId) {
+ this.showId = showId;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/tv/TVEpisodeInfo.java b/src/main/java/com/omertron/themoviedbapi/model/tv/TVEpisodeInfo.java
new file mode 100644
index 000000000..91fb96ce2
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/tv/TVEpisodeInfo.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.tv;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.media.MediaCreditCast;
+import com.omertron.themoviedbapi.model.media.MediaCreditCrew;
+import java.util.List;
+
+/**
+ * TV Episode information
+ *
+ * @author stuart.boston
+ */
+public class TVEpisodeInfo extends TVEpisodeBasic {
+
+ @JsonProperty("crew")
+ private List crew;
+ @JsonProperty("guest_stars")
+ private List guestStars;
+ @JsonProperty("production_code")
+ private String productionCode;
+
+ public List getCrew() {
+ return crew;
+ }
+
+ public void setCrew(List crew) {
+ this.crew = crew;
+ }
+
+ public List getGuestStars() {
+ return guestStars;
+ }
+
+ public void setGuestStars(List guestStars) {
+ this.guestStars = guestStars;
+ }
+
+ public String getProductionCode() {
+ return productionCode;
+ }
+
+ public void setProductionCode(String productionCode) {
+ this.productionCode = productionCode;
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/tv/TVInfo.java b/src/main/java/com/omertron/themoviedbapi/model/tv/TVInfo.java
new file mode 100644
index 000000000..afe694173
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/tv/TVInfo.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.tv;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.Genre;
+import com.omertron.themoviedbapi.model.movie.ProductionCompany;
+import com.omertron.themoviedbapi.model.network.Network;
+import com.omertron.themoviedbapi.model.person.PersonBasic;
+import java.util.List;
+
+/**
+ *
+ * @author Stuart
+ */
+public class TVInfo extends TVBasic {
+
+ @JsonProperty("created_by")
+ private List createdBy;
+ @JsonProperty("episode_run_time")
+ private List episodeRunTime;
+ @JsonProperty("genres")
+ private List genres;
+ @JsonProperty("homepage")
+ private String homepage;
+ @JsonProperty("in_production")
+ private boolean inProduction;
+ @JsonProperty("languages")
+ private List languages;
+ @JsonProperty("last_air_date")
+ private String lastAirDate;
+ @JsonProperty("networks")
+ private List networks;
+ @JsonProperty("number_of_episodes")
+ private int numberOfEpisodes;
+ @JsonProperty("number_of_seasons")
+ private int numberOfSeasons;
+ @JsonProperty("original_language")
+ private String originalLanguage;
+ @JsonProperty("overview")
+ private String overview;
+ @JsonProperty("production_companies")
+ private List productionCompanies;
+ @JsonProperty("seasons")
+ private List seasons;
+ @JsonProperty("status")
+ private String status;
+ @JsonProperty("type")
+ private String type;
+
+ public List getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(List createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public List getEpisodeRunTime() {
+ return episodeRunTime;
+ }
+
+ public void setEpisodeRunTime(List episodeRunTime) {
+ this.episodeRunTime = episodeRunTime;
+ }
+
+ public List getGenres() {
+ return genres;
+ }
+
+ public void setGenres(List genres) {
+ this.genres = genres;
+ }
+
+ public String getHomepage() {
+ return homepage;
+ }
+
+ public void setHomepage(String homepage) {
+ this.homepage = homepage;
+ }
+
+ public boolean isInProduction() {
+ return inProduction;
+ }
+
+ public void setInProduction(boolean inProduction) {
+ this.inProduction = inProduction;
+ }
+
+ public List getLanguages() {
+ return languages;
+ }
+
+ public void setLanguages(List languages) {
+ this.languages = languages;
+ }
+
+ public String getLastAirDate() {
+ return lastAirDate;
+ }
+
+ public void setLastAirDate(String lastAirDate) {
+ this.lastAirDate = lastAirDate;
+ }
+
+ public List getNetworks() {
+ return networks;
+ }
+
+ public void setNetworks(List networks) {
+ this.networks = networks;
+ }
+
+ public int getNumberOfEpisodes() {
+ return numberOfEpisodes;
+ }
+
+ public void setNumberOfEpisodes(int numberOfEpisodes) {
+ this.numberOfEpisodes = numberOfEpisodes;
+ }
+
+ public int getNumberOfSeasons() {
+ return numberOfSeasons;
+ }
+
+ public void setNumberOfSeasons(int numberOfSeasons) {
+ this.numberOfSeasons = numberOfSeasons;
+ }
+
+ public String getOriginalLanguage() {
+ return originalLanguage;
+ }
+
+ public void setOriginalLanguage(String originalLanguage) {
+ this.originalLanguage = originalLanguage;
+ }
+
+ public String getOverview() {
+ return overview;
+ }
+
+ public void setOverview(String overview) {
+ this.overview = overview;
+ }
+
+ public List getProductionCompanies() {
+ return productionCompanies;
+ }
+
+ public void setProductionCompanies(List productionCompanies) {
+ this.productionCompanies = productionCompanies;
+ }
+
+ public List getSeasons() {
+ return seasons;
+ }
+
+ public void setSeasons(List seasons) {
+ this.seasons = seasons;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/tv/TVSeasonBasic.java b/src/main/java/com/omertron/themoviedbapi/model/tv/TVSeasonBasic.java
new file mode 100644
index 000000000..ea81f41bf
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/tv/TVSeasonBasic.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.tv;
+
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * TV Favorite information
+ *
+ * @author stuart.boston
+ */
+public class TVSeasonBasic extends AbstractJsonMapping {
+
+ @JsonProperty("id")
+ private int id = -1;
+ @JsonProperty("air_date")
+ private String airDate;
+ @JsonProperty("poster_path")
+ private String posterPath;
+ @JsonProperty("season_number")
+ private int seasonNumber;
+ @JsonProperty("episode_count")
+ private int episodeCount = -1;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getAirDate() {
+ return airDate;
+ }
+
+ public void setAirDate(String airDate) {
+ this.airDate = airDate;
+ }
+
+ public String getPosterPath() {
+ return posterPath;
+ }
+
+ public void setPosterPath(String posterPath) {
+ this.posterPath = posterPath;
+ }
+
+ public int getSeasonNumber() {
+ return seasonNumber;
+ }
+
+ public void setSeasonNumber(int seasonNumber) {
+ this.seasonNumber = seasonNumber;
+ }
+
+ public int getEpisodeCount() {
+ return episodeCount;
+ }
+
+ public void setEpisodeCount(int episodeCount) {
+ this.episodeCount = episodeCount;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/tv/TVSeasonInfo.java b/src/main/java/com/omertron/themoviedbapi/model/tv/TVSeasonInfo.java
new file mode 100644
index 000000000..9da7cd5fc
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/tv/TVSeasonInfo.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model.tv;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+/**
+ * TV Season information
+ *
+ * @author stuart.boston
+ */
+public class TVSeasonInfo extends TVSeasonBasic {
+
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("overview")
+ private String overview;
+ @JsonProperty("episodes")
+ private List episodes;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOverview() {
+ return overview;
+ }
+
+ public void setOverview(String overview) {
+ this.overview = overview;
+ }
+
+ public List getEpisodes() {
+ return episodes;
+ }
+
+ public void setEpisodes(List episodes) {
+ this.episodes = episodes;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/results/TmdbResultsList.java b/src/main/java/com/omertron/themoviedbapi/results/TmdbResultsList.java
index f9b29e5f6..d6d7c422f 100644
--- a/src/main/java/com/omertron/themoviedbapi/results/TmdbResultsList.java
+++ b/src/main/java/com/omertron/themoviedbapi/results/TmdbResultsList.java
@@ -48,6 +48,10 @@ public final class TmdbResultsList extends AbstractResults {
this.results = results;
}
+ public boolean isEmpty() {
+ return results.isEmpty();
+ }
+
@Override
public int getTotalResults() {
if (super.getTotalResults() == 0) {
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java
index 48afc294b..f368011ba 100644
--- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java
@@ -23,8 +23,9 @@ import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
@@ -45,8 +46,16 @@ public class ApiUrl {
private static final String DELIMITER_SUBSEQUENT = "&";
// Properties
private final String apiKey;
- private final String method;
- private String submethod = StringUtils.EMPTY;
+ private final MethodBase method;
+ private MethodSub submethod = MethodSub.NONE;
+ private static final List IGNORE_PARAMS = new ArrayList();
+
+ static {
+ IGNORE_PARAMS.add(Param.ID);
+ IGNORE_PARAMS.add(Param.QUERY);
+ IGNORE_PARAMS.add(Param.SEASON_NUMBER);
+ IGNORE_PARAMS.add(Param.EPISODE_NUMBER);
+ }
/**
* Constructor for the simple API URL method without a sub-method
@@ -56,7 +65,7 @@ public class ApiUrl {
*/
public ApiUrl(String apiKey, MethodBase method) {
this.apiKey = apiKey;
- this.method = method.getValue();
+ this.method = method;
}
/**
@@ -65,106 +74,141 @@ public class ApiUrl {
* @param submethod
* @return
*/
- public ApiUrl setSubMethod(MethodSub submethod) {
- this.submethod = submethod.getValue();
+ public ApiUrl subMethod(MethodSub submethod) {
+ if (submethod != MethodSub.NONE) {
+ this.submethod = submethod;
+ }
return this;
}
/**
- * Add a sub-method that has an ID at the start
+ * Build the URL with the default parameters
*
- * @param someId
- * @param submethod
* @return
*/
- public ApiUrl setSubMethod(int someId, MethodSub submethod) {
- return setSubMethod(String.valueOf(someId), submethod);
+ public URL buildUrl() {
+ return buildUrl(new TmdbParameters());
}
/**
- * Add a sub-method that has an ID at the start
+ * Build the URL from the pre-created parameters.
*
- * @param someId
- * @param submethod
+ * @param params
* @return
*/
- public ApiUrl setSubMethod(String someId, MethodSub submethod) {
- StringBuilder sm = new StringBuilder(someId);
- sm.append("/");
- sm.append(submethod.getValue());
- this.submethod = sm.toString();
- return this;
+ public URL buildUrl(final TmdbParameters params) {
+ StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
+
+ LOG.trace("Method: '{}', Sub-method: '{}', Params: {}", method.getValue(), submethod.getValue(),
+ ToStringBuilder.reflectionToString(params, ToStringStyle.SHORT_PREFIX_STYLE));
+
+ // Get the start of the URL, substituting TV for the season or episode methods
+ if (method == MethodBase.SEASON || method == MethodBase.EPISODE) {
+ urlString.append(MethodBase.TV.getValue());
+ } else {
+ urlString.append(method.getValue());
+ }
+
+ // We have either a queury, or a ID request
+ if (params.has(Param.QUERY)) {
+ urlString.append(queryProcessing(params));
+ } else {
+ urlString.append(idProcessing(params));
+ }
+
+ urlString.append(otherProcessing(params));
+
+ try {
+ LOG.trace("URL: {}", urlString.toString());
+ return new URL(urlString.toString());
+ } catch (MalformedURLException ex) {
+ LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.getMessage());
+ return null;
+ }
}
/**
- * Build the URL with the default parameters
+ * Create the query based URL portion
*
+ * @param params
* @return
*/
- public URL buildUrl() {
- return buildUrl(new TmdbParameters());
+ private StringBuilder queryProcessing(TmdbParameters params) {
+ StringBuilder urlString = new StringBuilder();
+
+ // Append the suffix of the API URL
+ if (submethod != MethodSub.NONE) {
+ urlString.append("/").append(submethod.getValue());
+ }
+
+ // Append the key information
+ urlString.append(DELIMITER_FIRST)
+ .append(Param.API_KEY.getValue())
+ .append(apiKey);
+
+ // Append the search term
+ urlString.append(DELIMITER_SUBSEQUENT);
+ urlString.append(Param.QUERY.getValue());
+
+ String query = (String) params.get(Param.QUERY);
+
+ try {
+ urlString.append(URLEncoder.encode(query, "UTF-8"));
+ } catch (UnsupportedEncodingException ex) {
+ LOG.trace("Unable to encode query: '{}' trying raw.", query, ex);
+ // If we can't encode it, try it raw
+ urlString.append(query);
+ }
+
+ return urlString;
}
/**
- * Build the URL from the pre-created parameters.
+ * Create the ID based URL portion
*
* @param params
* @return
*/
- public URL buildUrl(final TmdbParameters params) {
- StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
+ private StringBuilder idProcessing(final TmdbParameters params) {
+ StringBuilder urlString = new StringBuilder();
- LOG.trace("Method: '{}', Sub-method: '{}', Params: {}", method, submethod,
- ToStringBuilder.reflectionToString(params, ToStringStyle.SHORT_PREFIX_STYLE));
-
- // Get the start of the URL
- urlString.append(method);
+ // Append the ID
+ if (params.has(Param.ID)) {
+ urlString.append("/").append(params.get(Param.ID));
+ }
- // We have either a queury, or a direct request
- if (params.has(Param.QUERY)) {
- // Append the suffix of the API URL
- if (StringUtils.isNotBlank(submethod)) {
- urlString.append("/").append(submethod);
- }
+ if (params.has(Param.SEASON_NUMBER)) {
+ urlString.append("/season/").append(params.get(Param.SEASON_NUMBER));
+ }
- // Append the key information
- urlString.append(DELIMITER_FIRST)
- .append(Param.API_KEY.getValue())
- .append(apiKey);
+ if (params.has(Param.EPISODE_NUMBER)) {
+ urlString.append("/episode/").append(params.get(Param.EPISODE_NUMBER));
+ }
- // Append the search term
- urlString.append(DELIMITER_SUBSEQUENT);
- urlString.append(Param.QUERY.getValue());
+ if (submethod != MethodSub.NONE) {
+ urlString.append("/").append(submethod.getValue());
+ }
- String query = (String) params.get(Param.QUERY);
+ // Append the key information
+ urlString.append(DELIMITER_FIRST)
+ .append(Param.API_KEY.getValue())
+ .append(apiKey);
- try {
- urlString.append(URLEncoder.encode(query, "UTF-8"));
- } catch (UnsupportedEncodingException ex) {
- LOG.trace("Unable to encode query: '{}' trying raw.", query, ex);
- // If we can't encode it, try it raw
- urlString.append(query);
- }
- } else {
- // Append the ID if provided
- if (params.has(Param.ID)) {
- urlString.append("/").append(params.get(Param.ID));
- }
-
- if (StringUtils.isNotBlank(submethod)) {
- urlString.append("/").append(submethod);
- }
+ return urlString;
+ }
- // Append the key information
- urlString.append(DELIMITER_FIRST)
- .append(Param.API_KEY.getValue())
- .append(apiKey);
- }
+ /**
+ * Create a string of the remaining parameters
+ *
+ * @param params
+ * @return
+ */
+ private StringBuilder otherProcessing(final TmdbParameters params) {
+ StringBuilder urlString = new StringBuilder();
- // Append remaining parameters
for (Map.Entry argEntry : params.getEntries()) {
// Skip the ID an QUERY params
- if (argEntry.getKey() == Param.ID || argEntry.getKey() == Param.QUERY) {
+ if (IGNORE_PARAMS.contains(argEntry.getKey())) {
continue;
}
@@ -172,13 +216,6 @@ public class ApiUrl {
.append(argEntry.getKey().getValue())
.append(argEntry.getValue());
}
-
- try {
- LOG.trace("URL: {}", urlString.toString());
- return new URL(urlString.toString());
- } catch (MalformedURLException ex) {
- LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.getMessage());
- return null;
- }
+ return urlString;
}
}
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java b/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
index 2f8b1e6ed..15f97ac5e 100644
--- a/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
@@ -26,17 +26,27 @@ public enum MethodBase {
ACCOUNT("account"),
AUTH("authentication"),
+ CERTIFICATION("certification"),
COLLECTION("collection"),
COMPANY("company"),
CONFIGURATION("configuration"),
+ CREDIT("credit"),
DISCOVER("discover"),
+ EPISODE("episode"),
+ FIND("find"),
GENRE("genre"),
+ GUEST_SESSION("guest_session"),
JOB("job"),
KEYWORD("keyword"),
LIST("list"),
MOVIE("movie"),
+ NETWORK("network"),
PERSON("person"),
- SEARCH("search");
+ REVIEW("review"),
+ SEARCH("search"),
+ SEASON("season"),
+ TIMEZONES("timezones"),
+ TV("tv");
private final String value;
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/MethodSub.java b/src/main/java/com/omertron/themoviedbapi/tools/MethodSub.java
index 8e54a1746..3733f8b95 100644
--- a/src/main/java/com/omertron/themoviedbapi/tools/MethodSub.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/MethodSub.java
@@ -24,14 +24,23 @@ import org.apache.commons.lang3.StringUtils;
public enum MethodSub {
+ NONE(""),
+ ACCOUNT_STATES("account_states"),
+ ADD_ITEM("add_item"),
+ AIRING_TODAY("airing_today"),
ALT_TITLES("alternative_titles"),
CASTS("casts"),
CHANGES("changes"),
+ CLEAR("clear"),
COLLECTION("collection"),
+ CONTENT_RATINGS("content_ratings"),
+ COMBINED_CREDITS("combined_credits"),
COMPANY("company"),
CREDITS("credits"),
+ EXTERNAL_IDS("external_ids"),
FAVORITE("favorite"),
- FAVORITE_MOVIES("favorite_movies"),
+ FAVORITE_MOVIES("favorite/movies"),
+ FAVORITE_TV("favorite/tv"),
GUEST_SESSION("guest_session/new"),
IMAGES("images"),
ITEM_STATUS("item_status"),
@@ -42,24 +51,35 @@ public enum MethodSub {
LISTS("lists"),
MOVIE("movie"),
MOVIES("movies"),
- MOVIE_WATCHLIST("movie_watchlist"),
+ MOVIE_CREDITS("movie_credits"),
+ MOVIE_LIST("movie/list"),
+ MULTI("multi"),
NOW_PLAYING("now-playing"),
+ ON_THE_AIR("on_the_air"),
PERSON("person"),
POPULAR("popular"),
RATED_MOVIES("rated/movies"),
+ RATED_MOVIES_GUEST("rated_movies"),
+ RATED_TV("rated/tv"),
RATING("rating"),
RELEASES("releases"),
+ REMOVE_ITEM("remove_item"),
REVIEWS("reviews"),
SESSION_NEW("session/new"),
- SIMILAR_MOVIES("similar_movies"),
+ SIMILAR("similar"),
+ TAGGED_IMAGES("tagged_images"),
TOKEN_NEW("token/new"),
TOKEN_VALIDATE("token/validate_with_login"),
- TOP_RATED("top-rated"),
+ TOP_RATED("top_rated"),
TRANSLATIONS("translations"),
+ TV("tv"),
+ TV_CREDITS("tv_credits"),
+ TV_LIST("tv/list"),
UPCOMING("upcoming"),
VIDEOS("videos"),
- ADD_ITEM("add_item"),
- REMOVE_ITEM("remove_item");
+ WATCHLIST("watchlist"),
+ WATCHLIST_MOVIES("watchlist/movies"),
+ WATCHLIST_TV("watchlist/tv");
private final String value;
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/Param.java b/src/main/java/com/omertron/themoviedbapi/tools/Param.java
index fb46d3e69..f145c69ea 100644
--- a/src/main/java/com/omertron/themoviedbapi/tools/Param.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/Param.java
@@ -32,35 +32,55 @@ public enum Param {
ADULT("include_adult="),
API_KEY("api_key="),
APPEND("append_to_response="),
+ CERTIFICATION("certification="),
+ CERTIFICATION_COUNTRY("certification_country="),
+ CERTIFICATION_LTE("certification.lte="),
+ CONFIRM("confirm="),
COUNTRY("country="),
END_DATE("end_date="),
+ EPISODE_NUMBER("episode_number="),
+ EXTERNAL_SOURCE("external_source="),
FAVORITE("favorite="),
+ FIRST_AIR_DATE_GTE("first_air_date.gte"),
+ FIRST_AIR_DATE_LTE("first_air_date.lte"),
+ FIRST_AIR_DATE_YEAR("first_air_date_year="),
+ GUEST_SESSION_ID("guest_session_id="),
ID("id="),
+ INCLUDE_ADULT("include_adult="),
INCLUDE_ALL_MOVIES("include_all_movies="),
+ INCLUDE_IMAGE_LANGUAGE("include_image_language="),
+ INCLUDE_VIDEO("include_video="),
LANGUAGE("language="),
+ MOVIE_ID("movie_id="),
MOVIE_WATCHLIST("movie_watchlist="),
PAGE("page="),
PASSWORD("password="),
+ PRIMARY_RELEASE_YEAR("primary_release_year="),
QUERY("query="),
- SESSION("session_id="),
+ RELEASE_DATE_GTE("release_date.gte="),
+ RELEASE_DATE_LTE("release_date.lte="),
+ SEARCH_TYPE("search_type="),
+ SEASON_NUMBER("season_number="),
+ SESSION_ID("session_id="),
+ SORT_BY("sort_by="),
+ SORT_ORDER("sort_order="),
START_DATE("start_date="),
+ TIMEZONE("timezone="),
TOKEN("request_token="),
USERNAME("username="),
VALUE("value="),
- YEAR("year="),
- /*
- * Discover parameters
- */
- CERTIFICATION_COUNTRY("certification_country="),
- CERTIFICATION_LTE("certification.lte="),
- PRIMARY_RELEASE_YEAR("primary_release_year="),
- RELEASE_DATE_GTE("release_date.gte="),
- RELEASE_DATE_LTE("release_date.lte="),
- SORT_BY("sort_by="),
VOTE_AVERAGE_GTE("vote_average.gte="),
+ VOTE_AVERAGE_LTE("vote_average.lte="),
VOTE_COUNT_GTE("vote_count.gte="),
+ VOTE_COUNT_LTE("vote_count.lte="),
+ WITH_CAST("with_cast="),
WITH_COMPANIES("with_companies="),
- WITH_GENRES("with_genres=");
+ WITH_CREW("with_crew="),
+ WITH_GENRES("with_genres="),
+ WITH_KEYWORDS("with_keywords="),
+ WITH_NETWORKS("with_networks="),
+ WITH_PEOPLE("with_people="),
+ YEAR("year=");
private final String value;
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java b/src/main/java/com/omertron/themoviedbapi/tools/PostBody.java
similarity index 60%
rename from src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java
rename to src/main/java/com/omertron/themoviedbapi/tools/PostBody.java
index ce3121ce3..e567de720 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/PostBody.java
@@ -17,26 +17,35 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.wrapper;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.KeywordMovie;
-import java.util.List;
+package com.omertron.themoviedbapi.tools;
/**
+ * List of values to use for the POST requests
*
- * @author stuart.boston
+ * @author Stuart.Boston
*/
-public class WrapperKeywordMovies extends AbstractWrapperAll {
+public enum PostBody {
+
+ MEDIA_ID("media_id"),
+ MEDIA_TYPE("media_type"),
+ FAVORITE("favorite"),
+ WATCHLIST("watchlist"),
+ NAME("name"),
+ DESCRIPTION("description"),
+ VALUE("value");
- @JsonProperty("results")
- private List results;
+ private final String value;
- public List getResults() {
- return results;
+ private PostBody(String value) {
+ this.value = value;
}
- public void setResults(List results) {
- this.results = results;
+ /**
+ * Get the URL parameter to use
+ *
+ * @return
+ */
+ public String getValue() {
+ return this.value;
}
}
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/PostTools.java b/src/main/java/com/omertron/themoviedbapi/tools/PostTools.java
new file mode 100644
index 000000000..c917f5d6b
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/tools/PostTools.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.tools;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.omertron.themoviedbapi.MovieDbException;
+import java.util.HashMap;
+import java.util.Map;
+import org.yamj.api.common.exception.ApiExceptionType;
+
+/**
+ *
+ * @author Stuart.Boston
+ */
+public class PostTools {
+
+ // Jackson JSON configuration
+ protected static final ObjectMapper MAPPER = new ObjectMapper();
+
+ private final Map values = new HashMap();
+
+ public PostTools() {
+ }
+
+ public PostTools add(PostBody key, Object value) {
+ values.put(key.getValue(), value);
+ return this;
+ }
+
+ public PostTools add(String key, Object value) {
+ values.put(key, value);
+ return this;
+ }
+
+ public String build() throws MovieDbException {
+ return convertToJson(values);
+ }
+
+ /**
+ * Use Jackson to convert Map to JSON string.
+ *
+ * @param map
+ * @return
+ * @throws MovieDbException
+ */
+ private String convertToJson(Map map) throws MovieDbException {
+ try {
+ return MAPPER.writeValueAsString(map);
+ } catch (JsonProcessingException ex) {
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "JSON conversion failed", "", ex);
+ }
+ }
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java b/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java
index 101914b4b..efedeebbf 100644
--- a/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java
@@ -56,8 +56,10 @@ public class TmdbParameters {
* @param key Parameter to add
* @param value The array value to use (will be converted into a comma separated list)
*/
- public void add(Param key, String[] value) {
- parameters.put(key, toList(value));
+ public void add(final Param key, final String[] value) {
+ if (value != null && value.length > 0) {
+ parameters.put(key, toList(value));
+ }
}
/**
@@ -66,7 +68,7 @@ public class TmdbParameters {
* @param key Parameter to add
* @param value The value to add (will be checked to ensure it's valid)
*/
- public void add(Param key, String value) {
+ public void add(final Param key, final String value) {
if (StringUtils.isNotBlank(value)) {
parameters.put(key, value);
}
@@ -78,8 +80,8 @@ public class TmdbParameters {
* @param key Parameter to add
* @param value The value to add (will be checked to ensure >0)
*/
- public void add(Param key, int value) {
- if (value > 0f) {
+ public void add(final Param key, final Integer value) {
+ if (value != null && value > 0) {
parameters.put(key, String.valueOf(value));
}
}
@@ -90,8 +92,8 @@ public class TmdbParameters {
* @param key Parameter to add
* @param value The value to add (will be checked to ensure >0)
*/
- public void add(Param key, float value) {
- if (value > 0) {
+ public void add(final Param key, final Float value) {
+ if (value != null && value > 0f) {
parameters.put(key, String.valueOf(value));
}
}
@@ -102,8 +104,10 @@ public class TmdbParameters {
* @param key Parameter to add
* @param value The value to add (will be checked to ensure >0)
*/
- public void add(Param key, boolean value) {
- parameters.put(key, String.valueOf(value));
+ public void add(final Param key, final Boolean value) {
+ if (value != null) {
+ parameters.put(key, String.valueOf(value));
+ }
}
/**
@@ -112,7 +116,7 @@ public class TmdbParameters {
* @param key The Parameter to check
* @return
*/
- public boolean has(Param key) {
+ public boolean has(final Param key) {
return parameters.containsKey(key);
}
@@ -122,7 +126,7 @@ public class TmdbParameters {
* @param key The parameter to get
* @return
*/
- public Object get(Param key) {
+ public Object get(final Param key) {
return parameters.get(key);
}
@@ -131,7 +135,7 @@ public class TmdbParameters {
*
* @param key
*/
- public void remove(Param key) {
+ public void remove(final Param key) {
parameters.remove(key);
}
@@ -159,7 +163,7 @@ public class TmdbParameters {
* @param appendToResponse
* @return
*/
- public String toList(String[] appendToResponse) {
+ public String toList(final String[] appendToResponse) {
StringBuilder sb = new StringBuilder();
if (appendToResponse.length > 0) {
boolean first = Boolean.TRUE;
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java
index b4ff2f086..5df2c69a5 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.AlternativeTitle;
+import com.omertron.themoviedbapi.model.media.AlternativeTitle;
import java.io.Serializable;
import java.util.List;
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java
index 209af3a58..9997d025b 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java
@@ -19,22 +19,15 @@
*/
package com.omertron.themoviedbapi.wrapper;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.ChangeKeyItem;
+import com.omertron.themoviedbapi.model.change.ChangeKeyItem;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-public class WrapperChanges {
+public class WrapperChanges extends AbstractWrapper {
@JsonProperty("changes")
private List changedItems = new ArrayList();
- private final Map newItems = new HashMap();
public List getChangedItems() {
return changedItems;
@@ -44,18 +37,4 @@ public class WrapperChanges {
this.changedItems = changes;
}
- @JsonAnyGetter
- public Map getNewItems() {
- return this.newItems;
- }
-
- @JsonAnySetter
- public void setNewItems(String name, Object value) {
- this.newItems.put(name, value);
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
- }
}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java
index 1fa55210a..98be2fae6 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.TmdbConfiguration;
+import com.omertron.themoviedbapi.model.config.Configuration;
import java.util.Collections;
import java.util.List;
@@ -31,15 +31,15 @@ import java.util.List;
public class WrapperConfig extends AbstractWrapper {
@JsonProperty("images")
- private TmdbConfiguration tmdbConfiguration;
+ private Configuration tmdbConfiguration;
@JsonProperty("change_keys")
private List changeKeys = Collections.emptyList();
- public TmdbConfiguration getTmdbConfiguration() {
+ public Configuration getTmdbConfiguration() {
return tmdbConfiguration;
}
- public void setTmdbConfiguration(TmdbConfiguration tmdbConfiguration) {
+ public void setTmdbConfiguration(Configuration tmdbConfiguration) {
this.tmdbConfiguration = tmdbConfiguration;
}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenericList.java
similarity index 62%
rename from src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java
rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenericList.java
index cccf68a51..c56255bd6 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenericList.java
@@ -19,24 +19,35 @@
*/
package com.omertron.themoviedbapi.wrapper;
+import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Collection;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import java.io.Serializable;
import java.util.List;
/**
+ * Generic wrapper for result lists
*
- * @author stuart.boston
+ * @author Stuart
+ * @param
*/
-public class WrapperCollection extends AbstractWrapperAll {
+public class WrapperGenericList extends AbstractWrapperAll implements Serializable {
@JsonProperty("results")
- private List results;
+ private List results;
- public List getResults() {
+ public List getResults() {
return results;
}
- public void setResults(List results) {
+ @JsonCreator
+ public void setResults(List results) {
this.results = results;
}
+
+ public TmdbResultsList getTmdbResultsList() {
+ TmdbResultsList resultsList = new TmdbResultsList(results);
+ resultsList.copyWrapper(this);
+ return resultsList;
+ }
}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java
index f682e4a6e..72241c18b 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java
@@ -20,8 +20,8 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Artwork;
-import com.omertron.themoviedbapi.model.ArtworkType;
+import com.omertron.themoviedbapi.enumeration.ArtworkType;
+import com.omertron.themoviedbapi.model.artwork.Artwork;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -41,6 +41,8 @@ public class WrapperImages extends AbstractWrapperAll implements Serializable {
private List posters = Collections.emptyList();
@JsonProperty("profiles")
private List profiles = Collections.emptyList();
+ @JsonProperty("stills")
+ private List stills = Collections.emptyList();
public List getBackdrops() {
return backdrops;
@@ -66,6 +68,10 @@ public class WrapperImages extends AbstractWrapperAll implements Serializable {
this.profiles = profiles;
}
+ public void setStills(List stills) {
+ this.stills = stills;
+ }
+
/**
* Return a list of all the artwork with their types.
*
@@ -96,12 +102,18 @@ public class WrapperImages extends AbstractWrapperAll implements Serializable {
artwork.addAll(backdrops);
}
- // Add all the backdrops to the list
+ // Add all the profiles to the list
if (types.contains(ArtworkType.PROFILE)) {
updateArtworkType(profiles, ArtworkType.PROFILE);
artwork.addAll(profiles);
}
+ // Add all the stills to the list
+ if (types.contains(ArtworkType.STILL)) {
+ updateArtworkType(stills, ArtworkType.STILL);
+ artwork.addAll(stills);
+ }
+
return artwork;
}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperJobList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperJobList.java
index 9aec0ce35..1221b26a6 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperJobList.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperJobList.java
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.JobDepartment;
+import com.omertron.themoviedbapi.model.config.JobDepartment;
import java.util.List;
/**
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java
deleted file mode 100644
index eaabc34e9..000000000
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi.wrapper;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Keyword;
-import java.util.List;
-
-/**
- *
- * @author stuart.boston
- */
-public class WrapperKeywords extends AbstractWrapperAll {
-
- @JsonProperty("results")
- private List results;
-
- public List getResults() {
- return results;
- }
-
- public void setResults(List results) {
- this.results = results;
- }
-}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java
deleted file mode 100644
index b2f822a9c..000000000
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi.wrapper;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Person;
-import com.omertron.themoviedbapi.model.PersonCast;
-import com.omertron.themoviedbapi.model.PersonCrew;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * @author Stuart
- */
-public class WrapperMovieCasts extends AbstractWrapperId implements Serializable {
-
- private static final long serialVersionUID = 1L;
- @JsonProperty("cast")
- private List cast;
- @JsonProperty("crew")
- private List crew;
-
- public List getCast() {
- return cast;
- }
-
- public List getCrew() {
- return crew;
- }
-
- public void setCast(List cast) {
- this.cast = cast;
- }
-
- public void setCrew(List crew) {
- this.crew = crew;
- }
-
- public List getAll() {
- List people = new ArrayList();
-
- // Add a cast member
- for (PersonCast member : cast) {
- Person person = new Person();
- person.addCast(member.getId(), member.getName(), member.getProfilePath(), member.getCharacter(), member.getOrder());
- people.add(person);
- }
-
- // Add a crew member
- for (PersonCrew member : crew) {
- Person person = new Person();
- person.addCrew(member.getId(), member.getName(), member.getProfilePath(), member.getDepartment(), member.getJob());
- people.add(person);
- }
-
- return people;
- }
-}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieChanges.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieChanges.java
deleted file mode 100644
index 08980b1e4..000000000
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieChanges.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi.wrapper;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.ChangedMovie;
-
-public class WrapperMovieChanges extends AbstractWrapperAll {
-
- @JsonProperty("results")
- private List results;
-
- public List getResults() {
- return results;
- }
-
- public void setResults(List results) {
- this.results = results;
- }
-}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java
index 2937b26d8..a52a4955e 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Keyword;
+import com.omertron.themoviedbapi.model.keyword.Keyword;
import java.io.Serializable;
import java.util.List;
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java
deleted file mode 100644
index 6e9607e24..000000000
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi.wrapper;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.MovieList;
-import java.io.Serializable;
-import java.util.List;
-
-/**
- *
- * @author Stuart
- */
-public class WrapperMovieList extends AbstractWrapperAll implements Serializable {
-
- private static final long serialVersionUID = 1L;
- @JsonProperty("results")
- private List movieList;
-
- public List getMovieList() {
- return movieList;
- }
-
- public void setMovieList(List movieList) {
- this.movieList = movieList;
- }
-}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMultiSearch.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMultiSearch.java
new file mode 100644
index 000000000..7d92523fd
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMultiSearch.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.wrapper;
+
+import com.fasterxml.jackson.annotation.JsonSetter;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.omertron.themoviedbapi.model.media.MediaBasic;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import com.omertron.themoviedbapi.model.tv.TVEpisodeBasic;
+import java.util.List;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class WrapperMultiSearch extends AbstractWrapperAll {
+
+ private List extends MediaBasic> results;
+
+ public List extends MediaBasic> getResults() {
+ return results;
+ }
+
+ @JsonTypeInfo(
+ use = JsonTypeInfo.Id.NAME,
+ include = JsonTypeInfo.As.PROPERTY,
+ property = "media_type",
+ defaultImpl = MediaBasic.class
+ )
+ @JsonSubTypes({
+ @JsonSubTypes.Type(value = MovieBasic.class, name = "movie"),
+ @JsonSubTypes.Type(value = TVBasic.class, name = "tv"),
+ @JsonSubTypes.Type(value = TVEpisodeBasic.class, name = "episode")
+ })
+ @JsonSetter("results")
+ public void setResults(List extends MediaBasic> results) {
+ this.results = results;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java
deleted file mode 100644
index 90fa0902d..000000000
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi.wrapper;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Person;
-import java.util.List;
-
-/**
- *
- * @author stuart.boston
- */
-public class WrapperPerson extends AbstractWrapperAll {
-
- @JsonProperty("results")
- private List results;
-
- public List getResults() {
- return results;
- }
-
- public void setResults(List results) {
- this.results = results;
- }
-}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java
deleted file mode 100644
index d4aafdbbe..000000000
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi.wrapper;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.PersonCredit;
-import com.omertron.themoviedbapi.model.PersonType;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * @author stuart.boston
- */
-public class WrapperPersonCredits extends AbstractWrapperAll {
-
- @JsonProperty("cast")
- private List cast;
- @JsonProperty("crew")
- private List crew;
-
- public List getCast() {
- return cast;
- }
-
- public void setCast(List cast) {
- this.cast = cast;
- }
-
- public List getCrew() {
- return crew;
- }
-
- public void setCrew(List crew) {
- this.crew = crew;
- }
-
- public List getAll(PersonType... typeList) {
- List personCredits = new ArrayList();
- List types = getTypeList(PersonType.class, typeList);
-
- // Add a cast member
- if (types.contains(PersonType.CAST)) {
- for (PersonCredit member : cast) {
- member.setPersonType(PersonType.CAST);
- personCredits.add(member);
- }
- }
-
- // Add a crew member
- if (types.contains(PersonType.CREW)) {
- for (PersonCredit member : crew) {
- member.setPersonType(PersonType.CREW);
- personCredits.add(member);
- }
- }
-
- return personCredits;
- }
-}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonList.java
deleted file mode 100644
index 6bbe82279..000000000
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonList.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi.wrapper;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Person;
-import java.util.List;
-
-/**
- *
- * @author Stuart
- */
-public class WrapperPersonList extends AbstractWrapperAll {
-
- @JsonProperty("results")
- private List personList;
-
- public List getPersonList() {
- return personList;
- }
-
- public void setPersonList(List personList) {
- this.personList = personList;
- }
-}
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java
index 390961aa3..8fd301259 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.ReleaseInfo;
+import com.omertron.themoviedbapi.model.movie.ReleaseInfo;
import java.io.Serializable;
import java.util.List;
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java
index 83d346863..5ffee9248 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.omertron.themoviedbapi.model.Translation;
+import com.omertron.themoviedbapi.model.media.Translation;
import java.io.Serializable;
import java.util.List;
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperVideos.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperVideos.java
index 71024e850..1eae551c0 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperVideos.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperVideos.java
@@ -20,8 +20,8 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonSetter;
-import com.omertron.themoviedbapi.model.Trailer;
-import com.omertron.themoviedbapi.model.Video;
+import com.omertron.themoviedbapi.model.media.Trailer;
+import com.omertron.themoviedbapi.model.media.Video;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -71,7 +71,7 @@ public class WrapperVideos extends AbstractWrapperId implements Serializable {
video.setId("");
video.setLanguage("");
- video.setSize("");
+ video.setSize(0);
video.setName(trailer.getName());
video.setKey(trailer.getSource());
video.setType(trailer.getType());
diff --git a/src/test/java/com/omertron/themoviedbapi/AbstractTests.java b/src/test/java/com/omertron/themoviedbapi/AbstractTests.java
new file mode 100644
index 000000000..0b5805564
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/AbstractTests.java
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi;
+
+import com.omertron.themoviedbapi.methods.TmdbAccount;
+import com.omertron.themoviedbapi.methods.TmdbAuthentication;
+import com.omertron.themoviedbapi.model.account.Account;
+import com.omertron.themoviedbapi.model.authentication.TokenAuthorisation;
+import com.omertron.themoviedbapi.model.authentication.TokenSession;
+import com.omertron.themoviedbapi.tools.HttpTools;
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SerializationUtils;
+import org.apache.http.client.HttpClient;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yamj.api.common.http.SimpleHttpClientBuilder;
+
+public class AbstractTests {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractTests.class);
+ private static final String PROP_FIlENAME = "testing.properties";
+ private static final String FILENAME_EXT = ".bin";
+ private static final Properties props = new Properties();
+ private static HttpClient httpClient;
+ private static HttpTools httpTools;
+ // Session informaion
+ private static TokenSession tokenSession = null;
+ private static Account account = null;
+ // Constants
+ protected static final String LANGUAGE_DEFAULT = "";
+ protected static final String LANGUAGE_ENGLISH = "en";
+ protected static final String LANGUAGE_RUSSIAN = "ru";
+
+ /**
+ * Do the initial configuration for the test cases
+ *
+ * @throws MovieDbException
+ */
+ public static final void doConfiguration() throws MovieDbException {
+ TestLogger.Configure();
+ httpClient = new SimpleHttpClientBuilder().build();
+ httpTools = new HttpTools(httpClient);
+
+ if (props.isEmpty()) {
+ File f = new File(PROP_FIlENAME);
+ if (f.exists()) {
+ LOG.info("Loading properties from '{}'", PROP_FIlENAME);
+ TestLogger.loadProperties(props, f);
+ } else {
+ LOG.info("Property file '{}' not found, creating dummy file.", PROP_FIlENAME);
+
+ props.setProperty("API_Key", "INSERT_YOUR_KEY_HERE");
+ props.setProperty("Username", "INSERT_YOUR_USERNAME_HERE");
+ props.setProperty("Password", "INSERT_YOUR_PASSWORD_HERE");
+ props.setProperty("GuestSession", "INSERT_YOUR_GUEST_SESSION_ID_HERE");
+
+ TestLogger.saveProperties(props, f, "Properties file for tests");
+ fail("Failed to get key information from properties file '" + PROP_FIlENAME + "'");
+ }
+ }
+ }
+
+ /**
+ * Write out the object to a file
+ *
+ * @param object
+ * @param filename
+ * @return
+ */
+ private static boolean writeObject(final Serializable object, final String baseFilename) {
+ String filename = baseFilename + FILENAME_EXT;
+ File serFile = new File(filename);
+
+ if (serFile.exists()) {
+ serFile.delete();
+ }
+
+ try {
+ byte[] serObject = SerializationUtils.serialize(object);
+ FileUtils.writeByteArrayToFile(serFile, serObject);
+ return true;
+ } catch (IOException ex) {
+ LOG.info("Failed to write object to '{}': {}", filename, ex.getMessage(), ex);
+ return false;
+ }
+ }
+
+ /**
+ * Read the object back from a file
+ *
+ * @param
+ * @param filename
+ * @return
+ */
+ private static T readObject(final String baseFilename) {
+ String filename = baseFilename + FILENAME_EXT;
+ File serFile = new File(filename);
+
+ if (serFile.exists()) {
+ long diff = System.currentTimeMillis() - serFile.lastModified();
+ if (diff < TimeUnit.HOURS.toMillis(1)) {
+ LOG.info("File '{}' is current, no need to reacquire", filename);
+ } else {
+ LOG.info("File '{}' is too old, re-acquiring", filename);
+ return null;
+ }
+ } else {
+ LOG.info("File '{}' doesn't exist", filename);
+ return null;
+ }
+
+ LOG.info("Reading object from '{}'", filename);
+ try {
+ byte[] serObject = FileUtils.readFileToByteArray(serFile);
+ return (T) SerializationUtils.deserialize(serObject);
+ } catch (IOException ex) {
+ LOG.info("Failed to read {}: {}", filename, ex.getMessage(), ex);
+ return null;
+ }
+ }
+
+ /**
+ * get the Session ID
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public static final String getSessionId() throws MovieDbException {
+ if (tokenSession == null) {
+ LOG.info("Create a session token for the rest of the tests");
+ String filename = TokenSession.class.getSimpleName();
+ // Try to read the object from a file
+ tokenSession = readObject(filename);
+
+ if (tokenSession == null) {
+ TmdbAuthentication auth = new TmdbAuthentication(getApiKey(), getHttpTools());
+ // 1: Create a request token
+ TokenAuthorisation token = auth.getAuthorisationToken();
+ assertTrue("Token (auth) is not valid", token.getSuccess());
+ token = auth.getSessionTokenLogin(token, getUsername(), getPassword());
+ assertTrue("Token (login) is not valid", token.getSuccess());
+ // 3: Create the sessions ID
+ tokenSession = auth.getSessionToken(token);
+ assertTrue("Session token is not valid", tokenSession.getSuccess());
+
+ // Write the object to a file
+ writeObject(tokenSession, filename);
+ }
+ }
+ return tokenSession.getSessionId();
+ }
+
+ /**
+ * Get the Account information
+ *
+ * @return
+ * @throws MovieDbException
+ */
+ public static final int getAccountId() throws MovieDbException {
+ if (account == null) {
+ LOG.info("Getting account information");
+ String filename = Account.class.getSimpleName();
+ // Read the object from a file
+ account = readObject(filename);
+
+ if (account == null) {
+ TmdbAccount instance = new TmdbAccount(getApiKey(), getHttpTools());
+ // Get the account for later tests
+ account = instance.getAccount(tokenSession.getSessionId());
+
+ // Write the object to a file
+ writeObject(account, filename);
+ }
+ }
+ return account.getId();
+ }
+
+ /**
+ * get the Http Client
+ *
+ * @return
+ */
+ public static HttpClient getHttpClient() {
+ return httpClient;
+ }
+
+ /**
+ * Get the Http Tools
+ *
+ * @return
+ */
+ public static HttpTools getHttpTools() {
+ return httpTools;
+ }
+
+ /**
+ * Get the API Key
+ *
+ * @return
+ */
+ public static String getApiKey() {
+ return props.getProperty("API_Key");
+ }
+
+ /**
+ * Get the Account username
+ *
+ * @return
+ */
+ public static String getUsername() {
+ return props.getProperty("Username");
+ }
+
+ /**
+ * Get the Account password
+ *
+ * @return
+ */
+ public static String getPassword() {
+ return props.getProperty("Password");
+ }
+
+ /**
+ * Get the Guest Session ID
+ *
+ * @return
+ */
+ public static String getGuestSession() {
+ return props.getProperty("GuestSession");
+ }
+
+ /**
+ * Get the named property
+ *
+ * @param property
+ * @return
+ */
+ public static String getProperty(String property) {
+ return props.getProperty(property);
+ }
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/ArtworkResults.java b/src/test/java/com/omertron/themoviedbapi/ArtworkResults.java
new file mode 100644
index 000000000..44326d7cb
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/ArtworkResults.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi;
+
+import com.omertron.themoviedbapi.enumeration.ArtworkType;
+import java.util.EnumMap;
+import java.util.Map;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ArtworkResults {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ArtworkResults.class);
+ private final Map results;
+
+ public ArtworkResults() {
+ results = new EnumMap(ArtworkType.class);
+ for (ArtworkType at : ArtworkType.values()) {
+ results.put(at, false);
+ }
+ }
+
+ public void found(ArtworkType artworkType) {
+ results.put(artworkType, Boolean.TRUE);
+ }
+
+ public void validateResults(ArtworkType expectedType) {
+ validateResults(new ArtworkType[]{expectedType});
+ }
+
+ public void validateResults(ArtworkType expectedType1, ArtworkType expectedType2) {
+ validateResults(new ArtworkType[]{expectedType1, expectedType2});
+ }
+
+ public void validateResults(ArtworkType[] expectedTypes) {
+ LOG.trace("Results: {}", results);
+ for (ArtworkType artworkType : expectedTypes) {
+ assertTrue("No " + artworkType.name() + " found", results.get(artworkType));
+ results.remove(artworkType);
+ }
+
+ for (Map.Entry entry : results.entrySet()) {
+ assertFalse(entry.getKey() + " was also found", entry.getValue());
+ }
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/CompareTest.java b/src/test/java/com/omertron/themoviedbapi/CompareTest.java
new file mode 100644
index 000000000..68b75a97b
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/CompareTest.java
@@ -0,0 +1,130 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.omertron.themoviedbapi;
+
+import com.omertron.themoviedbapi.model.movie.MovieDb;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Stuart.Boston
+ */
+public class CompareTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CompareTest.class);
+
+ private static MovieDb moviedb;
+ private static final String TITLE_MAIN = "Blade Runner";
+ private static final String TITLE_OTHER = "Blade Runner Directors Cut";
+ private static final String YEAR_FULL = "1982-01-01";
+ private static final String YEAR_SHORT = "1982";
+
+ private static final boolean CASE_SENSITIVE = true;
+ private static final boolean NOT_CASE_SENSITIVE = false;
+
+ public CompareTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ TestLogger.Configure();
+
+ // Set the default comparison movie
+ moviedb = new MovieDb();
+ moviedb.setTitle(TITLE_MAIN);
+ moviedb.setOriginalTitle(TITLE_OTHER);
+ moviedb.setReleaseDate(YEAR_FULL);
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Exact match
+ */
+ @Test
+ public void testExactMatch() {
+ int maxDistance = 0;
+ boolean result;
+
+ result = Compare.movies(moviedb, TITLE_MAIN, YEAR_SHORT, maxDistance, CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, TITLE_OTHER, YEAR_SHORT, maxDistance, CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, TITLE_MAIN, YEAR_SHORT, maxDistance, NOT_CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, TITLE_OTHER, YEAR_SHORT, maxDistance, NOT_CASE_SENSITIVE);
+ assertTrue(result);
+
+ result = Compare.movies(moviedb, TITLE_MAIN, "", maxDistance, CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, TITLE_OTHER, "", maxDistance, CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, TITLE_MAIN, "", maxDistance, NOT_CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, TITLE_OTHER, "", maxDistance, NOT_CASE_SENSITIVE);
+ assertTrue(result);
+ }
+
+ /**
+ * Close match
+ */
+ @Test
+ public void testCloseMatch() {
+ int maxDistance = 6;
+ boolean result;
+
+ String closeMain = "bloderannar";
+ String closeOther = "Blade Runner Dir Cut";
+
+ // Make sure they are close enough
+ int currentDistance;
+
+ currentDistance = StringUtils.getLevenshteinDistance(TITLE_MAIN, closeMain);
+ LOG.info("Distance between '{}' and '{}' is {}", TITLE_MAIN, closeMain, currentDistance);
+ assertTrue(currentDistance <= maxDistance);
+
+ currentDistance = StringUtils.getLevenshteinDistance(TITLE_OTHER, closeOther);
+ LOG.info("Distance between '{}' and '{}' is {}", TITLE_OTHER, closeOther, currentDistance);
+ assertTrue(currentDistance <= maxDistance);
+
+ result = Compare.movies(moviedb, closeMain, YEAR_SHORT, maxDistance, CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, closeOther, YEAR_SHORT, maxDistance, CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, closeMain, YEAR_SHORT, maxDistance, NOT_CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, closeOther, YEAR_SHORT, maxDistance, NOT_CASE_SENSITIVE);
+ assertTrue(result);
+
+ result = Compare.movies(moviedb, closeMain, "", maxDistance, CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, closeOther, "", maxDistance, CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, closeMain, "", maxDistance, NOT_CASE_SENSITIVE);
+ assertTrue(result);
+ result = Compare.movies(moviedb, closeOther, "", maxDistance, NOT_CASE_SENSITIVE);
+ assertTrue(result);
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/TestAccounts.java b/src/test/java/com/omertron/themoviedbapi/TestAccounts.java
deleted file mode 100644
index 37fffcd91..000000000
--- a/src/test/java/com/omertron/themoviedbapi/TestAccounts.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi;
-
-import com.omertron.themoviedbapi.model.Account;
-import com.omertron.themoviedbapi.model.MovieDb;
-import com.omertron.themoviedbapi.model.MovieDbList;
-import com.omertron.themoviedbapi.model.StatusCode;
-import com.omertron.themoviedbapi.model.TokenAuthorisation;
-import com.omertron.themoviedbapi.model.TokenSession;
-import java.io.File;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TestAccounts {
-
- private static final Logger LOG = LoggerFactory.getLogger(TestAccounts.class);
- // API Key
- private static final String PROP_FIlENAME = "testing.properties";
- private static String API_KEY;
- private static String ACCOUNT_USERNAME;
- private static String ACCOUNT_PASSWORD;
- private static TheMovieDbApi tmdb;
- private static TokenSession tokenSession = null;
- private static Account account = null;
-
- public TestAccounts() throws MovieDbException {
- }
-
- @BeforeClass
- public static void setUpClass() throws MovieDbException {
- TestLogger.Configure();
-
- Properties props = new Properties();
- File f = new File(PROP_FIlENAME);
- if (f.exists()) {
- LOG.info("Loading properties from '{}'", PROP_FIlENAME);
- TestLogger.loadProperties(props, f);
-
- API_KEY = props.getProperty("API_Key");
- ACCOUNT_USERNAME = props.getProperty("Username");
- ACCOUNT_PASSWORD = props.getProperty("Password");
- } else {
- // Properties file is created in the main test class
- fail("Failed to get key information from properties file '" + PROP_FIlENAME + "'");
- }
-
- tmdb = new TheMovieDbApi(API_KEY);
- }
-
- @AfterClass
- public static void tearDownClass() {
- }
-
- @Before
- public void setUp() throws MovieDbException {
- if (tokenSession == null) {
- testSessionCreation();
- }
-
- if (account == null) {
- testAccount();
- }
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Test and create a session token for the rest of the tests
- *
- * @throws MovieDbException
- */
- @Test
- public void testSessionCreation() throws MovieDbException {
- LOG.info("Test and create a session token for the rest of the tests");
-
- // 1: Create a request token
- TokenAuthorisation token = tmdb.getAuthorisationToken();
- assertFalse("Token (auth) is null", token == null);
- assertTrue("Token (auth) is not valid", token.getSuccess());
- LOG.info("Token (auth): {}", token.toString());
-
- // 2b; Get user permission
- token = tmdb.getSessionTokenLogin(token, ACCOUNT_USERNAME, ACCOUNT_PASSWORD);
- assertFalse("Token (login) is null", token == null);
- assertTrue("Token (login) is not valid", token.getSuccess());
- LOG.info("Token (login): {}", token.toString());
-
- // 3: Create the sessions ID
- tokenSession = tmdb.getSessionToken(token);
- assertFalse("Session token is null", tokenSession == null);
- assertTrue("Session token is not valid", tokenSession.getSuccess());
- LOG.info("Session token: {}", tokenSession.toString());
- }
-
- /**
- * Test the account information
- *
- * @throws MovieDbException
- */
- @Test
- public void testAccount() throws MovieDbException {
- LOG.info("Using Session ID '{}' for test", tokenSession.getSessionId());
- account = tmdb.getAccount(tokenSession.getSessionId());
-
- LOG.info("Account: {}", account);
-
- // Make sure properties are extracted correctly
- assertEquals("Wrong username!", ACCOUNT_USERNAME, account.getUserName());
- }
-
- @Test
- public void testWatchList() throws MovieDbException {
- // If the static account is null, get it
- if (account == null) {
- account = tmdb.getAccount(tokenSession.getSessionId());
- }
-
- // make sure it's empty (because it's just a test account
- Assert.assertTrue(tmdb.getWatchList(tokenSession.getSessionId(), account.getId()).isEmpty());
-
- // add a movie
- tmdb.addToWatchList(tokenSession.getSessionId(), account.getId(), 550);
-
- List watchList = tmdb.getWatchList(tokenSession.getSessionId(), account.getId());
- assertNotNull("Empty watch list returned", watchList);
- assertEquals("Watchlist wrong size", 1, watchList.size());
-
- // clean up again
- tmdb.removeFromWatchList(tokenSession.getSessionId(), account.getId(), 550);
-
- Assert.assertTrue(tmdb.getWatchList(tokenSession.getSessionId(), account.getId()).isEmpty());
- }
-
- @Test
- public void testFavorites() throws MovieDbException {
- // If the static account is null, get it
- if (account == null) {
- account = tmdb.getAccount(tokenSession.getSessionId());
- }
-
- // make sure it's empty (because it's just a test account
- Assert.assertTrue(tmdb.getFavoriteMovies(tokenSession.getSessionId(), account.getId()).isEmpty());
-
- // add a movie
- tmdb.changeFavoriteStatus(tokenSession.getSessionId(), account.getId(), 550, true);
-
- List watchList = tmdb.getFavoriteMovies(tokenSession.getSessionId(), account.getId());
- assertNotNull("Empty watch list returned", watchList);
- assertEquals("Watchlist wrong size", 1, watchList.size());
-
- // clean up again
- tmdb.changeFavoriteStatus(tokenSession.getSessionId(), account.getId(), 550, false);
-
- Assert.assertTrue(tmdb.getFavoriteMovies(tokenSession.getSessionId(), account.getId()).isEmpty());
- }
-
- /**
- * Test of getSessionToken method, of class TheMovieDbApi.
- *
- * TODO: Cannot be tested without a HTTP authorisation:
- * http://help.themoviedb.org/kb/api/user-authentication
- *
- * @throws MovieDbException
- */
- @Ignore("Tested in setup")
- public void testGetSessionToken() throws MovieDbException {
- }
-
- /**
- * Test of getGuestSessionToken method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetGuestSessionToken() throws MovieDbException {
- LOG.info("getGuestSessionToken");
- TokenSession result = tmdb.getGuestSessionToken();
-
- assertTrue("Failed to get guest session", result.getSuccess());
- }
-
- /**
- * Test of postMovieRating method, of class TheMovieDbApi.
- *
- * TODO: Cannot be tested without a HTTP authorisation:
- * http://help.themoviedb.org/kb/api/user-authentication
- *
- * @throws MovieDbException
- */
- @Test
- public void testMovieRating() throws MovieDbException {
- LOG.info("postMovieRating");
-
- Integer movieID = 68724;
- Integer rating = new Random().nextInt(10) + 1;
-
- boolean wasPosted = tmdb.postMovieRating(tokenSession.getSessionId(), movieID, rating);
- assertTrue("Rating was not added", wasPosted);
-
- // get all rated movies
- List ratedMovies = tmdb.getRatedMovies(tokenSession.getSessionId(), account.getId());
- assertTrue("No rated movies", ratedMovies.size() > 0);
-
- // We should check that the movie was correctly rated, but the CDN does not update fast enough.
- }
-
- @Test
- public void testMovieLists() throws MovieDbException {
- Integer movieID = 68724;
-
- // use a random name to avoid that we clash we leftovers of incomplete test runs
- String name = "test list " + new Random().nextInt(100);
-
- // create the list
- String listId = tmdb.createList(tokenSession.getSessionId(), name, "api testing only");
-
- // add a movie, and test that it is on the list now
- tmdb.addMovieToList(tokenSession.getSessionId(), listId, movieID);
- MovieDbList list = tmdb.getList(listId);
- assertNotNull("Movie list returned was null", list);
- assertEquals("Unexpected number of items returned", 1, list.getItemCount());
- assertEquals((int) movieID, list.getItems().get(0).getId());
-
- // now remove the movie
- tmdb.removeMovieFromList(tokenSession.getSessionId(), listId, movieID);
- assertEquals(tmdb.getList(listId).getItemCount(), 0);
-
- // delete the test list
- StatusCode statusCode = tmdb.deleteMovieList(tokenSession.getSessionId(), listId);
- assertEquals(statusCode.getStatusCode(), 13);
- }
-}
diff --git a/src/test/java/com/omertron/themoviedbapi/TestID.java b/src/test/java/com/omertron/themoviedbapi/TestID.java
new file mode 100644
index 000000000..9f2c932a1
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/TestID.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi;
+
+public class TestID {
+
+ private String name;
+ private String imdb;
+ private int tmdb;
+ private String other;
+
+ public TestID() {
+ }
+
+ public TestID(String name, String imdb, int tmdb) {
+ this.name = name;
+ this.imdb = imdb;
+ this.tmdb = tmdb;
+ }
+
+ public TestID(String name, String imdb, int tmdb, String other) {
+ this.name = name;
+ this.imdb = imdb;
+ this.tmdb = tmdb;
+ this.other = other;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getImdb() {
+ return imdb;
+ }
+
+ public void setImdb(String imdb) {
+ this.imdb = imdb;
+ }
+
+ public int getTmdb() {
+ return tmdb;
+ }
+
+ public void setTmdb(int tmdb) {
+ this.tmdb = tmdb;
+ }
+
+ public String getOther() {
+ return other;
+ }
+
+ public void setOther(String other) {
+ this.other = other;
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java
deleted file mode 100644
index cfd7bd895..000000000
--- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java
+++ /dev/null
@@ -1,799 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi;
-
-import com.omertron.themoviedbapi.model.AlternativeTitle;
-import com.omertron.themoviedbapi.model.Artwork;
-import com.omertron.themoviedbapi.model.ChangedItem;
-import com.omertron.themoviedbapi.model.ChangedMovie;
-import com.omertron.themoviedbapi.model.Collection;
-import com.omertron.themoviedbapi.model.CollectionInfo;
-import com.omertron.themoviedbapi.model.Company;
-import com.omertron.themoviedbapi.model.Discover;
-import com.omertron.themoviedbapi.model.Genre;
-import com.omertron.themoviedbapi.model.JobDepartment;
-import com.omertron.themoviedbapi.model.Keyword;
-import com.omertron.themoviedbapi.model.KeywordMovie;
-import com.omertron.themoviedbapi.model.MovieDb;
-import com.omertron.themoviedbapi.model.MovieDbList;
-import com.omertron.themoviedbapi.model.MovieList;
-import com.omertron.themoviedbapi.model.Person;
-import com.omertron.themoviedbapi.model.PersonCredit;
-import com.omertron.themoviedbapi.model.ReleaseInfo;
-import com.omertron.themoviedbapi.model.Reviews;
-import com.omertron.themoviedbapi.model.TmdbConfiguration;
-import com.omertron.themoviedbapi.model.TokenAuthorisation;
-import com.omertron.themoviedbapi.model.TokenSession;
-import com.omertron.themoviedbapi.model.Translation;
-import com.omertron.themoviedbapi.model.Video;
-import com.omertron.themoviedbapi.results.TmdbResultsList;
-import com.omertron.themoviedbapi.results.TmdbResultsMap;
-import java.io.File;
-import java.util.List;
-import java.util.Properties;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test cases for TheMovieDbApi API
- *
- * @author stuart.boston
- */
-public class TheMovieDbApiTest {
-
- // Logger
- private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApiTest.class);
- // API Key
- private static final String PROP_FIlENAME = "testing.properties";
- private static String API_KEY;
- private static TheMovieDbApi tmdb;
- // Test data
- private static final int ID_MOVIE_BLADE_RUNNER = 78;
- private static final int ID_MOVIE_THE_AVENGERS = 24428;
- private static final int ID_COLLECTION_STAR_WARS = 10;
- private static final int ID_PERSON_BRUCE_WILLIS = 62;
- private static final int ID_COMPANY = 2;
- private static final String COMPANY_NAME = "Marvel Studios";
- private static final int ID_GENRE_ACTION = 28;
- private static final String ID_KEYWORD = "1721";
- // Languages
- private static final String LANGUAGE_DEFAULT = "";
- private static final String LANGUAGE_ENGLISH = "en";
- private static final String LANGUAGE_RUSSIAN = "ru";
- // session and account id of test users named 'apitests'
-
- public TheMovieDbApiTest() throws MovieDbException {
- }
-
- @BeforeClass
- public static void setUpClass() throws MovieDbException {
- TestLogger.Configure();
-
- Properties props = new Properties();
- File f = new File(PROP_FIlENAME);
- if (f.exists()) {
- LOG.info("Loading properties from '{}'", PROP_FIlENAME);
- TestLogger.loadProperties(props, f);
-
- API_KEY = props.getProperty("API_Key");
- } else {
- LOG.info("Property file '{}' not found, creating dummy file.", PROP_FIlENAME);
-
- props.setProperty("API_Key", "INSERT_YOUR_KEY_HERE");
- props.setProperty("Username", "INSERT_YOUR_USERNAME_HERE");
- props.setProperty("Password", "INSERT_YOUR_PASSWORD_HERE");
-
- TestLogger.saveProperties(props, f, "Properties file for tests");
- fail("Failed to get key information from properties file '" + PROP_FIlENAME + "'");
- }
-
- tmdb = new TheMovieDbApi(API_KEY);
- }
-
- @AfterClass
- public static void tearDownClass() throws MovieDbException {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Test of getConfiguration method, of class TheMovieDbApi.
- */
- @Test
- public void testConfiguration() {
- LOG.info("Test Configuration");
-
- TmdbConfiguration tmdbConfig = tmdb.getConfiguration();
- assertNotNull("Configuration failed", tmdbConfig);
- assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl()));
- assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0);
- assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0);
- assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0);
- LOG.info(tmdbConfig.toString());
- }
-
- /**
- * Test of searchMovie method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testSearchMovie() throws MovieDbException {
- LOG.info("searchMovie");
-
- // Try a movie with less than 1 page of results
- TmdbResultsList movieList = tmdb.searchMovie("Blade Runner", 0, "", true, 0);
-// List movieList = tmdb.searchMovie("Blade Runner", "", true);
- assertTrue("No movies found, should be at least 1", movieList.getResults().size() > 0);
-
- // Try a russian langugage movie
- movieList = tmdb.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, true, 0);
- assertTrue("No 'RU' movies found, should be at least 1", movieList.getResults().size() > 0);
-
- // Try a movie with more than 20 results
- movieList = tmdb.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, false, 0);
- assertTrue("Not enough movies found, should be over 15, found " + movieList.getResults().size(), movieList.getResults().size() >= 15);
- }
-
- /**
- * Test of getMovieInfo method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieInfo() throws MovieDbException {
- LOG.info("getMovieInfo");
- MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
- assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle());
- }
-
- /**
- * Test of getMovieAlternativeTitles method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieAlternativeTitles() throws MovieDbException {
- LOG.info("getMovieAlternativeTitles");
- String country = "";
- TmdbResultsList result = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country, "casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
- assertTrue("No alternative titles found", result.getResults().size() > 0);
-
- country = "US";
- result = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country);
- assertTrue("No alternative titles found", result.getResults().size() > 0);
-
- }
-
- /**
- * Test of getMovieCasts method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieCasts() throws MovieDbException {
- LOG.info("getMovieCasts");
- TmdbResultsList people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
- assertTrue("No cast information", people.getResults().size() > 0);
-
- String name1 = "Harrison Ford";
- String name2 = "Charles Knode";
- boolean foundName1 = Boolean.FALSE;
- boolean foundName2 = Boolean.FALSE;
-
- for (Person person : people.getResults()) {
- if (!foundName1 && person.getName().equalsIgnoreCase(name1)) {
- foundName1 = Boolean.TRUE;
- }
-
- if (!foundName2 && person.getName().equalsIgnoreCase(name2)) {
- foundName2 = Boolean.TRUE;
- }
- }
- assertTrue("Couldn't find " + name1, foundName1);
- assertTrue("Couldn't find " + name2, foundName2);
- }
-
- /**
- * Test of getMovieImages method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieImages() throws MovieDbException {
- LOG.info("getMovieImages");
- String language = "";
- TmdbResultsList result = tmdb.getMovieImages(ID_MOVIE_BLADE_RUNNER, language);
- assertFalse("No artwork found", result.getResults().isEmpty());
- }
-
- /**
- * Test of getMovieKeywords method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieKeywords() throws MovieDbException {
- LOG.info("getMovieKeywords");
- TmdbResultsList result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER);
- assertFalse("No keywords found", result.getResults().isEmpty());
- }
-
- /**
- * Test of getMovieReleaseInfo method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieReleaseInfo() throws MovieDbException {
- LOG.info("getMovieReleaseInfo");
- TmdbResultsList result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, "");
- assertFalse("Release information missing", result.getResults().isEmpty());
- }
-
- /**
- * Test of getMovieTrailers method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieTrailers() throws MovieDbException {
- LOG.info("getMovieTrailers");
- TmdbResultsList result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, "");
- assertFalse("Movie trailers missing", result.getResults().isEmpty());
- }
-
- /**
- * Test of getMovieTranslations method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieTranslations() throws MovieDbException {
- LOG.info("getMovieTranslations");
- TmdbResultsList result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER);
- assertFalse("No translations found", result.getResults().isEmpty());
- }
-
- /**
- * Test of getCollectionInfo method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetCollectionInfo() throws MovieDbException {
- LOG.info("getCollectionInfo");
- String language = "";
- CollectionInfo result = tmdb.getCollectionInfo(ID_COLLECTION_STAR_WARS, language);
- assertFalse("No collection information", result.getParts().isEmpty());
- }
-
- /**
- * Test of createImageUrl method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testCreateImageUrl() throws MovieDbException {
- LOG.info("createImageUrl");
- MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, "");
- String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString();
- assertTrue("Error compiling image URL", !result.isEmpty());
- }
-
- /**
- * Test of getMovieInfoImdb method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieInfoImdb() throws MovieDbException {
- LOG.info("getMovieInfoImdb");
- MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US");
- assertTrue("Error getting the movie from IMDB ID", result.getId() == 11);
- }
-
- /**
- * Test of searchPeople method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testSearchPeople() throws MovieDbException {
- LOG.info("searchPeople");
- String personName = "Bruce Willis";
- boolean includeAdult = false;
- TmdbResultsList result = tmdb.searchPeople(personName, includeAdult, 0);
- assertTrue("Couldn't find the person", result.getResults().size() > 0);
- }
-
- /**
- * Test of getPersonInfo method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetPersonInfo() throws MovieDbException {
- LOG.info("getPersonInfo");
- Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS);
- assertTrue("Wrong actor returned", result.getId() == ID_PERSON_BRUCE_WILLIS);
- }
-
- /**
- * Test of getPersonCredits method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetPersonCredits() throws MovieDbException {
- LOG.info("getPersonCredits");
-
- TmdbResultsList result = tmdb.getPersonCredits(ID_PERSON_BRUCE_WILLIS);
- assertTrue("No cast information", result.getResults().size() > 0);
- }
-
- /**
- * Test of getPersonImages method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetPersonImages() throws MovieDbException {
- LOG.info("getPersonImages");
-
- TmdbResultsList result = tmdb.getPersonImages(ID_PERSON_BRUCE_WILLIS);
- assertTrue("No cast information", result.getResults().size() > 0);
- }
-
- /**
- * Test of getLatestMovie method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetLatestMovie() throws MovieDbException {
- LOG.info("getLatestMovie");
- MovieDb result = tmdb.getLatestMovie();
- assertTrue("No latest movie found", result != null);
- assertTrue("No latest movie found", result.getId() > 0);
- }
-
- /**
- * Test of getNowPlayingMovies method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetNowPlayingMovies() throws MovieDbException {
- LOG.info("getNowPlayingMovies");
- TmdbResultsList result = tmdb.getNowPlayingMovies(LANGUAGE_DEFAULT, 0);
- assertTrue("No now playing movies found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of getPopularMovieList method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetPopularMovieList() throws MovieDbException {
- LOG.info("getPopularMovieList");
- TmdbResultsList result = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0);
- assertTrue("No popular movies found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of getTopRatedMovies method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetTopRatedMovies() throws MovieDbException {
- LOG.info("getTopRatedMovies");
- TmdbResultsList result = tmdb.getTopRatedMovies(LANGUAGE_DEFAULT, 0);
- assertTrue("No top rated movies found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of getCompanyInfo method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetCompanyInfo() throws MovieDbException {
- LOG.info("getCompanyInfo");
- Company company = tmdb.getCompanyInfo(ID_COMPANY);
- assertTrue("No company information found", company.getCompanyId() > 0);
- assertNotNull("No parent company found", company.getParentCompany());
- }
-
- /**
- * Test of getCompanyMovies method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetCompanyMovies() throws MovieDbException {
- LOG.info("getCompanyMovies");
- TmdbResultsList result = tmdb.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
- assertTrue("No company movies found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of searchCompanies method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testSearchCompanies() throws MovieDbException {
- LOG.info("searchCompanies");
- TmdbResultsList result = tmdb.searchCompanies(COMPANY_NAME, 0);
- assertTrue("No company information found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of getSimilarMovies method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetSimilarMovies() throws MovieDbException {
- LOG.info("getSimilarMovies");
- TmdbResultsList result = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, LANGUAGE_DEFAULT, 0);
- assertTrue("No similar movies found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of getGenreList method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetGenreList() throws MovieDbException {
- LOG.info("getGenreList");
- TmdbResultsList result = tmdb.getGenreList(LANGUAGE_DEFAULT);
- assertTrue("No genres found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of getGenreMovies method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetGenreMovies() throws MovieDbException {
- LOG.info("getGenreMovies");
- TmdbResultsList result = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0, Boolean.TRUE);
- assertTrue("No genre movies found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of getUpcoming method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetUpcoming() throws MovieDbException {
- LOG.info("getUpcoming");
- TmdbResultsList result = tmdb.getUpcoming(LANGUAGE_DEFAULT, 0);
- assertTrue("No upcoming movies found", !result.getResults().isEmpty());
- }
-
- /**
- * Test of getCollectionImages method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetCollectionImages() throws MovieDbException {
- LOG.info("getCollectionImages");
- TmdbResultsList result = tmdb.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT);
- assertFalse("No artwork found", result.getResults().isEmpty());
- }
-
- /**
- * Test of getAuthorisationToken method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetAuthorisationToken() throws MovieDbException {
- LOG.info("getAuthorisationToken");
- TokenAuthorisation result = tmdb.getAuthorisationToken();
- assertFalse("Token is null", result == null);
- assertTrue("Token is not valid", result.getSuccess());
- LOG.info(result.toString());
- }
-
- /**
- * Test of getSessionToken method, of class TheMovieDbApi.
- *
- * TODO: Cannot be tested without a HTTP authorisation:
- * http://help.themoviedb.org/kb/api/user-authentication
- *
- * @throws MovieDbException
- */
- @Ignore("Session required")
- public void testGetSessionToken() throws MovieDbException {
- LOG.info("getSessionToken");
- TokenAuthorisation token = tmdb.getAuthorisationToken();
- assertFalse("Token is null", token == null);
- assertTrue("Token is not valid", token.getSuccess());
- LOG.info("Token: {}", token.toString());
-
- TokenSession result = tmdb.getSessionToken(token);
- assertFalse("Session token is null", result == null);
- assertTrue("Session token is not valid", result.getSuccess());
- LOG.info(result.toString());
- }
-
- /**
- * Test of getGuestSessionToken method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Ignore("Not ready yet")
- public void testGetGuestSessionToken() throws MovieDbException {
- LOG.info("getGuestSessionToken");
- TokenSession result = tmdb.getGuestSessionToken();
-
- assertTrue("Failed to get guest session", result.getSuccess());
- }
-
- public void testGetMovieLists() throws MovieDbException {
- LOG.info("getMovieLists");
- TmdbResultsList result = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, 0);
- assertNotNull("No results found", result);
- assertTrue("No results found", result.getResults().size() > 0);
- }
-
- /**
- * Test of getMovieChanges method,of class TheMovieDbApi
- *
- * TODO: Do not test this until it is fixed
- *
- * @throws MovieDbException
- */
- @Ignore("Do not test this until it is fixed")
- public void testGetMovieChanges() throws MovieDbException {
- LOG.info("getMovieChanges");
-
- String startDate = "";
- String endDate = null;
-
- // Get some popular movies
- TmdbResultsList movieList = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0);
- for (MovieDb movie : movieList.getResults()) {
- TmdbResultsMap> result = tmdb.getMovieChanges(movie.getId(), startDate, endDate);
- LOG.info("{} has {} changes.", movie.getTitle(), result.getResults().size());
- assertTrue("No changes found", result.getResults().size() > 0);
- break;
- }
- }
-
- @Test
- public void testGetPersonLatest() throws MovieDbException {
- LOG.info("getPersonLatest");
-
- Person result = tmdb.getPersonLatest();
-
- assertNotNull("No results found", result);
- assertTrue("No results found", StringUtils.isNotBlank(result.getName()));
- }
-
- /**
- * Test of searchCollection method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testSearchCollection() throws MovieDbException {
- LOG.info("searchCollection");
- String query = "batman";
- int page = 0;
- TmdbResultsList result = tmdb.searchCollection(query, LANGUAGE_DEFAULT, page);
- assertFalse("No collections found", result == null);
- assertTrue("No collections found", result.getResults().size() > 0);
- }
-
- /**
- * Test of searchList method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testSearchList() throws MovieDbException {
- LOG.info("searchList");
- String query = "watch";
- int page = 0;
- TmdbResultsList result = tmdb.searchList(query, LANGUAGE_DEFAULT, page);
- assertFalse("No lists found", result.getResults() == null);
- assertTrue("No lists found", result.getResults().size() > 0);
- }
-
- /**
- * Test of searchKeyword method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testSearchKeyword() throws MovieDbException {
- LOG.info("searchKeyword");
- String query = "action";
- int page = 0;
- TmdbResultsList result = tmdb.searchKeyword(query, page);
- assertFalse("No keywords found", result.getResults() == null);
- assertTrue("No keywords found", result.getResults().size() > 0);
- }
-
- /**
- * Test of getPersonChanges method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Ignore("Not ready yet")
- public void testGetPersonChanges() throws MovieDbException {
- LOG.info("getPersonChanges");
- String startDate = "";
- String endDate = "";
- tmdb.getPersonChanges(ID_PERSON_BRUCE_WILLIS, startDate, endDate);
- }
-
- /**
- * Test of getList method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetList() throws MovieDbException {
- LOG.info("getList");
- String listId = "509ec17b19c2950a0600050d";
- MovieDbList result = tmdb.getList(listId);
- assertFalse("List not found", result.getItems().isEmpty());
- }
-
- /**
- * Test of getKeyword method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetKeyword() throws MovieDbException {
- LOG.info("getKeyword");
- Keyword result = tmdb.getKeyword(ID_KEYWORD);
- assertEquals("fight", result.getName());
- }
-
- /**
- * Test of getKeywordMovies method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetKeywordMovies() throws MovieDbException {
- LOG.info("getKeywordMovies");
- int page = 0;
- TmdbResultsList result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page);
- assertFalse("No keyword movies found", result.getResults().isEmpty());
- }
-
- /**
- * Test of getReviews method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetReviews() throws MovieDbException {
- LOG.info("getReviews");
- int page = 0;
- TmdbResultsList result = tmdb.getReviews(ID_MOVIE_THE_AVENGERS, LANGUAGE_DEFAULT, page);
-
- assertFalse("No reviews found", result.getResults().isEmpty());
- }
-
- /**
- * Test of getPersonPopular method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetPersonPopular_int() throws MovieDbException {
- LOG.info("getPersonPopular");
- int page = 0;
- TmdbResultsList result = tmdb.getPersonPopular(page);
- assertFalse("No popular people", result.getResults().isEmpty());
- }
-
- /**
- * Test of getMovieChangesList method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetMovieChangesList() throws MovieDbException {
- LOG.info("getMovieChangesList");
- int page = 0;
- String startDate = "";
- String endDate = "";
- TmdbResultsList result = tmdb.getMovieChangesList(page, startDate, endDate);
- assertFalse("No movie changes.", result.getResults().isEmpty());
- }
-
- /**
- * Test of getPersonChangesList method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Ignore("Not ready yet")
- public void testGetPersonChangesList() throws MovieDbException {
- LOG.info("getPersonChangesList");
- int page = 0;
- String startDate = "";
- String endDate = "";
- tmdb.getPersonChangesList(page, startDate, endDate);
- // TODO review the generated test code and remove the default call to fail.
- fail("The test case is a prototype.");
- }
-
- /**
- * Test of getJobs method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetJobs() throws MovieDbException {
- LOG.info("getJobs");
- TmdbResultsList result = tmdb.getJobs();
- assertFalse("No jobs found", result.getResults().isEmpty());
- }
-
- /**
- * Test of getDiscover method, of class TheMovieDbApi.
- *
- * @throws MovieDbException
- */
- @Test
- public void testGetDiscover_Discover() throws MovieDbException {
- LOG.info("getDiscover");
- Discover discover = new Discover();
- discover.year(2013).language(LANGUAGE_ENGLISH);
-
- TmdbResultsList result = tmdb.getDiscover(discover);
- assertFalse("No movies discovered", result.getResults().isEmpty());
- }
-}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java
new file mode 100644
index 000000000..7744a9870
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java
@@ -0,0 +1,308 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.enumeration.MediaType;
+import com.omertron.themoviedbapi.enumeration.SortBy;
+import com.omertron.themoviedbapi.model.StatusCode;
+import com.omertron.themoviedbapi.model.account.Account;
+import com.omertron.themoviedbapi.model.list.UserList;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbAccountTest extends AbstractTests {
+
+ private static TmdbAccount instance;
+ // Constants
+ private static final int ID_MOVIE_FIGHT_CLUB = 550;
+ private static final int ID_TV_WALKING_DEAD = 1402;
+
+ public TmdbAccountTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbAccount(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() throws MovieDbException {
+ }
+
+ @After
+ public void tearDown() throws MovieDbException {
+ }
+
+ /**
+ * Test of getAccountId method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetAccount() throws MovieDbException {
+ LOG.info("getAccount");
+ Account result = instance.getAccount(getSessionId());
+ assertNotNull("No account returned", result);
+ // Make sure properties are extracted correctly
+ assertEquals("Wrong username!", getUsername(), result.getUserName());
+ }
+
+ /**
+ * Test of getUserLists method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetUserLists() throws MovieDbException {
+ LOG.info("getUserLists");
+ List results = instance.getUserLists(getSessionId(), getAccountId());
+ assertNotNull("No list found", results);
+ assertFalse("No entries found", results.isEmpty());
+ for (UserList r : results) {
+ LOG.info(" {}", r.toString());
+ }
+ }
+
+ /**
+ * Test of getFavoriteMovies method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetFavoriteMovies() throws MovieDbException {
+ LOG.info("getFavoriteMovies");
+ List results = instance.getFavoriteMovies(getSessionId(), getAccountId());
+ assertNotNull("No list found", results);
+ assertFalse("No entries found", results.isEmpty());
+ for (MovieBasic r : results) {
+ LOG.info(" {}", r.toString());
+ }
+ }
+
+ /**
+ * Test of getFavoriteTv method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetFavoriteTv() throws MovieDbException {
+ LOG.info("getFavoriteTv");
+ List results = instance.getFavoriteTv(getSessionId(), getAccountId());
+ assertNotNull("No list found", results);
+ assertFalse("No entries found", results.isEmpty());
+ for (TVBasic r : results) {
+ LOG.info(" {}", r.toString());
+ }
+ }
+
+ /**
+ * Test of modifyFavoriteStatus method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testModifyFavoriteStatus() throws MovieDbException {
+ LOG.info("modifyFavoriteStatus");
+
+ // Add a movie as a favourite
+ StatusCode result = instance.modifyFavoriteStatus(getSessionId(), getAccountId(), MediaType.MOVIE, ID_MOVIE_FIGHT_CLUB, true);
+ LOG.info("Result: {}", result);
+ assertTrue("Incorrect status code", result.getCode() == 1 || result.getCode() == 12);
+
+ // Remove a movie as a favourite
+ result = instance.modifyFavoriteStatus(getSessionId(), getAccountId(), MediaType.MOVIE, ID_MOVIE_FIGHT_CLUB, false);
+ LOG.info("Result: {}", result);
+ assertTrue("Incorrect status code", result.getCode() == 13);
+
+ // Add a TV Show as a favourite
+ result = instance.modifyFavoriteStatus(getSessionId(), getAccountId(), MediaType.TV, ID_TV_WALKING_DEAD, true);
+ LOG.info("Result: {}", result);
+ assertTrue("Incorrect status code", result.getCode() == 1 || result.getCode() == 12);
+
+ // Remove a TV Show as a favourite
+ result = instance.modifyFavoriteStatus(getSessionId(), getAccountId(), MediaType.TV, ID_TV_WALKING_DEAD, false);
+ LOG.info("Result: {}", result);
+ assertTrue("Incorrect status code", result.getCode() == 13);
+ }
+
+ /**
+ * Test of getRatedMovies method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetRatedMovies() throws MovieDbException {
+ LOG.info("getRatedMovies");
+ List results = instance.getRatedMovies(getSessionId(), getAccountId(), null, null, null);
+ assertNotNull("No rated list found", results);
+ assertFalse("No entries found", results.isEmpty());
+ }
+
+ /**
+ * Test of getRatedTV method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetRatedTV() throws MovieDbException {
+ LOG.info("getRatedTV");
+ List results = instance.getRatedTV(getSessionId(), getAccountId(), null, null, null);
+ assertNotNull("No rated list found", results);
+ assertFalse("No entries found", results.isEmpty());
+ for (TVBasic r : results) {
+ LOG.info(" {}", r.toString());
+ }
+ }
+
+ /**
+ * Test of getWatchListMovie method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetWatchListMovie() throws MovieDbException {
+ LOG.info("getWatchListMovie");
+ List results = instance.getWatchListMovie(getSessionId(), getAccountId(), null, null, null);
+ assertNotNull("No rated list found", results);
+ assertFalse("No entries found", results.isEmpty());
+ for (MovieBasic r : results) {
+ LOG.info(" {}", r.toString());
+ }
+ }
+
+ /**
+ * Test of getWatchListTV method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetWatchListTV() throws MovieDbException {
+ LOG.info("getWatchListTV");
+ List results = instance.getWatchListTV(getSessionId(), getAccountId(), null, null, null);
+ assertNotNull("No rated list found", results);
+ assertFalse("No entries found", results.isEmpty());
+ for (TVBasic r : results) {
+ LOG.info(" {}", r.toString());
+ }
+ }
+
+ /**
+ * Test of modifyWatchList method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testModifyWatchList() throws MovieDbException {
+ LOG.info("modifyWatchList");
+
+ // Add a movie to the watch list
+ StatusCode result = instance.modifyWatchList(getSessionId(), getAccountId(), MediaType.MOVIE, ID_MOVIE_FIGHT_CLUB, true);
+ LOG.info("Result: {}", result);
+ assertTrue("Incorrect status code", result.getCode() == 1 || result.getCode() == 12);
+
+ // Remove a movie from the watch list
+ result = instance.modifyWatchList(getSessionId(), getAccountId(), MediaType.MOVIE, ID_MOVIE_FIGHT_CLUB, false);
+ LOG.info("Result: {}", result);
+ assertTrue("Incorrect status code", result.getCode() == 13);
+
+ // Add a TV Show to the watch list
+ result = instance.modifyWatchList(getSessionId(), getAccountId(), MediaType.TV, ID_TV_WALKING_DEAD, true);
+ LOG.info("Result: {}", result);
+ assertTrue("Incorrect status code", result.getCode() == 1 || result.getCode() == 12);
+
+ // Remove a TV Show from the watch list
+ result = instance.modifyWatchList(getSessionId(), getAccountId(), MediaType.TV, ID_TV_WALKING_DEAD, false);
+ LOG.info("Result: {}", result);
+ assertTrue("Incorrect status code", result.getCode() == 13);
+ }
+
+ /**
+ * Test of getGuestRatedMovies method, of class TmdbAccount.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetGuestRatedMovies() throws MovieDbException {
+ LOG.info("getGuestRatedMovies");
+
+ // Get the guest token
+ String guestSession = getGuestSession();
+
+ String language = LANGUAGE_DEFAULT;
+ Integer page = null;
+ SortBy sortBy = SortBy.CREATED_AT_ASC;
+ List result = instance.getGuestRatedMovies(guestSession, language, page, sortBy);
+
+ // Check and post some ratings if required
+ if (result.isEmpty()) {
+ postGuestRating(guestSession, ID_MOVIE_FIGHT_CLUB);
+ postGuestRating(guestSession, 78);
+ postGuestRating(guestSession, 76757);
+ postGuestRating(guestSession, 240832);
+ try {
+ Thread.sleep(TimeUnit.SECONDS.toMillis(5));
+ } catch (InterruptedException ex) {
+ LOG.trace("Interrupted");
+ }
+
+ // Get the movie list again
+ result = instance.getGuestRatedMovies(guestSession, language, page, sortBy);
+ }
+
+ for (MovieBasic mb : result) {
+ LOG.info("{}", mb);
+ }
+
+ assertFalse("No movies found!", result.isEmpty());
+ }
+
+ private void postGuestRating(String guestSessionId, int movieId) throws MovieDbException {
+ TmdbMovies tmdbMovies = new TmdbMovies(getApiKey(), getHttpTools());
+ Integer rating = new Random().nextInt(10) + 1;
+
+ LOG.info("Posting rating of '{}' to ID {} for guest session '{}'", rating, movieId, guestSessionId);
+ StatusCode sc = tmdbMovies.postMovieRating(movieId, rating, null, guestSessionId);
+ LOG.info("{}", sc);
+ assertTrue("Failed to post rating", sc.getCode() == 1 || sc.getCode() == 12);
+ }
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java
new file mode 100644
index 000000000..982a5ad1b
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.authentication.TokenAuthorisation;
+import com.omertron.themoviedbapi.model.authentication.TokenSession;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbAuthenticationTest extends AbstractTests {
+
+ private static TmdbAuthentication instance;
+
+ public TmdbAuthenticationTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbAuthentication(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test of getAuthorisationToken method, of class TmdbAuthentication.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetAuthorisationToken() throws MovieDbException {
+ LOG.info("getAuthorisationToken");
+ TokenAuthorisation token = instance.getAuthorisationToken();
+ assertFalse("Token is null", token == null);
+ assertTrue("Token is not valid", token.getSuccess());
+ }
+
+ /**
+ * Test of getSessionToken method, of class TmdbAuthentication.
+ *
+ * TODO: Cannot be tested without a HTTP authorisation:
+ * http://help.themoviedb.org/kb/api/user-authentication
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Ignore("Session needs to be authorised")
+ public void testGetSessionToken() throws MovieDbException {
+ LOG.info("getSessionToken");
+ TokenAuthorisation token = instance.getAuthorisationToken();
+ // Need to authorise the token here.
+ TokenSession result = instance.getSessionToken(token);
+ assertFalse("Session token is null", result == null);
+ assertTrue("Session token is not valid", result.getSuccess());
+ }
+
+ /**
+ * Test of getGuestSessionToken method, of class TmdbAuthentication.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetGuestSessionToken() throws MovieDbException {
+ LOG.info("getGuestSessionToken");
+ TokenSession result = instance.getGuestSessionToken();
+ assertTrue("Failed to get guest session", result.getSuccess());
+ }
+
+ /**
+ * Test of getSessionTokenLogin method, of class TmdbAuthentication.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSessionTokenLogin() throws MovieDbException {
+ System.out.println("getSessionTokenLogin");
+ TokenAuthorisation token = instance.getAuthorisationToken();
+ TokenAuthorisation result = instance.getSessionTokenLogin(token, getUsername(), getPassword());
+ assertNotNull("Null token returned", result);
+ assertTrue("Empty token", StringUtils.isNotBlank(result.getRequestToken()));
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java
new file mode 100644
index 000000000..fe7f220ea
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import static com.omertron.themoviedbapi.AbstractTests.doConfiguration;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.Certification;
+import com.omertron.themoviedbapi.results.TmdbResultsMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ * @author Luca Tagliani
+ */
+public class TmdbCertificationsTest extends AbstractTests {
+
+ private static TmdbCertifications instance;
+
+ public TmdbCertificationsTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbCertifications(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ /**
+ * Test of getMoviesCertification method, of class TmdbCertifications.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetMovieCertifications() throws MovieDbException {
+ LOG.info("getMovieCertifications");
+ TmdbResultsMap> result = instance.getMoviesCertification();
+ assertFalse("No movie certifications.", result.getResults().isEmpty());
+ for (Map.Entry> entry : result.getResults().entrySet()) {
+ LOG.info("{} = {} entries", entry.getKey(), entry.getValue().size());
+ assertFalse("No entries for " + entry.getKey(), entry.getValue().isEmpty());
+ }
+ }
+
+ /**
+ * Test of getTvCertification method, of class TmdbCertifications.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetTvCertifications() throws MovieDbException {
+ LOG.info("getTvCertifications");
+ TmdbResultsMap> result = instance.getTvCertification();
+ assertFalse("No tv certifications.", result.getResults().isEmpty());
+ for (Map.Entry> entry : result.getResults().entrySet()) {
+ LOG.info("{} = {} entries", entry.getKey(), entry.getValue().size());
+ assertFalse("No entries for " + entry.getKey(), entry.getValue().isEmpty());
+ }
+ }
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java
new file mode 100644
index 000000000..d7a9314a0
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.change.ChangeListItem;
+import com.omertron.themoviedbapi.tools.MethodBase;
+import java.util.List;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbChangesTest extends AbstractTests {
+
+ private static TmdbChanges instance;
+
+ public TmdbChangesTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbChanges(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ /**
+ * Test of getChangeList(MOVIE) method, of class TmdbChanges.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetMovieChangesList() throws MovieDbException {
+ LOG.info("getMovieChangesList");
+ List result = instance.getChangeList(MethodBase.MOVIE, null, null, null);
+ assertFalse("No movie changes.", result.isEmpty());
+ }
+
+ /**
+ * Test of getChangeList(PERSON) method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Ignore("Not ready yet")
+ public void testGetPersonChangesList() throws MovieDbException {
+ LOG.info("getPersonChangesList");
+ List result = instance.getChangeList(MethodBase.PERSON, null, null, null);
+ assertFalse("No Person changes.", result.isEmpty());
+ }
+
+ /**
+ * Test of getChangeList(TV) method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Ignore("Not ready yet")
+ public void testGetTVChangesList() throws MovieDbException {
+ LOG.info("getPersonChangesList");
+ List result = instance.getChangeList(MethodBase.PERSON, null, null, null);
+ assertFalse("No TV changes.", result.isEmpty());
+ }
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java
new file mode 100644
index 000000000..e31493d3d
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.artwork.Artwork;
+import com.omertron.themoviedbapi.model.collection.CollectionInfo;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbCollectionsTest extends AbstractTests {
+
+ private static TmdbCollections instance;
+ private static final int ID_COLLECTION_STAR_WARS = 10;
+
+ public TmdbCollectionsTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbCollections(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ /**
+ * Test of getCollectionInfo method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetCollectionInfo() throws MovieDbException {
+ LOG.info("getCollectionInfo");
+ String language = "";
+ CollectionInfo result = instance.getCollectionInfo(ID_COLLECTION_STAR_WARS, language);
+ assertFalse("No collection information", result.getParts().isEmpty());
+ }
+
+ /**
+ * Test of getCollectionImages method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetCollectionImages() throws MovieDbException {
+ LOG.info("getCollectionImages");
+ TmdbResultsList result = instance.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT);
+ assertFalse("No artwork found", result.getResults().isEmpty());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java
new file mode 100644
index 000000000..e7e52f2b7
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.company.Company;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbCompaniesTest extends AbstractTests {
+
+ private static TmdbCompanies instance;
+ private static final int ID_COMPANY = 2;
+
+ public TmdbCompaniesTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbCompanies(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getCompanyInfo method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetCompanyInfo() throws MovieDbException {
+ LOG.info("getCompanyInfo");
+ Company company = instance.getCompanyInfo(ID_COMPANY);
+ assertTrue("No company information found", company.getCompanyId() > 0);
+ assertNotNull("No parent company found", company.getParentCompany());
+ }
+
+ /**
+ * Test of getCompanyMovies method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetCompanyMovies() throws MovieDbException {
+ LOG.info("getCompanyMovies");
+ List result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
+ assertFalse("No company movies found", result.isEmpty());
+ }
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java
new file mode 100644
index 000000000..ee1b711a9
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.config.Configuration;
+import com.omertron.themoviedbapi.model.config.JobDepartment;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbConfigurationTest extends AbstractTests {
+
+ private static TmdbConfiguration instance;
+
+ public TmdbConfigurationTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbConfiguration(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getConfig method, of class TmdbConfiguration.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetConfig() throws MovieDbException {
+ LOG.info("getConfig");
+ Configuration result = instance.getConfig();
+ LOG.info(result.toString());
+ assertFalse("No backdrop sizes", result.getBackdropSizes().isEmpty());
+ assertFalse("No logo sizes", result.getLogoSizes().isEmpty());
+ assertFalse("No poster sizes", result.getPosterSizes().isEmpty());
+ assertFalse("No profile sizes", result.getProfileSizes().isEmpty());
+ assertTrue("No base url", StringUtils.isNotBlank(result.getBaseUrl()));
+ assertTrue("No secure base url", StringUtils.isNotBlank(result.getSecureBaseUrl()));
+ }
+
+ /**
+ * Test of createImageUrl method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testCreateImageUrl() throws MovieDbException {
+ LOG.info("createImageUrl");
+ Configuration config = instance.getConfig();
+
+ String result = config.createImageUrl("http://mediaplayersite.com/image.jpg", "original").toString();
+ assertTrue("Error compiling image URL", !result.isEmpty());
+ }
+
+ /**
+ * Test of getJobs method, of class TmdbConfiguration.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetJobs() throws MovieDbException {
+ LOG.info("getJobs");
+ TmdbResultsList result = instance.getJobs();
+ assertNotNull("Null results", result);
+ assertFalse("Empty results", result.getResults().isEmpty());
+ assertTrue("No results", result.getResults().size() > 0);
+ }
+
+ /**
+ * Test of getTimezones method, of class TmdbConfiguration.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetTimezones() throws MovieDbException {
+ LOG.info("getTimezones");
+ Map> result = instance.getTimezones();
+ assertNotNull("Null results", result);
+ assertFalse("Empty results", result.isEmpty());
+ assertTrue("No US TZ",result.containsKey("US"));
+ assertTrue("No GB TZ",result.containsKey("GB"));
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java
new file mode 100644
index 000000000..d199e7fff
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.person.CreditInfo;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbCreditsTest extends AbstractTests {
+
+ private static TmdbCredits instance;
+
+ public TmdbCreditsTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbCredits(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getCreditInfo method, of class TmdbCredits.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetCreditInfo() throws MovieDbException {
+ LOG.info("getCreditInfo");
+ String creditId = "53392a9c9251417da10041c8";
+ CreditInfo result = instance.getCreditInfo(creditId, LANGUAGE_DEFAULT);
+ assertEquals("Wrong name", "Josh McDermitt", result.getPerson().getName());
+ assertEquals("Wrong job", "Actor", result.getJob());
+ assertFalse("No seasons", result.getMedia().getSeasons().isEmpty());
+ assertFalse("No episodes", result.getMedia().getEpisodes().isEmpty());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java
new file mode 100644
index 000000000..422d28dae
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.discover.Discover;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbDiscoverTest extends AbstractTests {
+
+ private static TmdbDiscover instance;
+
+ public TmdbDiscoverTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbDiscover(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getDiscoverMovie method, of class TmdbDiscover.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetDiscoverMovie() throws MovieDbException {
+ LOG.info("getDiscoverMovie");
+ Discover discover = new Discover();
+ discover.year(2013).language(LANGUAGE_ENGLISH);
+
+ List result = instance.getDiscoverMovies(discover);
+ assertFalse("No movies discovered", result.isEmpty());
+ }
+
+ /**
+ * Test of getDiscoverTv method, of class TmdbDiscover.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetDiscoverTv() throws MovieDbException {
+ LOG.info("getDiscoverTv");
+ Discover discover = new Discover();
+ discover.year(2013).language(LANGUAGE_ENGLISH);
+
+ List result = instance.getDiscoverTV(discover);
+ assertFalse("No TV shows discovered", result.isEmpty());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java
new file mode 100644
index 000000000..1836885d1
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.TestID;
+import com.omertron.themoviedbapi.enumeration.ExternalSource;
+import com.omertron.themoviedbapi.model.FindResults;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.model.person.PersonFind;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ * @author Luca Tagliani
+ */
+public class TmdbFindTest extends AbstractTests {
+
+ private static TmdbFind instance;
+ private static final List PERSON_IDS = new ArrayList();
+ private static final List FILM_IDS = new ArrayList();
+ private static final List TV_IDS = new ArrayList();
+
+ public TmdbFindTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbFind(getApiKey(), getHttpTools());
+
+ PERSON_IDS.add(new TestID("Mila Kunis", "nm0005109", 18973));
+ PERSON_IDS.add(new TestID("Andrew Lincoln", "nm0511088", 7062));
+
+ FILM_IDS.add(new TestID("Jupiter Ascending", "tt1617661", 76757));
+ FILM_IDS.add(new TestID("Lucy", "tt2872732", 240832));
+
+ TV_IDS.add(new TestID("The Walking Dead", "tt1520211", 1402));
+ TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622));
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of Find Movie
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testFindMoviesImdbID() throws MovieDbException {
+ LOG.info("findMoviesImdbID");
+ FindResults result;
+
+ for (TestID test : FILM_IDS) {
+ result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
+ assertFalse("No movie for ID " + test.getName(), result.getMovieResults().isEmpty());
+ boolean found = false;
+ for (MovieBasic m : result.getMovieResults()) {
+ if (m.getId() == test.getTmdb()) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("No movie found: " + test.getName(), found);
+ }
+ }
+
+ /**
+ * Test of Find Person
+ *
+ * @throws MovieDbException
+ * @throws IOException
+ */
+ @Test
+ public void testFindPersonImdbID() throws MovieDbException, IOException {
+ LOG.info("findPersonImdbID");
+ FindResults result;
+
+ for (TestID test : PERSON_IDS) {
+ result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
+ assertFalse("No person for ID: " + test.getName(), result.getPersonResults().isEmpty());
+ boolean found = false;
+ for (PersonFind p : result.getPersonResults()) {
+ for (Object x : p.getKnownFor()) {
+ LOG.info(" {}", x.toString());
+ }
+ if (p.getId() == test.getTmdb()) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("No person found for ID: " + test.getName(), found);
+ }
+ }
+
+ /**
+ * Test of Find TV
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testFindTvSeriesImdbID() throws MovieDbException {
+ LOG.info("findTvSeriesImdbID");
+ FindResults result;
+
+ for (TestID test : TV_IDS) {
+ result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
+ assertFalse("No TV Show info for ID: " + test.getName(), result.getTvResults().isEmpty());
+ boolean found = false;
+ for (TVBasic tv : result.getTvResults()) {
+ if (tv.getId() == test.getTmdb()) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("No TV Show found for ID: " + test.getName(), found);
+ }
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java
new file mode 100644
index 000000000..24ceb3233
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.Genre;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbGenresTest extends AbstractTests {
+
+ private static TmdbGenres instance;
+ private static final int ID_GENRE_ACTION = 28;
+
+ public TmdbGenresTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbGenres(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getGenreMovieList method, of class TmdbGenres.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetGenreMovieList() throws MovieDbException {
+ LOG.info("getGenreMovieList");
+ TmdbResultsList result = instance.getGenreMovieList(LANGUAGE_DEFAULT);
+ assertNotNull("List is null", result.getResults());
+ assertFalse("List is empty", result.getResults().isEmpty());
+ }
+
+ /**
+ * Test of getGenreTVList method, of class TmdbGenres.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetGenreTVList() throws MovieDbException {
+ LOG.info("getGenreTVList");
+ TmdbResultsList result = instance.getGenreTVList(LANGUAGE_DEFAULT);
+ assertNotNull("List is null", result.getResults());
+ assertFalse("List is empty", result.getResults().isEmpty());
+ }
+
+ /**
+ * Test of getGenreMovies method, of class TmdbGenres.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetGenreMovies() throws MovieDbException {
+ LOG.info("getGenreMovies");
+ Integer page = null;
+ Boolean includeAllMovies = null;
+ Boolean includeAdult = null;
+ List result = instance.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, page, includeAllMovies, includeAdult);
+ assertNotNull("List is null", result);
+ assertFalse("List is empty", result.isEmpty());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java
new file mode 100644
index 000000000..0fe895b5b
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.keyword.Keyword;
+import com.omertron.themoviedbapi.model.movie.MovieBasic;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbKeywordsTest extends AbstractTests{
+
+ private static TmdbKeywords tmdb;
+ private static final String ID_KEYWORD = "1721";
+
+ public TmdbKeywordsTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ tmdb = new TmdbKeywords(getApiKey(),getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getKeyword method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetKeyword() throws MovieDbException {
+ LOG.info("getKeyword");
+ Keyword result = tmdb.getKeyword(ID_KEYWORD);
+ assertEquals("fight", result.getName());
+ }
+
+ /**
+ * Test of getMovieDbBasics method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetKeywordMovies() throws MovieDbException {
+ LOG.info("getKeywordMovies");
+ int page = 0;
+ TmdbResultsList result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page);
+ assertFalse("No keyword movies found", result.isEmpty());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java
new file mode 100644
index 000000000..a58a3b9b2
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.StatusCode;
+import com.omertron.themoviedbapi.model.list.ListItem;
+import java.util.Random;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+//@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TmdbListsTest extends AbstractTests {
+
+ private static TmdbLists instance;
+ private static final int ID_JUPITER_ASCENDING = 76757;
+ private static final int ID_BIG_HERO_6 = 177572;
+ // Status codes
+ private static final int SC_SUCCESS_UPD = 12;
+ private static final int SC_SUCCESS_DEL = 13;
+ // Expected exception
+ @Rule
+ public ExpectedException exception = ExpectedException.none();
+
+ public TmdbListsTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbLists(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void testSuite() throws MovieDbException {
+ // Test the list creation
+ String listId = testCreateList();
+
+ // Add two items to the list
+ testAddItem(listId, ID_JUPITER_ASCENDING);
+ testAddItem(listId, ID_BIG_HERO_6);
+
+ // Get information on the list
+ testGetList(listId);
+
+ // Check item status on the list
+ testCheckItemStatus(listId, ID_JUPITER_ASCENDING);
+
+ // Delete an item from the list
+ testRemoveItem(listId, ID_BIG_HERO_6);
+
+ // Clear the list
+ testClear(listId);
+
+ // Delete the list
+ testDeleteList(listId);
+
+ }
+
+ /**
+ * Test of getList method, of class TmdbLists.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ private void testGetList(String listId) throws MovieDbException {
+ LOG.info("getList");
+
+ ListItem result = instance.getList(listId);
+ LOG.info("Found {} movies on list", result.getItems().size());
+ assertFalse("No movies in list", result.getItems().isEmpty());
+ }
+
+ /**
+ * Test of createList method, of class TmdbLists.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ private String testCreateList() throws MovieDbException {
+ LOG.info("createList");
+ int r = new Random().nextInt();
+
+ String name = "Random list name #" + r;
+ String description = "This is random list number " + r + " used for testing purposes";
+ String result = instance.createList(getSessionId(), name, description);
+ assertTrue("No list ID returned", StringUtils.isNotBlank(result));
+ return result;
+ }
+
+ /**
+ * Test of checkItemStatus method, of class TmdbLists.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ private void testCheckItemStatus(String listId, int mediaId) throws MovieDbException {
+ LOG.info("checkItemStatus");
+ boolean expResult = true;
+ boolean result = instance.checkItemStatus(listId, mediaId);
+ assertEquals("Item is not on list!", expResult, result);
+ }
+
+ /**
+ * Test of deleteList method, of class TmdbLists.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ private void testDeleteList(String listId) throws MovieDbException {
+ LOG.info("deleteList");
+ StatusCode result = instance.deleteList(getSessionId(), listId);
+ LOG.info("Result: {}", result);
+
+ // We expect there to be an exception thrown here
+ exception.expect(MovieDbException.class);
+ ListItem result2 = instance.getList(listId);
+ LOG.info("Result: {}", result2);
+ }
+
+ /**
+ * Test of addItem method, of class TmdbLists.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ private void testAddItem(String listId, int mediaId) throws MovieDbException {
+ LOG.info("addItem");
+ StatusCode result = instance.addItem(getSessionId(), listId, mediaId);
+ assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_UPD, result.getCode());
+ }
+
+ /**
+ * Test of removeItem method, of class TmdbLists.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ private void testRemoveItem(String listId, int mediaId) throws MovieDbException {
+ LOG.info("removeItem");
+ StatusCode result = instance.removeItem(getSessionId(), listId, mediaId);
+ assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_DEL, result.getCode());
+ }
+
+ /**
+ * Test of clear method, of class TmdbLists.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ private void testClear(String listId) throws MovieDbException {
+ LOG.info("clear");
+ StatusCode result = instance.clear(getSessionId(), listId, true);
+ assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_UPD, result.getCode());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java
new file mode 100644
index 000000000..737f4baa8
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java
@@ -0,0 +1,468 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import static com.omertron.themoviedbapi.AbstractTests.getApiKey;
+import static com.omertron.themoviedbapi.AbstractTests.getHttpTools;
+import com.omertron.themoviedbapi.ArtworkResults;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.TestID;
+import com.omertron.themoviedbapi.enumeration.ArtworkType;
+import com.omertron.themoviedbapi.model.StatusCode;
+import com.omertron.themoviedbapi.model.artwork.Artwork;
+import com.omertron.themoviedbapi.model.change.ChangeKeyItem;
+import com.omertron.themoviedbapi.model.change.ChangeListItem;
+import com.omertron.themoviedbapi.model.keyword.Keyword;
+import com.omertron.themoviedbapi.model.list.UserList;
+import com.omertron.themoviedbapi.model.media.MediaCreditCast;
+import com.omertron.themoviedbapi.model.media.MediaCreditList;
+import com.omertron.themoviedbapi.model.media.MediaState;
+import com.omertron.themoviedbapi.model.media.AlternativeTitle;
+import com.omertron.themoviedbapi.model.movie.MovieDb;
+import com.omertron.themoviedbapi.model.movie.ReleaseInfo;
+import com.omertron.themoviedbapi.model.media.Translation;
+import com.omertron.themoviedbapi.model.media.Video;
+import com.omertron.themoviedbapi.model.review.Review;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import com.omertron.themoviedbapi.tools.MethodBase;
+import com.omertron.themoviedbapi.wrapper.WrapperChanges;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbMoviesTest extends AbstractTests {
+
+ private static TmdbMovies instance;
+ private static final List FILM_IDS = new ArrayList();
+
+ public TmdbMoviesTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbMovies(getApiKey(), getHttpTools());
+
+ FILM_IDS.add(new TestID("Blade Runner", "tt0083658", 78, "Harrison Ford"));
+ FILM_IDS.add(new TestID("Jupiter Ascending", "tt1617661", 76757, "Mila Kunis"));
+ FILM_IDS.add(new TestID("Lucy", "tt2872732", 240832, "Morgan Freeman"));
+
+ }
+
+ /**
+ * Test of getMovieInfo method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieInfo() throws MovieDbException {
+ LOG.info("getMovieInfo");
+
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ MovieDb result = instance.getMovieInfo(test.getTmdb(), language, appendToResponse);
+ assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbID());
+ assertEquals("Wrong title", test.getName(), result.getTitle());
+
+ }
+ }
+
+ /**
+ * Test of getMovieInfoImdb method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieInfoImdb() throws MovieDbException {
+ LOG.info("getMovieInfoImdb");
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ MovieDb result = instance.getMovieInfoImdb(test.getImdb(), language, appendToResponse);
+ assertEquals("Wrong TMDB ID", test.getTmdb(), result.getId());
+ assertEquals("Wrong title", test.getName(), result.getTitle());
+ }
+ }
+
+ /**
+ * Test of getMovieAccountState method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieAccountState() throws MovieDbException {
+ LOG.info("getMovieAccountState");
+
+ for (TestID test : FILM_IDS) {
+ MediaState result = instance.getMovieAccountState(test.getTmdb(), getSessionId());
+ assertNotNull("Null result", result);
+ assertTrue("Invalid rating", result.getRated() > -2f);
+ }
+ }
+
+ /**
+ * Test of getMovieAlternativeTitles method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieAlternativeTitles() throws MovieDbException {
+ LOG.info("getMovieAlternativeTitles");
+
+ String country = "";
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ TmdbResultsList result = instance.getMovieAlternativeTitles(test.getTmdb(), country, appendToResponse);
+ assertFalse("No alt titles", result.isEmpty());
+ }
+ }
+
+ /**
+ * Test of getMovieCredits method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieCredits() throws MovieDbException {
+ LOG.info("getMovieCredits");
+
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ MediaCreditList result = instance.getMovieCredits(test.getTmdb(), appendToResponse);
+ assertNotNull(result);
+ assertFalse(result.getCast().isEmpty());
+
+ boolean found = false;
+ for (MediaCreditCast p : result.getCast()) {
+ if (test.getOther().equals(p.getName())) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue(test.getOther() + " not found in cast!", found);
+
+ assertFalse(result.getCrew().isEmpty());
+ break;
+ }
+ }
+
+ /**
+ * Test of getMovieImages method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieImages() throws MovieDbException {
+ LOG.info("getMovieImages");
+
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ ArtworkResults results = new ArtworkResults();
+
+ for (TestID test : FILM_IDS) {
+ TmdbResultsList result = instance.getMovieImages(test.getTmdb(), language, appendToResponse);
+ assertFalse("No artwork", result.isEmpty());
+ for (Artwork artwork : result.getResults()) {
+ results.found(artwork.getArtworkType());
+ }
+
+ // We should only have posters & backdrops
+ results.validateResults(ArtworkType.POSTER, ArtworkType.BACKDROP);
+ }
+ }
+
+ /**
+ * Test of getMovieKeywords method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieKeywords() throws MovieDbException {
+ LOG.info("getMovieKeywords");
+
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ TmdbResultsList result = instance.getMovieKeywords(test.getTmdb(), appendToResponse);
+ assertFalse("No keywords", result.isEmpty());
+ }
+ }
+
+ /**
+ * Test of getMovieReleaseInfo method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieReleaseInfo() throws MovieDbException {
+ LOG.info("getMovieReleaseInfo");
+
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ TmdbResultsList result = instance.getMovieReleaseInfo(test.getTmdb(), language, appendToResponse);
+ assertFalse("No release info", result.isEmpty());
+ }
+ }
+
+ /**
+ * Test of getMovieVideos method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieVideos() throws MovieDbException {
+ LOG.info("getMovieVideos");
+
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+ boolean found = false;
+
+ for (TestID test : FILM_IDS) {
+ TmdbResultsList result = instance.getMovieVideos(test.getTmdb(), language, appendToResponse);
+ found = found || !result.isEmpty();
+ }
+ assertTrue("No videos", found);
+ }
+
+ /**
+ * Test of getMovieTranslations method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieTranslations() throws MovieDbException {
+ LOG.info("getMovieTranslations");
+
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ TmdbResultsList result = instance.getMovieTranslations(test.getTmdb(), appendToResponse);
+ assertFalse("No translations", result.isEmpty());
+ }
+ }
+
+ /**
+ * Test of getSimilarMovies method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSimilarMovies() throws MovieDbException {
+ LOG.info("getSimilarMovies");
+
+ Integer page = null;
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ TmdbResultsList result = instance.getSimilarMovies(test.getTmdb(), page, language, appendToResponse);
+ assertFalse("No similar movies", result.isEmpty());
+ }
+ }
+
+ /**
+ * Test of getMovieReviews method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieReviews() throws MovieDbException {
+ LOG.info("getMovieReviews");
+
+ Integer page = null;
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ if (test.getTmdb() == 76757) {
+ // Has no reviews
+ continue;
+ }
+ TmdbResultsList result = instance.getMovieReviews(test.getTmdb(), page, language, appendToResponse);
+ assertFalse("No reviews", result.isEmpty());
+ }
+ }
+
+ /**
+ * Test of getMovieLists method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieLists() throws MovieDbException {
+ LOG.info("getMovieLists");
+
+ Integer page = null;
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : FILM_IDS) {
+ TmdbResultsList result = instance.getMovieLists(test.getTmdb(), page, language, appendToResponse);
+ assertFalse("Empty list", result.isEmpty());
+ assertTrue(result.getTotalResults() > 0);
+ }
+ }
+
+ /**
+ * Test of getMovieChanges method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetMovieChanges() throws MovieDbException {
+ LOG.info("getMovieChanges");
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ String startDate = sdf.format(DateUtils.addDays(new Date(), -14));
+ String endDate = "";
+ int maxCheck = 5;
+
+ TmdbChanges chgs = new TmdbChanges(getApiKey(), getHttpTools());
+ List changeList = chgs.getChangeList(MethodBase.MOVIE, null, null, null);
+ LOG.info("Found {} changes to check, will check maximum of {}", changeList.size(), maxCheck);
+
+ int count = 1;
+ WrapperChanges result;
+ for (ChangeListItem item : changeList) {
+ result = instance.getMovieChanges(item.getId(), startDate, endDate);
+ for (ChangeKeyItem ci : result.getChangedItems()) {
+ assertNotNull("Null changes", ci);
+ }
+
+ if (count++ > maxCheck) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Test of postMovieRating method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testPostMovieRating() throws MovieDbException {
+ LOG.info("postMovieRating");
+ Integer rating = new Random().nextInt(10) + 1;
+
+ for (TestID test : FILM_IDS) {
+ StatusCode result = instance.postMovieRating(test.getTmdb(), rating, getSessionId(), null);
+ assertEquals("failed to post rating", 12, result.getCode());
+ }
+ }
+
+ /**
+ * Test of getLatestMovie method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetLatestMovie() throws MovieDbException {
+ LOG.info("getLatestMovie");
+
+ MovieDb result = instance.getLatestMovie();
+ assertNotNull("Null movie returned", result);
+ assertTrue("No ID", result.getId() > 0);
+ assertTrue("No title", StringUtils.isNotBlank(result.getTitle()));
+ }
+
+ /**
+ * Test of getUpcoming method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetUpcoming() throws MovieDbException {
+ LOG.info("getUpcoming");
+ Integer page = null;
+ String language = LANGUAGE_DEFAULT;
+
+ TmdbResultsList result = instance.getUpcoming(page, language);
+ assertFalse("No results found", result.isEmpty());
+ }
+
+ /**
+ * Test of getNowPlayingMovies method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetNowPlayingMovies() throws MovieDbException {
+ LOG.info("getNowPlayingMovies");
+ Integer page = null;
+ String language = LANGUAGE_DEFAULT;
+
+ TmdbResultsList result = instance.getNowPlayingMovies(page, language);
+ assertFalse("No results found", result.isEmpty());
+ }
+
+ /**
+ * Test of getPopularMovieList method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPopularMovieList() throws MovieDbException {
+ LOG.info("getPopularMovieList");
+ Integer page = null;
+ String language = LANGUAGE_DEFAULT;
+
+ TmdbResultsList result = instance.getPopularMovieList(page, language);
+ assertFalse("No results found", result.isEmpty());
+ }
+
+ /**
+ * Test of getTopRatedMovies method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetTopRatedMovies() throws MovieDbException {
+ LOG.info("getTopRatedMovies");
+ Integer page = null;
+ String language = LANGUAGE_DEFAULT;
+
+ TmdbResultsList result = instance.getTopRatedMovies(page, language);
+ assertFalse("No results found", result.isEmpty());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java
new file mode 100644
index 000000000..aec3fda54
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.TestID;
+import com.omertron.themoviedbapi.model.network.Network;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbNetworksTest extends AbstractTests {
+
+ private static TmdbNetworks instance;
+ private static final List testIDs = new ArrayList();
+
+ public TmdbNetworksTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbNetworks(getApiKey(), getHttpTools());
+ testIDs.add(new TestID("Fuji Television", "", 1));
+ testIDs.add(new TestID("Sonshine Media Network International", "", 200));
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ /**
+ * Test of getNetworkInfo method, of class TmdbNetworks.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetNetworkInfo() throws MovieDbException {
+ LOG.info("getNetworkInfo");
+
+ Network result;
+ for (TestID t : testIDs) {
+ result = instance.getNetworkInfo(t.getTmdb());
+ assertEquals("Wrong network returned", t.getName(), result.getName());
+ }
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java
new file mode 100644
index 000000000..9d6c62d35
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.TestID;
+import com.omertron.themoviedbapi.enumeration.ArtworkType;
+import com.omertron.themoviedbapi.enumeration.MediaType;
+import com.omertron.themoviedbapi.model.artwork.Artwork;
+import com.omertron.themoviedbapi.model.artwork.ArtworkMedia;
+import com.omertron.themoviedbapi.model.change.ChangeKeyItem;
+import com.omertron.themoviedbapi.model.change.ChangeListItem;
+import com.omertron.themoviedbapi.model.person.CreditBasic;
+import com.omertron.themoviedbapi.model.person.CreditMovieBasic;
+import com.omertron.themoviedbapi.model.person.CreditTVBasic;
+import com.omertron.themoviedbapi.model.person.ExternalID;
+import com.omertron.themoviedbapi.model.person.Person;
+import com.omertron.themoviedbapi.model.person.PersonCredits;
+import com.omertron.themoviedbapi.model.person.PersonFind;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import com.omertron.themoviedbapi.tools.MethodBase;
+import com.omertron.themoviedbapi.wrapper.WrapperChanges;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbPeopleTest extends AbstractTests {
+
+ private static TmdbPeople instance;
+ private static final List testIDs = new ArrayList();
+
+ public TmdbPeopleTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbPeople(getApiKey(), getHttpTools());
+ testIDs.add(new TestID("Bruce Willis", "nm0000246", 62));
+// testIDs.add(new TestID("Will Smith", "nm0000226", 2888));
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getPersonMovieOldInfo method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testGetPersonInfo() throws MovieDbException {
+ LOG.info("getPersonInfo");
+ Person result;
+
+ for (TestID test : testIDs) {
+ result = instance.getPersonInfo(test.getTmdb());
+ assertEquals("Wrong actor returned", test.getTmdb(), result.getId());
+ assertTrue("Missing bio", StringUtils.isNotBlank(result.getBiography()));
+ assertTrue("Missing birthday", StringUtils.isNotBlank(result.getBirthday()));
+ assertTrue("Missing homepage", StringUtils.isNotBlank(result.getHomepage()));
+ assertEquals("Missing IMDB", test.getImdb(), result.getImdbId());
+ assertTrue("Missing name", StringUtils.isNotBlank(result.getName()));
+ assertTrue("Missing birth place", StringUtils.isNotBlank(result.getPlaceOfBirth()));
+ assertTrue("Missing artwork", StringUtils.isNotBlank(result.getProfilePath()));
+ assertTrue("Missing bio", result.getPopularity() > 0F);
+ }
+ }
+
+ /**
+ * Test of getPersonMovieCredits method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonMovieCredits() throws MovieDbException {
+ LOG.info("getPersonMovieCredits");
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : testIDs) {
+ PersonCredits result = instance.getPersonMovieCredits(test.getTmdb(), language, appendToResponse);
+ LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
+ assertEquals("Incorrect ID", test.getTmdb(), result.getId());
+ assertFalse("No cast", result.getCast().isEmpty());
+ assertFalse("No crew", result.getCrew().isEmpty());
+
+ // Check that we have the movie specific fields
+ assertTrue("No title", StringUtils.isNotBlank(result.getCast().get(0).getTitle()));
+ assertTrue("No title", StringUtils.isNotBlank(result.getCrew().get(0).getTitle()));
+ }
+ }
+
+ /**
+ * Test of getPersonTVCredits method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonTVCredits() throws MovieDbException {
+ LOG.info("getPersonTVCredits");
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : testIDs) {
+ PersonCredits result = instance.getPersonTVCredits(test.getTmdb(), language, appendToResponse);
+ LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
+ assertEquals("Incorrect ID", test.getTmdb(), result.getId());
+ assertFalse("No cast", result.getCast().isEmpty());
+ assertFalse("No crew", result.getCrew().isEmpty());
+
+ // Check that we have the TV specific fields
+ assertTrue("No title", StringUtils.isNotBlank(result.getCast().get(0).getName()));
+ assertTrue("No title", StringUtils.isNotBlank(result.getCrew().get(0).getName()));
+ }
+ }
+
+ /**
+ * Test of getPersonCombinedCredits method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonCombinedCredits() throws MovieDbException {
+ LOG.info("getPersonCombinedCredits");
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : testIDs) {
+ PersonCredits result = instance.getPersonCombinedCredits(test.getTmdb(), language, appendToResponse);
+ LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
+ assertEquals("Incorrect ID", test.getTmdb(), result.getId());
+ assertFalse("No cast", result.getCast().isEmpty());
+ assertFalse("No crew", result.getCrew().isEmpty());
+
+ boolean checkedMovie = false;
+ boolean checkedTV = false;
+
+ for (CreditBasic p : result.getCast()) {
+ if (!checkedMovie && p.getMediaType() == MediaType.MOVIE) {
+ CreditMovieBasic c = (CreditMovieBasic) p;
+ assertTrue("No title", StringUtils.isNotBlank(c.getTitle()));
+ checkedMovie = true;
+ }
+
+ if (!checkedTV && p.getMediaType() == MediaType.TV) {
+ CreditTVBasic c = (CreditTVBasic) p;
+ assertTrue("No name", StringUtils.isNotBlank(c.getName()));
+ checkedTV = true;
+ }
+
+ if (checkedMovie && checkedTV) {
+ break;
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Test of getPersonExternalIds method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonExternalIds() throws MovieDbException {
+ LOG.info("getPersonExternalIds");
+
+ for (TestID test : testIDs) {
+ ExternalID result = instance.getPersonExternalIds(test.getTmdb());
+ assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbId());
+ }
+ }
+
+ /**
+ * Test of getPersonImages method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonImages() throws MovieDbException {
+ LOG.info("getPersonImages");
+
+ for (TestID test : testIDs) {
+ TmdbResultsList result = instance.getPersonImages(test.getTmdb());
+ assertFalse("No artwork", result.isEmpty());
+ assertEquals("Wrong artwork type", ArtworkType.PROFILE, result.getResults().get(0).getArtworkType());
+ }
+ }
+
+ /**
+ * Test of getPersonTaggedImages method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonTaggedImages() throws MovieDbException {
+ LOG.info("getPersonTaggedImages");
+ Integer page = null;
+ String language = LANGUAGE_DEFAULT;
+
+ for (TestID test : testIDs) {
+ TmdbResultsList result = instance.getPersonTaggedImages(test.getTmdb(), page, language);
+ assertFalse("No images", result.isEmpty());
+ for (ArtworkMedia am : result.getResults()) {
+ assertTrue("No ID", StringUtils.isNotBlank(am.getId()));
+ assertTrue("No file path", StringUtils.isNotBlank(am.getFilePath()));
+ }
+ }
+ }
+
+ /**
+ * Test of getPersonChanges method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonChanges() throws MovieDbException {
+ LOG.info("getPersonChanges");
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ String startDate = sdf.format(DateUtils.addDays(new Date(), -14));
+ String endDate = "";
+ int maxCheck = 5;
+
+ TmdbChanges chgs = new TmdbChanges(getApiKey(), getHttpTools());
+ List changeList = chgs.getChangeList(MethodBase.PERSON, null, null, null);
+ LOG.info("Found {} person changes to check", changeList.size());
+
+ int count = 1;
+ WrapperChanges result;
+ for (ChangeListItem item : changeList) {
+ result = instance.getPersonChanges(item.getId(), startDate, endDate);
+ for (ChangeKeyItem ci : result.getChangedItems()) {
+ assertNotNull("Null changes", ci);
+ }
+
+ if (count++ > maxCheck) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Test of getPersonPopular method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonPopular() throws MovieDbException {
+ LOG.info("getPersonPopular");
+ Integer page = null;
+ TmdbResultsList result = instance.getPersonPopular(page);
+ assertFalse("No results", result.isEmpty());
+ assertTrue("No results", result.getResults().size() > 0);
+ for (PersonFind p : result.getResults()) {
+ assertFalse("No known for entries", p.getKnownFor().isEmpty());
+ LOG.info("{} ({}) = {}", p.getName(), p.getId(), p.getKnownFor().size());
+ }
+ }
+
+ /**
+ * Test of getPersonLatest method, of class TmdbPeople.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetPersonLatest() throws MovieDbException {
+ LOG.info("getPersonLatest");
+
+ Person result = instance.getPersonLatest();
+ assertTrue("No ID", result.getId() > 0);
+ assertTrue("No name!", StringUtils.isNotBlank(result.getName()));
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java
new file mode 100644
index 000000000..30eb98cd3
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.model.review.Review;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbReviewsTest extends AbstractTests {
+
+ private static TmdbReviews instance;
+
+ public TmdbReviewsTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbReviews(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getReview method, of class TmdbReviews.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetReview() throws MovieDbException {
+ LOG.info("getReview");
+ String reviewId = "53fc2f600e0a267a7b009aba";
+ Review result = instance.getReview(reviewId);
+ assertNotNull("No review", result);
+ assertTrue("No content", StringUtils.isNotBlank(result.getContent()));
+ assertEquals("Wrong media ID", "70160", result.getMediaId());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java
new file mode 100644
index 000000000..27ac12cda
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.enumeration.SearchType;
+import com.omertron.themoviedbapi.model.collection.Collection;
+import com.omertron.themoviedbapi.model.company.Company;
+import com.omertron.themoviedbapi.model.keyword.Keyword;
+import com.omertron.themoviedbapi.model.list.UserList;
+import com.omertron.themoviedbapi.model.media.MediaBasic;
+import com.omertron.themoviedbapi.model.movie.MovieDb;
+import com.omertron.themoviedbapi.model.person.PersonFind;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class TmdbSearchTest extends AbstractTests {
+
+ private static TmdbSearch instance;
+ private static final String COMPANY_NAME = "Marvel Studios";
+
+ public TmdbSearchTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbSearch(getApiKey(), getHttpTools());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test of searchCompanies method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testSearchCompanies() throws MovieDbException {
+ LOG.info("searchCompanies");
+ TmdbResultsList result = instance.searchCompanies(COMPANY_NAME, 0);
+ assertNotNull("Null results", result);
+ assertNotNull("Null company", result.getResults());
+ assertFalse("Empty company", result.isEmpty());
+ }
+
+ /**
+ * Test of searchCollection method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testSearchCollection() throws MovieDbException {
+ LOG.info("searchCollection");
+ String query = "batman";
+ int page = 0;
+ TmdbResultsList result = instance.searchCollection(query, page, LANGUAGE_DEFAULT);
+ assertNotNull("Null results", result);
+ assertNotNull("Null collection", result.getResults());
+ assertFalse("Empty collection", result.isEmpty());
+ }
+
+ /**
+ * Test of searchKeyword method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testSearchKeyword() throws MovieDbException {
+ LOG.info("searchKeyword");
+ String query = "action";
+ int page = 0;
+ TmdbResultsList result = instance.searchKeyword(query, page);
+ assertNotNull("Null results", result);
+ assertNotNull("Null keyword", result.getResults());
+ assertFalse("Empty keyword", result.isEmpty());
+ }
+
+ /**
+ * Test of searchList method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testSearchList() throws MovieDbException {
+ LOG.info("searchList");
+ String query = "watch";
+ int page = 0;
+ TmdbResultsList result = instance.searchList(query, page, null);
+ assertNotNull("Null results", result);
+ assertNotNull("Null list", result.getResults());
+ assertFalse("Empty list", result.isEmpty());
+ }
+
+ /**
+ * Test of searchMovie method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testSearchMovie() throws MovieDbException {
+ LOG.info("searchMovie");
+
+ // Try a movie with less than 1 page of results
+ TmdbResultsList movieList = instance.searchMovie("Blade Runner", 0, "", null, 0, 0, SearchType.PHRASE);
+ assertTrue("No movies found, should be at least 1", movieList.getResults().size() > 0);
+
+ // Try a russian langugage movie
+ movieList = instance.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, null, 0, 0, SearchType.PHRASE);
+ assertTrue("No 'RU' movies found, should be at least 1", movieList.getResults().size() > 0);
+
+ // Try a movie with more than 20 results
+ movieList = instance.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, null, 0, 0, SearchType.PHRASE);
+ assertTrue("Not enough movies found, should be over 15, found " + movieList.getResults().size(), movieList.getResults().size() >= 15);
+ }
+
+ /**
+ * Test of searchMulti method, of class TmdbSearch.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testSearchMulti() throws MovieDbException {
+ System.out.println("searchMulti");
+ String query = "j";
+ Integer page = null;
+ String language = "";
+ Boolean includeAdult = null;
+ TmdbResultsList result = instance.searchMulti(query, page, language, includeAdult);
+ for (MediaBasic item : result.getResults()) {
+ LOG.info("{}", item);
+ }
+ }
+
+ /**
+ * Test of searchPeople method, of class TheMovieDbApi.
+ *
+ * @throws MovieDbException
+ */
+ @Test
+ public void testSearchPeople() throws MovieDbException {
+ LOG.info("searchPeople");
+ String personName = "Bruce Willis";
+ TmdbResultsList result = instance.searchPeople(personName, null, null, SearchType.PHRASE);
+ assertNotNull("Null results", result);
+ assertNotNull("Null people", result.getResults());
+ assertFalse("Empty people", result.isEmpty());
+ }
+
+ /**
+ * Test of searchTV method, of class TmdbSearch.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testSearchTV() throws MovieDbException {
+ System.out.println("searchTV");
+ String query = "The Walking Dead";
+ Integer page = null;
+ String language = LANGUAGE_ENGLISH;
+ Integer firstAirDateYear = null;
+ SearchType searchType = SearchType.PHRASE;
+ TmdbResultsList result = instance.searchTV(query, page, language, firstAirDateYear, searchType);
+ assertNotNull("Null results", result);
+ assertNotNull("Null TV", result.getResults());
+ assertFalse("Empty TV", result.isEmpty());
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVEpisodesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVEpisodesTest.java
new file mode 100644
index 000000000..b45dfeee6
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVEpisodesTest.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import static com.omertron.themoviedbapi.AbstractTests.getApiKey;
+import static com.omertron.themoviedbapi.AbstractTests.getHttpTools;
+import com.omertron.themoviedbapi.ArtworkResults;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.TestID;
+import com.omertron.themoviedbapi.enumeration.ArtworkType;
+import com.omertron.themoviedbapi.model.StatusCode;
+import com.omertron.themoviedbapi.model.artwork.Artwork;
+import com.omertron.themoviedbapi.model.media.MediaCreditCast;
+import com.omertron.themoviedbapi.model.media.MediaCreditList;
+import com.omertron.themoviedbapi.model.media.MediaState;
+import com.omertron.themoviedbapi.model.media.Video;
+import com.omertron.themoviedbapi.model.person.ExternalID;
+import com.omertron.themoviedbapi.model.tv.TVEpisodeInfo;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author Stuart.Boston
+ */
+public class TmdbTVEpisodesTest extends AbstractTests {
+
+ private static TmdbTVEpisodes instance;
+ private static final List TV_IDS = new ArrayList();
+
+ public TmdbTVEpisodesTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbTVEpisodes(getApiKey(), getHttpTools());
+
+ TV_IDS.add(new TestID("The Walking Dead", "tt1589921", 1402, "Andrew Lincoln"));
+ TV_IDS.add(new TestID("Supernatural", "tt0713618", 1622, "Misha Collins"));
+ TV_IDS.add(new TestID("The Big Bang Theory", "tt0775431", 1418, "Kaley Cuoco"));
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getEpisodeInfo method, of class TmdbTVEpisodes.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetEpisodeInfo() throws MovieDbException {
+ LOG.info("getEpisodeInfo");
+
+ int seasonNumber = 1;
+ int episodeNumber = 1;
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : TV_IDS) {
+ TVEpisodeInfo result = instance.getEpisodeInfo(test.getTmdb(), seasonNumber, episodeNumber, language, appendToResponse);
+ assertTrue("No ID", result.getId() > 0);
+ assertTrue("No name", StringUtils.isNotBlank(result.getName()));
+ assertTrue("No crew", result.getCrew().size() > 0);
+ assertTrue("No guest stars", result.getGuestStars().size() > 0);
+ }
+ }
+
+ /**
+ * Test of getEpisodeChanges method, of class TmdbTVEpisodes.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetEpisodeChanges() throws MovieDbException {
+ LOG.info("getEpisodeChanges");
+ // This is too empherial to test
+ }
+
+ /**
+ * Test of getEpisodeAccountState method, of class TmdbTVEpisodes.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetEpisodeAccountState() throws MovieDbException {
+ LOG.info("getEpisodeAccountState");
+
+ int seasonNumber = 1;
+ int episodeNumber = 1;
+
+ for (TestID test : TV_IDS) {
+ MediaState result = instance.getEpisodeAccountState(test.getTmdb(), seasonNumber, episodeNumber, getSessionId());
+ assertNotNull("Null result", result);
+ assertTrue("Invalid rating", result.getRated() > -2f);
+ }
+ }
+
+ /**
+ * Test of getEpisodeCredits method, of class TmdbTVEpisodes.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetEpisodeCredits() throws MovieDbException {
+ LOG.info("getEpisodeCredits");
+
+ int seasonNumber = 1;
+ int episodeNumber = 1;
+
+ for (TestID test : TV_IDS) {
+ MediaCreditList result = instance.getEpisodeCredits(test.getTmdb(), seasonNumber, episodeNumber);
+ assertNotNull(result);
+ assertFalse(result.getCast().isEmpty());
+
+ boolean found = false;
+ for (MediaCreditCast p : result.getCast()) {
+ if (test.getOther().equals(p.getName())) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue(test.getOther() + " not found in cast!", found);
+
+ assertFalse(result.getCrew().isEmpty());
+ break;
+ }
+ }
+
+ /**
+ * Test of getEpisodeExternalID method, of class TmdbTVEpisodes.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetEpisodeExternalID() throws MovieDbException {
+ LOG.info("getEpisodeExternalID");
+
+ int seasonNumber = 1;
+ int episodeNumber = 1;
+ String language = LANGUAGE_DEFAULT;
+
+ for (TestID test : TV_IDS) {
+ ExternalID result = instance.getEpisodeExternalID(test.getTmdb(), seasonNumber, episodeNumber, language);
+ assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbId());
+ }
+ }
+
+ /**
+ * Test of getEpisodeImages method, of class TmdbTVEpisodes.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetEpisodeImages() throws MovieDbException {
+ LOG.info("getEpisodeImages");
+
+ int seasonNumber = 1;
+ int episodeNumber = 1;
+
+ ArtworkResults results = new ArtworkResults();
+
+ for (TestID test : TV_IDS) {
+ TmdbResultsList result = instance.getEpisodeImages(test.getTmdb(), seasonNumber, episodeNumber);
+ assertFalse("No artwork", result.isEmpty());
+ for (Artwork artwork : result.getResults()) {
+ results.found(artwork.getArtworkType());
+ }
+
+ // We should only have posters & backdrops
+ results.validateResults(ArtworkType.STILL);
+ }
+
+ }
+
+ /**
+ * Test of postEpisodeRating method, of class TmdbTVEpisodes.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testPostEpisodeRating() throws MovieDbException {
+ LOG.info("postEpisodeRating");
+
+ int seasonNumber = 1;
+ int episodeNumber = 1;
+ String guestSessionID = null;
+
+ for (TestID test : TV_IDS) {
+ Integer rating = new Random().nextInt(10) + 1;
+ StatusCode result = instance.postEpisodeRating(test.getTmdb(), seasonNumber, episodeNumber, rating, getSessionId(), guestSessionID);
+ assertEquals("failed to post rating", 12, result.getCode());
+ }
+ }
+
+ /**
+ * Test of getEpisodeVideos method, of class TmdbTVEpisodes.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetEpisodeVideos() throws MovieDbException {
+ LOG.info("getEpisodeVideos");
+
+ int seasonNumber = 1;
+ int episodeNumber = 1;
+ String language = LANGUAGE_DEFAULT;
+
+ for (TestID test : TV_IDS) {
+ TmdbResultsList result = instance.getEpisodeVideos(test.getTmdb(), seasonNumber, episodeNumber, language);
+ LOG.info("Found {} videos", result.getResults().size());
+ }
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVSeasonsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVSeasonsTest.java
new file mode 100644
index 000000000..968d1293e
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVSeasonsTest.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import static com.omertron.themoviedbapi.AbstractTests.doConfiguration;
+import static com.omertron.themoviedbapi.AbstractTests.getApiKey;
+import static com.omertron.themoviedbapi.AbstractTests.getHttpTools;
+import com.omertron.themoviedbapi.ArtworkResults;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.TestID;
+import com.omertron.themoviedbapi.enumeration.ArtworkType;
+import com.omertron.themoviedbapi.model.artwork.Artwork;
+import com.omertron.themoviedbapi.model.media.MediaCreditCast;
+import com.omertron.themoviedbapi.model.media.MediaCreditList;
+import com.omertron.themoviedbapi.model.media.MediaState;
+import com.omertron.themoviedbapi.model.media.Video;
+import com.omertron.themoviedbapi.model.person.ExternalID;
+import com.omertron.themoviedbapi.model.tv.TVSeasonInfo;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author Stuart.Boston
+ */
+public class TmdbTVSeasonsTest extends AbstractTests {
+
+ private static TmdbTVSeasons instance;
+ private static final List TV_IDS = new ArrayList();
+
+ public TmdbTVSeasonsTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbTVSeasons(getApiKey(), getHttpTools());
+
+ TV_IDS.add(new TestID("The Walking Dead", "tt1520211", 1402, "Andrew Lincoln"));
+ TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622, "Misha Collins"));
+ TV_IDS.add(new TestID("The Big Bang Theory", "tt0898266", 1418, "Kaley Cuoco"));
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of getSeasonInfo method, of class TmdbTVSeasons.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSeasonInfo() throws MovieDbException {
+ LOG.info("getSeasonInfo");
+
+ int seasonNumber = 1;
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : TV_IDS) {
+ TVSeasonInfo result = instance.getSeasonInfo(test.getTmdb(), seasonNumber, language, appendToResponse);
+ assertTrue("No ID", result.getId() > 0);
+ assertTrue("No name", StringUtils.isNotBlank(result.getName()));
+ assertTrue("No overview", StringUtils.isNotBlank(result.getOverview()));
+ assertTrue("No episodes", result.getEpisodes().size() > 0);
+ }
+ }
+
+ /**
+ * Test of getSeasonChanges method, of class TmdbTVSeasons.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSeasonChanges() throws MovieDbException {
+ LOG.info("getSeasonChanges");
+ // This is too empherial to test
+ }
+
+ /**
+ * Test of getSeasonAccountState method, of class TmdbTVSeasons.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSeasonAccountState() throws MovieDbException {
+ LOG.info("getSeasonAccountState");
+
+ for (TestID test : TV_IDS) {
+ MediaState result = instance.getSeasonAccountState(test.getTmdb(), getSessionId());
+ assertNotNull("Null result", result);
+ assertTrue("Invalid rating", result.getRated() > -2f);
+ }
+ }
+
+ /**
+ * Test of getSeasonCredits method, of class TmdbTVSeasons.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSeasonCredits() throws MovieDbException {
+ LOG.info("getSeasonCredits");
+
+ int seasonNumber = 0;
+
+ for (TestID test : TV_IDS) {
+ MediaCreditList result = instance.getSeasonCredits(test.getTmdb(), seasonNumber);
+ assertNotNull(result);
+ assertFalse(result.getCast().isEmpty());
+
+ boolean found = false;
+ for (MediaCreditCast p : result.getCast()) {
+ if (test.getOther().equals(p.getName())) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue(test.getOther() + " not found in cast!", found);
+
+ assertFalse(result.getCrew().isEmpty());
+ break;
+ }
+ }
+
+ /**
+ * Test of getSeasonExternalID method, of class TmdbTVSeasons.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSeasonExternalID() throws MovieDbException {
+ LOG.info("getSeasonExternalID");
+
+ int seasonNumber = 0;
+ String language = LANGUAGE_DEFAULT;
+
+ for (TestID test : TV_IDS) {
+ ExternalID result = instance.getSeasonExternalID(test.getTmdb(), seasonNumber, language);
+ assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbId());
+ }
+ }
+
+ /**
+ * Test of getSeasonImages method, of class TmdbTVSeasons.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSeasonImages() throws MovieDbException {
+ LOG.info("getSeasonImages");
+
+ int seasonNumber = 1;
+ String language = LANGUAGE_DEFAULT;
+ String[] includeImageLanguage = null;
+
+ ArtworkResults results = new ArtworkResults();
+
+ for (TestID test : TV_IDS) {
+ TmdbResultsList result = instance.getSeasonImages(test.getTmdb(), seasonNumber, language, includeImageLanguage);
+ assertFalse("No artwork", result.isEmpty());
+ for (Artwork artwork : result.getResults()) {
+ results.found(artwork.getArtworkType());
+ }
+
+ // We should only have posters
+ results.validateResults(ArtworkType.POSTER);
+ }
+ }
+
+ /**
+ * Test of getSeasonVideos method, of class TmdbTVSeasons.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetSeasonVideos() throws MovieDbException {
+ LOG.info("getSeasonVideos");
+
+ int seasonNumber = 0;
+ String language = LANGUAGE_DEFAULT;
+ boolean found = false;
+
+ for (TestID test : TV_IDS) {
+ TmdbResultsList result = instance.getSeasonVideos(test.getTmdb(), seasonNumber, language);
+ found = found || !result.isEmpty();
+ }
+
+ assertTrue("No videos", found);
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVTest.java
new file mode 100644
index 000000000..561cf9954
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVTest.java
@@ -0,0 +1,419 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.methods;
+
+import com.omertron.themoviedbapi.AbstractTests;
+import static com.omertron.themoviedbapi.AbstractTests.getApiKey;
+import static com.omertron.themoviedbapi.AbstractTests.getHttpTools;
+import com.omertron.themoviedbapi.ArtworkResults;
+import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.TestID;
+import com.omertron.themoviedbapi.enumeration.ArtworkType;
+import com.omertron.themoviedbapi.model.StatusCode;
+import com.omertron.themoviedbapi.model.artwork.Artwork;
+import com.omertron.themoviedbapi.model.change.ChangeKeyItem;
+import com.omertron.themoviedbapi.model.change.ChangeListItem;
+import com.omertron.themoviedbapi.model.keyword.Keyword;
+import com.omertron.themoviedbapi.model.media.MediaCreditCast;
+import com.omertron.themoviedbapi.model.media.MediaCreditList;
+import com.omertron.themoviedbapi.model.media.MediaState;
+import com.omertron.themoviedbapi.model.media.AlternativeTitle;
+import com.omertron.themoviedbapi.model.media.Translation;
+import com.omertron.themoviedbapi.model.media.Video;
+import com.omertron.themoviedbapi.model.person.ContentRating;
+import com.omertron.themoviedbapi.model.person.ExternalID;
+import com.omertron.themoviedbapi.model.tv.TVBasic;
+import com.omertron.themoviedbapi.model.tv.TVInfo;
+import com.omertron.themoviedbapi.results.TmdbResultsList;
+import com.omertron.themoviedbapi.tools.MethodBase;
+import com.omertron.themoviedbapi.wrapper.WrapperChanges;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test for the TV Method
+ *
+ * @author stuart.boston
+ */
+public class TmdbTVTest extends AbstractTests {
+
+ private static TmdbTV instance;
+ private static final List TV_IDS = new ArrayList();
+
+ public TmdbTVTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws MovieDbException {
+ doConfiguration();
+ instance = new TmdbTV(getApiKey(), getHttpTools());
+
+ TV_IDS.add(new TestID("The Walking Dead", "tt1520211", 1402, "Andrew Lincoln"));
+ TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622, "Misha Collins"));
+ TV_IDS.add(new TestID("The Big Bang Theory", "tt0898266", 1418, "Kaley Cuoco"));
+ }
+
+ /**
+ * Test of getTVInfo method, of class TmdbTV.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetTVInfo() throws MovieDbException {
+ LOG.info("getTVInfo");
+
+ String language = LANGUAGE_DEFAULT;
+ String[] appendToResponse = null;
+
+ for (TestID test : TV_IDS) {
+ TVInfo result = instance.getTVInfo(test.getTmdb(), language, appendToResponse);
+ assertTrue("No ID", result.getId() > 0);
+ assertFalse("No runtime", result.getEpisodeRunTime().isEmpty());
+ assertFalse("No genres", result.getGenres().isEmpty());
+ assertTrue("No season count", result.getNumberOfSeasons() > 0);
+ assertTrue("No episode count", result.getNumberOfEpisodes() > 0);
+ }
+ }
+
+ /**
+ * Test of getTVAccountState method, of class TmdbTV.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetTVAccountState() throws MovieDbException {
+ LOG.info("getTVAccountState");
+
+ for (TestID test : TV_IDS) {
+ MediaState result = instance.getTVAccountState(test.getTmdb(), getSessionId());
+ assertNotNull("Null result", result);
+ assertTrue("Invalid rating", result.getRated() > -2f);
+ }
+ }
+
+ /**
+ * Test of getTVAlternativeTitles method, of class TmdbTV.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetTVAlternativeTitles() throws MovieDbException {
+ LOG.info("getTVAlternativeTitles");
+
+ for (TestID test : TV_IDS) {
+ TmdbResultsList result = instance.getTVAlternativeTitles(test.getTmdb());
+ assertFalse("No alt titles", result.isEmpty());
+ }
+ }
+
+ /**
+ * Test of getTVChanges method, of class TmdbTV.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetTVChanges() throws MovieDbException {
+ LOG.info("getTVChanges");
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ String startDate = sdf.format(DateUtils.addDays(new Date(), -14));
+ String endDate = "";
+ int maxCheck = 5;
+
+ TmdbChanges chgs = new TmdbChanges(getApiKey(), getHttpTools());
+ List changeList = chgs.getChangeList(MethodBase.TV, null, null, null);
+ LOG.info("Found {} changes to check, will check maximum of {}", changeList.size(), maxCheck);
+
+ int count = 1;
+ WrapperChanges result;
+ for (ChangeListItem item : changeList) {
+ result = instance.getTVChanges(item.getId(), startDate, endDate);
+ for (ChangeKeyItem ci : result.getChangedItems()) {
+ assertNotNull("Null changes", ci);
+ }
+
+ if (count++ > maxCheck) {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Test of getTVContentRatings method, of class TmdbTV.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetTVContentRatings() throws MovieDbException {
+ LOG.info("getTVContentRatings");
+
+ for (TestID test : TV_IDS) {
+ TmdbResultsList