Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7900b6d25b | |||
| 4747c42fc6 | |||
| 1a96343924 | |||
| 76191c13c0 | |||
| ce533c2b41 | |||
| de623ff0db | |||
| 6745f5f3d5 | |||
| 955ef0369e | |||
| 4c682731b6 | |||
| c99f60f636 | |||
| 265878d016 | |||
| 9bf7175ee8 | |||
| 00063cc85d | |||
| 2f7468914c | |||
| 4d9d53421f | |||
| 9f135c3ca7 | |||
| 7d9552a08c | |||
| 3acf07b36a | |||
| f501126b76 | |||
| 8ab8699dd5 | |||
| 6c4ba2a492 | |||
| 44df73f2d1 | |||
| 98a1b5d1b9 |
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<groupId>com.omertron</groupId>
|
<groupId>com.omertron</groupId>
|
||||||
<artifactId>themoviedbapi</artifactId>
|
<artifactId>themoviedbapi</artifactId>
|
||||||
<version>3.4</version>
|
<version>3.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>API-The MovieDB</name>
|
<name>API-The MovieDB</name>
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>Hudson CI</system>
|
<system>Jenkins CI</system>
|
||||||
<url>http://jenkins.omertron.com/job/API-TheMovieDb/</url>
|
<url>http://jenkins.omertron.com/job/API-TheMovieDb/</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
@@ -83,22 +83,22 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.1.4</version>
|
<version>2.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.1.4</version>
|
<version>2.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.1.4</version>
|
<version>2.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
<version>1.7</version>
|
<version>1.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
@@ -108,18 +108,18 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.3</version>
|
<version>1.7.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-jdk14</artifactId>
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
<version>1.7.3</version>
|
<version>1.7.5</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.artifactId}-${project.version}-r${buildNumber}</finalName>
|
<finalName>${project.artifactId}-${project.version}-${buildNumber}</finalName>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -127,8 +127,9 @@
|
|||||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
<version>1.2</version>
|
<version>1.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
|
<shortRevisionLength>10</shortRevisionLength>
|
||||||
<revisionOnScmFailure>0000</revisionOnScmFailure>
|
<doCheck>false</doCheck>
|
||||||
|
<doUpdate>false</doUpdate>
|
||||||
<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
|
<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
@@ -190,12 +191,12 @@
|
|||||||
<property name="header_line" value="The MovieDb API${line.separator}" />
|
<property name="header_line" value="The MovieDb API${line.separator}" />
|
||||||
<property name="build_date_line" value="Build Date: ${timestamp}${line.separator}" />
|
<property name="build_date_line" value="Build Date: ${timestamp}${line.separator}" />
|
||||||
<property name="version_line" value="Version: ${project.version}${line.separator}" />
|
<property name="version_line" value="Version: ${project.version}${line.separator}" />
|
||||||
<!--<property name="revision_line" value="Revision: r${buildNumber}${line.separator}" />-->
|
<property name="buildnumber_line" value="Git-SHA: ${buildNumber}${line.separator}" />
|
||||||
<echo>Writing version file: ${version_file}</echo>
|
<echo>Writing version file: ${version_file}</echo>
|
||||||
<echo file="${version_file}" append="false">${header_line}</echo>
|
<echo file="${version_file}" append="false">${header_line}</echo>
|
||||||
<echo file="${version_file}" append="true">${build_date_line}</echo>
|
<echo file="${version_file}" append="true">${build_date_line}</echo>
|
||||||
<echo file="${version_file}" append="true">${version_line}</echo>
|
<echo file="${version_file}" append="true">${version_line}</echo>
|
||||||
<!--<echo file="${version_file}" append="true">${revision_line}</echo>-->
|
<echo file="${version_file}" append="true">${buildnumber_line}</echo>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
@@ -290,12 +291,12 @@
|
|||||||
<extension>
|
<extension>
|
||||||
<groupId>org.apache.maven.scm</groupId>
|
<groupId>org.apache.maven.scm</groupId>
|
||||||
<artifactId>maven-scm-provider-gitexe</artifactId>
|
<artifactId>maven-scm-provider-gitexe</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.8.1</version>
|
||||||
</extension>
|
</extension>
|
||||||
<extension>
|
<extension>
|
||||||
<groupId>org.apache.maven.scm</groupId>
|
<groupId>org.apache.maven.scm</groupId>
|
||||||
<artifactId>maven-scm-manager-plexus</artifactId>
|
<artifactId>maven-scm-manager-plexus</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.8.1</version>
|
||||||
</extension>
|
</extension>
|
||||||
<extension>
|
<extension>
|
||||||
<groupId>org.kathrynhuxtable.maven.wagon</groupId>
|
<groupId>org.kathrynhuxtable.maven.wagon</groupId>
|
||||||
|
|||||||
@@ -45,12 +45,7 @@ public class TheMovieDbApi {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApi.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApi.class);
|
||||||
private String apiKey;
|
private String apiKey;
|
||||||
private TmdbConfiguration tmdbConfig;
|
private TmdbConfiguration tmdbConfig;
|
||||||
/*
|
// API Methods
|
||||||
* API Methods
|
|
||||||
*
|
|
||||||
* These are not set to static so that multiple instances of
|
|
||||||
* the API can co-exist
|
|
||||||
*/
|
|
||||||
private static final String BASE_MOVIE = "movie/";
|
private static final String BASE_MOVIE = "movie/";
|
||||||
private static final String BASE_PERSON = "person/";
|
private static final String BASE_PERSON = "person/";
|
||||||
private static final String BASE_COMPANY = "company/";
|
private static final String BASE_COMPANY = "company/";
|
||||||
@@ -61,18 +56,9 @@ public class TheMovieDbApi {
|
|||||||
private static final String BASE_SEARCH = "search/";
|
private static final String BASE_SEARCH = "search/";
|
||||||
private static final String BASE_LIST = "list/";
|
private static final String BASE_LIST = "list/";
|
||||||
private static final String BASE_KEYWORD = "keyword/";
|
private static final String BASE_KEYWORD = "keyword/";
|
||||||
// Account
|
private static final String BASE_JOB = "job/";
|
||||||
/*
|
private static final String BASE_DISCOVER = "discover/";
|
||||||
private final ApiUrl tmdbAccount = new ApiUrl(this, BASE_ACCOUNT);
|
// Jackson JSON configuration
|
||||||
private final ApiUrl tmdbFavouriteMovies = new ApiUrl(this, BASE_ACCOUNT, "/favorite_movies");
|
|
||||||
private final ApiUrl tmdbPostFavourite = new ApiUrl(this, BASE_ACCOUNT, "/favorite");
|
|
||||||
private final ApiUrl tmdbRatedMovies = new ApiUrl(this, BASE_ACCOUNT, "/rated_movies");
|
|
||||||
private final ApiUrl tmdbMovieWatchList = new ApiUrl(this, BASE_ACCOUNT, "/movie_watchlist");
|
|
||||||
private final ApiUrl tmdbPostMovieWatchList = new ApiUrl(this, BASE_ACCOUNT, "/movie_watchlist");
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Jackson JSON configuration
|
|
||||||
*/
|
|
||||||
private static ObjectMapper mapper = new ObjectMapper();
|
private static ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +69,7 @@ public class TheMovieDbApi {
|
|||||||
*/
|
*/
|
||||||
public TheMovieDbApi(String apiKey) throws MovieDbException {
|
public TheMovieDbApi(String apiKey) throws MovieDbException {
|
||||||
this.apiKey = apiKey;
|
this.apiKey = apiKey;
|
||||||
ApiUrl apiUrl = new ApiUrl(this, "configuration");
|
ApiUrl apiUrl = new ApiUrl(apiKey, "configuration");
|
||||||
URL configUrl = apiUrl.buildUrl();
|
URL configUrl = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(configUrl);
|
String webpage = WebBrowser.request(configUrl);
|
||||||
|
|
||||||
@@ -247,7 +233,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public TokenAuthorisation getAuthorisationToken() throws MovieDbException {
|
public TokenAuthorisation getAuthorisationToken() throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_AUTH, "token/new");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_AUTH, "token/new");
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
@@ -269,7 +255,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException {
|
public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_AUTH, "session/new");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_AUTH, "session/new");
|
||||||
|
|
||||||
if (!token.getSuccess()) {
|
if (!token.getSuccess()) {
|
||||||
LOG.warn("Authorisation token was not successful!");
|
LOG.warn("Authorisation token was not successful!");
|
||||||
@@ -303,7 +289,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public TokenSession getGuestSessionToken() throws MovieDbException {
|
public TokenSession getGuestSessionToken() throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_AUTH, "guest_session/new");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_AUTH, "guest_session/new");
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
@@ -331,8 +317,8 @@ public class TheMovieDbApi {
|
|||||||
* @param language
|
* @param language
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public MovieDb getMovieInfo(int movieId, String language) throws MovieDbException {
|
public MovieDb getMovieInfo(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE);
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE);
|
||||||
|
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
@@ -340,6 +326,8 @@ public class TheMovieDbApi {
|
|||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
try {
|
try {
|
||||||
@@ -359,8 +347,8 @@ public class TheMovieDbApi {
|
|||||||
* @param language
|
* @param language
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public MovieDb getMovieInfoImdb(String imdbId, String language) throws MovieDbException {
|
public MovieDb getMovieInfoImdb(String imdbId, String language, String... appendToResponse) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE);
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE);
|
||||||
|
|
||||||
apiUrl.addArgument(PARAM_ID, imdbId);
|
apiUrl.addArgument(PARAM_ID, imdbId);
|
||||||
|
|
||||||
@@ -368,6 +356,8 @@ public class TheMovieDbApi {
|
|||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
try {
|
try {
|
||||||
@@ -385,14 +375,16 @@ public class TheMovieDbApi {
|
|||||||
* @param country
|
* @param country
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<AlternativeTitle> getMovieAlternativeTitles(int movieId, String country) throws MovieDbException {
|
public List<AlternativeTitle> getMovieAlternativeTitles(int movieId, String country, String... appendToResponse) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/alternative_titles");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/alternative_titles");
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(country)) {
|
if (StringUtils.isNotBlank(country)) {
|
||||||
apiUrl.addArgument(PARAM_COUNTRY, country);
|
apiUrl.addArgument(PARAM_COUNTRY, country);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
try {
|
try {
|
||||||
@@ -412,11 +404,14 @@ public class TheMovieDbApi {
|
|||||||
* @param movieId
|
* @param movieId
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Person> getMovieCasts(int movieId) throws MovieDbException {
|
public List<Person> getMovieCasts(int movieId, String... appendToResponse) throws MovieDbException {
|
||||||
List<Person> people = new ArrayList<Person>();
|
List<Person> people = new ArrayList<Person>();
|
||||||
|
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/casts");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/casts");
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
@@ -451,33 +446,22 @@ public class TheMovieDbApi {
|
|||||||
* @param language
|
* @param language
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Artwork> getMovieImages(int movieId, String language) throws MovieDbException {
|
public List<Artwork> getMovieImages(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/images");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/images");
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Artwork> artwork = new ArrayList<Artwork>();
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class);
|
WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class);
|
||||||
|
return wrapper.getAll();
|
||||||
// Add all the posters to the list
|
|
||||||
for (Artwork poster : wrapper.getPosters()) {
|
|
||||||
poster.setArtworkType(ArtworkType.POSTER);
|
|
||||||
artwork.add(poster);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add all the backdrops to the list
|
|
||||||
for (Artwork backdrop : wrapper.getBackdrops()) {
|
|
||||||
backdrop.setArtworkType(ArtworkType.BACKDROP);
|
|
||||||
artwork.add(backdrop);
|
|
||||||
}
|
|
||||||
|
|
||||||
return artwork;
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOG.warn("Failed to get movie images: {}", ex.getMessage());
|
LOG.warn("Failed to get movie images: {}", ex.getMessage());
|
||||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||||
@@ -492,10 +476,12 @@ public class TheMovieDbApi {
|
|||||||
* @param movieId
|
* @param movieId
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Keyword> getMovieKeywords(int movieId) throws MovieDbException {
|
public List<Keyword> getMovieKeywords(int movieId, String... appendToResponse) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/keywords");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/keywords");
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
@@ -515,11 +501,13 @@ public class TheMovieDbApi {
|
|||||||
* @param language
|
* @param language
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<ReleaseInfo> getMovieReleaseInfo(int movieId, String language) throws MovieDbException {
|
public List<ReleaseInfo> getMovieReleaseInfo(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/releases");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/releases");
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
@@ -541,33 +529,22 @@ public class TheMovieDbApi {
|
|||||||
* @param language
|
* @param language
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Trailer> getMovieTrailers(int movieId, String language) throws MovieDbException {
|
public List<Trailer> getMovieTrailers(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||||
List<Trailer> trailers = new ArrayList<Trailer>();
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/trailers");
|
||||||
|
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/trailers");
|
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
WrapperTrailers wrapper = mapper.readValue(webpage, WrapperTrailers.class);
|
WrapperTrailers wrapper = mapper.readValue(webpage, WrapperTrailers.class);
|
||||||
|
return wrapper.getAll();
|
||||||
// Add the trailer to the return list along with it's source
|
|
||||||
for (Trailer trailer : wrapper.getQuicktime()) {
|
|
||||||
trailer.setWebsite(Trailer.WEBSITE_QUICKTIME);
|
|
||||||
trailers.add(trailer);
|
|
||||||
}
|
|
||||||
// Add the trailer to the return list along with it's source
|
|
||||||
for (Trailer trailer : wrapper.getYoutube()) {
|
|
||||||
trailer.setWebsite(Trailer.WEBSITE_YOUTUBE);
|
|
||||||
trailers.add(trailer);
|
|
||||||
}
|
|
||||||
return trailers;
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LOG.warn("Failed to get movie trailers: {}", ex.getMessage());
|
LOG.warn("Failed to get movie trailers: {}", ex.getMessage());
|
||||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||||
@@ -580,10 +557,12 @@ public class TheMovieDbApi {
|
|||||||
* @param movieId
|
* @param movieId
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Translation> getMovieTranslations(int movieId) throws MovieDbException {
|
public List<Translation> getMovieTranslations(int movieId, String... appendToResponse) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/translations");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/translations");
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
@@ -608,8 +587,8 @@ public class TheMovieDbApi {
|
|||||||
* @param page
|
* @param page
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<MovieDb> getSimilarMovies(int movieId, String language, int page) throws MovieDbException {
|
public List<MovieDb> getSimilarMovies(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/similar_movies");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/similar_movies");
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
@@ -620,6 +599,8 @@ public class TheMovieDbApi {
|
|||||||
apiUrl.addArgument(PARAM_PAGE, page);
|
apiUrl.addArgument(PARAM_PAGE, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
@@ -632,16 +613,8 @@ public class TheMovieDbApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public List<Reviews> getReviews(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||||
* Get the lists that the movie belongs to
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/reviews");
|
||||||
*
|
|
||||||
* @param movieId
|
|
||||||
* @param language
|
|
||||||
* @param page
|
|
||||||
* @throws MovieDbException
|
|
||||||
*/
|
|
||||||
public List<MovieList> getMovieLists(int movieId, String language, int page) throws MovieDbException {
|
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/lists");
|
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
@@ -652,6 +625,42 @@ public class TheMovieDbApi {
|
|||||||
apiUrl.addArgument(PARAM_PAGE, page);
|
apiUrl.addArgument(PARAM_PAGE, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
|
URL url = apiUrl.buildUrl();
|
||||||
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
|
try {
|
||||||
|
WrapperReviews wrapper = mapper.readValue(webpage, WrapperReviews.class);
|
||||||
|
return wrapper.getReviews();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOG.warn("Failed to get reviews: {}", ex.getMessage());
|
||||||
|
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the lists that the movie belongs to
|
||||||
|
*
|
||||||
|
* @param movieId
|
||||||
|
* @param language
|
||||||
|
* @param page
|
||||||
|
* @throws MovieDbException
|
||||||
|
*/
|
||||||
|
public List<MovieList> getMovieLists(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||||
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/lists");
|
||||||
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(language)) {
|
||||||
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page > 0) {
|
||||||
|
apiUrl.addArgument(PARAM_PAGE, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
apiUrl.appendToResponse(appendToResponse);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
@@ -684,7 +693,7 @@ public class TheMovieDbApi {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public List<MovieChanges> getMovieChanges(int movieId, String startDate, String endDate) throws MovieDbException {
|
public List<MovieChanges> getMovieChanges(int movieId, String startDate, String endDate) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/changes");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/changes");
|
||||||
apiUrl.addArgument(PARAM_ID, movieId);
|
apiUrl.addArgument(PARAM_ID, movieId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(startDate)) {
|
if (StringUtils.isNotBlank(startDate)) {
|
||||||
@@ -713,7 +722,7 @@ public class TheMovieDbApi {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public MovieDb getLatestMovie() throws MovieDbException {
|
public MovieDb getLatestMovie() throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/latest");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/latest");
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
@@ -735,7 +744,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<MovieDb> getUpcoming(String language, int page) throws MovieDbException {
|
public List<MovieDb> getUpcoming(String language, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "upcoming");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "upcoming");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
@@ -770,7 +779,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<MovieDb> getNowPlayingMovies(String language, int page) throws MovieDbException {
|
public List<MovieDb> getNowPlayingMovies(String language, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "now-playing");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "now-playing");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
@@ -804,7 +813,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<MovieDb> getPopularMovieList(String language, int page) throws MovieDbException {
|
public List<MovieDb> getPopularMovieList(String language, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "popular");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "popular");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
@@ -838,7 +847,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<MovieDb> getTopRatedMovies(String language, int page) throws MovieDbException {
|
public List<MovieDb> getTopRatedMovies(String language, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "top-rated");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "top-rated");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
@@ -870,7 +879,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public boolean postMovieRating(String sessionId, String rating) throws MovieDbException {
|
public boolean postMovieRating(String sessionId, String rating) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/rating");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/rating");
|
||||||
|
|
||||||
apiUrl.addArgument(PARAM_SESSION, sessionId);
|
apiUrl.addArgument(PARAM_SESSION, sessionId);
|
||||||
apiUrl.addArgument(PARAM_VALUE, rating);
|
apiUrl.addArgument(PARAM_VALUE, rating);
|
||||||
@@ -891,7 +900,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public CollectionInfo getCollectionInfo(int collectionId, String language) throws MovieDbException {
|
public CollectionInfo getCollectionInfo(int collectionId, String language) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_COLLECTION);
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_COLLECTION);
|
||||||
apiUrl.addArgument(PARAM_ID, collectionId);
|
apiUrl.addArgument(PARAM_ID, collectionId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
@@ -918,7 +927,7 @@ public class TheMovieDbApi {
|
|||||||
*/
|
*/
|
||||||
public List<Artwork> getCollectionImages(int collectionId, String language) throws MovieDbException {
|
public List<Artwork> getCollectionImages(int collectionId, String language) throws MovieDbException {
|
||||||
List<Artwork> artwork = new ArrayList<Artwork>();
|
List<Artwork> artwork = new ArrayList<Artwork>();
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_COLLECTION, "/images");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_COLLECTION, "/images");
|
||||||
apiUrl.addArgument(PARAM_ID, collectionId);
|
apiUrl.addArgument(PARAM_ID, collectionId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
@@ -963,7 +972,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public Person getPersonInfo(int personId) throws MovieDbException {
|
public Person getPersonInfo(int personId) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_PERSON);
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_PERSON);
|
||||||
|
|
||||||
apiUrl.addArgument(PARAM_ID, personId);
|
apiUrl.addArgument(PARAM_ID, personId);
|
||||||
|
|
||||||
@@ -987,7 +996,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<PersonCredit> getPersonCredits(int personId) throws MovieDbException {
|
public List<PersonCredit> getPersonCredits(int personId) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_PERSON, "/credits");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_PERSON, "/credits");
|
||||||
|
|
||||||
List<PersonCredit> personCredits = new ArrayList<PersonCredit>();
|
List<PersonCredit> personCredits = new ArrayList<PersonCredit>();
|
||||||
|
|
||||||
@@ -1023,7 +1032,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Artwork> getPersonImages(int personId) throws MovieDbException {
|
public List<Artwork> getPersonImages(int personId) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_PERSON, "/images");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_PERSON, "/images");
|
||||||
|
|
||||||
List<Artwork> personImages = new ArrayList<Artwork>();
|
List<Artwork> personImages = new ArrayList<Artwork>();
|
||||||
|
|
||||||
@@ -1067,13 +1076,53 @@ public class TheMovieDbApi {
|
|||||||
throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet");
|
throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of popular people on The Movie Database.
|
||||||
|
*
|
||||||
|
* This list refreshes every day.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws MovieDbException
|
||||||
|
*/
|
||||||
|
public List<Person> getPersonPopular() throws MovieDbException {
|
||||||
|
return getPersonPopular(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of popular people on The Movie Database.
|
||||||
|
*
|
||||||
|
* This list refreshes every day.
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
* @throws MovieDbException
|
||||||
|
*/
|
||||||
|
public List<Person> getPersonPopular(int page) throws MovieDbException {
|
||||||
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_PERSON, "/popular");
|
||||||
|
|
||||||
|
if (page > 0) {
|
||||||
|
apiUrl.addArgument(PARAM_PAGE, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
URL url = apiUrl.buildUrl();
|
||||||
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
|
try {
|
||||||
|
WrapperPersonList wrapper = mapper.readValue(webpage, WrapperPersonList.class);
|
||||||
|
return wrapper.getPersonList();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOG.warn("Failed to get person images: {}", ex.getMessage());
|
||||||
|
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the latest person id.
|
* Get the latest person id.
|
||||||
*
|
*
|
||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public Person getPersonLatest() throws MovieDbException {
|
public Person getPersonLatest() throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_PERSON, "/latest");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_PERSON, "/latest");
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
String webpage = WebBrowser.request(url);
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
@@ -1095,7 +1144,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public Company getCompanyInfo(int companyId) throws MovieDbException {
|
public Company getCompanyInfo(int companyId) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_COMPANY);
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_COMPANY);
|
||||||
|
|
||||||
apiUrl.addArgument(PARAM_ID, companyId);
|
apiUrl.addArgument(PARAM_ID, companyId);
|
||||||
|
|
||||||
@@ -1123,7 +1172,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<MovieDb> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
|
public List<MovieDb> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_COMPANY, "/movies");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_COMPANY, "/movies");
|
||||||
|
|
||||||
apiUrl.addArgument(PARAM_ID, companyId);
|
apiUrl.addArgument(PARAM_ID, companyId);
|
||||||
|
|
||||||
@@ -1158,7 +1207,7 @@ public class TheMovieDbApi {
|
|||||||
* @param language
|
* @param language
|
||||||
*/
|
*/
|
||||||
public List<Genre> getGenreList(String language) throws MovieDbException {
|
public List<Genre> getGenreList(String language) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_GENRE, "/list");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_GENRE, "/list");
|
||||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
@@ -1190,7 +1239,7 @@ public class TheMovieDbApi {
|
|||||||
* @param page
|
* @param page
|
||||||
*/
|
*/
|
||||||
public List<MovieDb> getGenreMovies(int genreId, String language, int page, boolean includeAllMovies) throws MovieDbException {
|
public List<MovieDb> getGenreMovies(int genreId, String language, int page, boolean includeAllMovies) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_GENRE, "/movies");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_GENRE, "/movies");
|
||||||
apiUrl.addArgument(PARAM_ID, genreId);
|
apiUrl.addArgument(PARAM_ID, genreId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
@@ -1229,7 +1278,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<MovieDb> searchMovie(String movieName, int searchYear, String language, boolean includeAdult, int page) throws MovieDbException {
|
public List<MovieDb> searchMovie(String movieName, int searchYear, String language, boolean includeAdult, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "movie");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "movie");
|
||||||
if (StringUtils.isNotBlank(movieName)) {
|
if (StringUtils.isNotBlank(movieName)) {
|
||||||
apiUrl.addArgument(PARAM_QUERY, movieName);
|
apiUrl.addArgument(PARAM_QUERY, movieName);
|
||||||
}
|
}
|
||||||
@@ -1270,7 +1319,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Collection> searchCollection(String query, String language, int page) throws MovieDbException {
|
public List<Collection> searchCollection(String query, String language, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "collections");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "collections");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(query)) {
|
if (StringUtils.isNotBlank(query)) {
|
||||||
apiUrl.addArgument(PARAM_QUERY, query);
|
apiUrl.addArgument(PARAM_QUERY, query);
|
||||||
@@ -1307,7 +1356,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Person> searchPeople(String personName, boolean includeAdult, int page) throws MovieDbException {
|
public List<Person> searchPeople(String personName, boolean includeAdult, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "person");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "person");
|
||||||
apiUrl.addArgument(PARAM_QUERY, personName);
|
apiUrl.addArgument(PARAM_QUERY, personName);
|
||||||
apiUrl.addArgument(PARAM_ADULT, includeAdult);
|
apiUrl.addArgument(PARAM_ADULT, includeAdult);
|
||||||
|
|
||||||
@@ -1336,7 +1385,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<MovieList> searchList(String query, String language, int page) throws MovieDbException {
|
public List<MovieList> searchList(String query, String language, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "list");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "list");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(query)) {
|
if (StringUtils.isNotBlank(query)) {
|
||||||
apiUrl.addArgument(PARAM_QUERY, query);
|
apiUrl.addArgument(PARAM_QUERY, query);
|
||||||
@@ -1375,7 +1424,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Company> searchCompanies(String companyName, int page) throws MovieDbException {
|
public List<Company> searchCompanies(String companyName, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "company");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "company");
|
||||||
apiUrl.addArgument(PARAM_QUERY, companyName);
|
apiUrl.addArgument(PARAM_QUERY, companyName);
|
||||||
|
|
||||||
if (page > 0) {
|
if (page > 0) {
|
||||||
@@ -1401,7 +1450,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<Keyword> searchKeyword(String query, int page) throws MovieDbException {
|
public List<Keyword> searchKeyword(String query, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "keyword");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "keyword");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(query)) {
|
if (StringUtils.isNotBlank(query)) {
|
||||||
apiUrl.addArgument(PARAM_QUERY, query);
|
apiUrl.addArgument(PARAM_QUERY, query);
|
||||||
@@ -1434,7 +1483,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public MovieDbList getList(String listId) throws MovieDbException {
|
public MovieDbList getList(String listId) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_LIST);
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_LIST);
|
||||||
apiUrl.addArgument(PARAM_ID, listId);
|
apiUrl.addArgument(PARAM_ID, listId);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
@@ -1459,7 +1508,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public Keyword getKeyword(String keywordId) throws MovieDbException {
|
public Keyword getKeyword(String keywordId) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_KEYWORD);
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_KEYWORD);
|
||||||
apiUrl.addArgument(PARAM_ID, keywordId);
|
apiUrl.addArgument(PARAM_ID, keywordId);
|
||||||
|
|
||||||
URL url = apiUrl.buildUrl();
|
URL url = apiUrl.buildUrl();
|
||||||
@@ -1484,7 +1533,7 @@ public class TheMovieDbApi {
|
|||||||
* @throws MovieDbException
|
* @throws MovieDbException
|
||||||
*/
|
*/
|
||||||
public List<KeywordMovie> getKeywordMovies(String keywordId, String language, int page) throws MovieDbException {
|
public List<KeywordMovie> getKeywordMovies(String keywordId, String language, int page) throws MovieDbException {
|
||||||
ApiUrl apiUrl = new ApiUrl(this, BASE_KEYWORD, "/movies");
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_KEYWORD, "/movies");
|
||||||
apiUrl.addArgument(PARAM_ID, keywordId);
|
apiUrl.addArgument(PARAM_ID, keywordId);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(language)) {
|
if (StringUtils.isNotBlank(language)) {
|
||||||
@@ -1519,4 +1568,99 @@ public class TheMovieDbApi {
|
|||||||
throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet");
|
throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet");
|
||||||
}
|
}
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
//
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="Jobs">
|
||||||
|
public List<JobDepartment> getJobs() throws MovieDbException {
|
||||||
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_JOB, "/list");
|
||||||
|
|
||||||
|
URL url = apiUrl.buildUrl();
|
||||||
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
|
try {
|
||||||
|
WrapperJobList wrapper = mapper.readValue(webpage, WrapperJobList.class);
|
||||||
|
return wrapper.getJobs();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOG.warn("Failed to get job list: {}", ex.getMessage());
|
||||||
|
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="Discover">
|
||||||
|
/**
|
||||||
|
* 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 List<MovieDb> 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 d = new Discover();
|
||||||
|
d.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(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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<MovieDb> getDiscover(Discover discover) throws MovieDbException {
|
||||||
|
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_DISCOVER, "/movie");
|
||||||
|
|
||||||
|
apiUrl.setArguments(discover.getParams());
|
||||||
|
|
||||||
|
URL url = apiUrl.buildUrl();
|
||||||
|
String webpage = WebBrowser.request(url);
|
||||||
|
|
||||||
|
try {
|
||||||
|
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||||
|
return wrapper.getMovies();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOG.warn("Failed to get job list: {}", ex.getMessage());
|
||||||
|
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public class CollectionInfo implements Serializable {
|
|||||||
private int id;
|
private int id;
|
||||||
@JsonProperty("name")
|
@JsonProperty("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
@JsonProperty("overview")
|
||||||
|
private String overview;
|
||||||
@JsonProperty("poster_path")
|
@JsonProperty("poster_path")
|
||||||
private String posterPath;
|
private String posterPath;
|
||||||
@JsonProperty("backdrop_path")
|
@JsonProperty("backdrop_path")
|
||||||
@@ -65,6 +67,10 @@ public class CollectionInfo implements Serializable {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOverview() {
|
||||||
|
return overview;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Collection> getParts() {
|
public List<Collection> getParts() {
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
@@ -87,6 +93,10 @@ public class CollectionInfo implements Serializable {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOverview(String overview) {
|
||||||
|
this.overview = overview;
|
||||||
|
}
|
||||||
|
|
||||||
public void setParts(List<Collection> parts) {
|
public void setParts(List<Collection> parts) {
|
||||||
this.parts = parts;
|
this.parts = parts;
|
||||||
}
|
}
|
||||||
@@ -115,6 +125,7 @@ public class CollectionInfo implements Serializable {
|
|||||||
StringBuilder sb = new StringBuilder("[CollectionInfo=");
|
StringBuilder sb = new StringBuilder("[CollectionInfo=");
|
||||||
sb.append("[id=").append(id);
|
sb.append("[id=").append(id);
|
||||||
sb.append("],[name=").append(name);
|
sb.append("],[name=").append(name);
|
||||||
|
sb.append("],[overview=").append(overview);
|
||||||
sb.append("],[posterPath=").append(posterPath);
|
sb.append("],[posterPath=").append(posterPath);
|
||||||
sb.append("],[backdropPath=").append(backdropPath);
|
sb.append("],[backdropPath=").append(backdropPath);
|
||||||
sb.append("],[# of parts=").append(parts.size());
|
sb.append("],[# of parts=").append(parts.size());
|
||||||
|
|||||||
@@ -0,0 +1,262 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013 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;private either version 3 of the License;private or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* TheMovieDB API is distributed in the hope that it will be useful;private
|
||||||
|
* 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;private see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.omertron.themoviedbapi.model;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import static com.omertron.themoviedbapi.tools.ApiUrl.*;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a discover object for use in the MovieDbApi
|
||||||
|
*
|
||||||
|
* This allows you to just add the search components you are concerned with
|
||||||
|
*
|
||||||
|
* @author stuart.boston
|
||||||
|
*/
|
||||||
|
public class Discover {
|
||||||
|
|
||||||
|
private Map<String, String> params = new HashMap<String, String>();
|
||||||
|
private static final String PARAM_PRIMARY_RELEASE_YEAR = "primary_release_year=";
|
||||||
|
private static final String PARAM_VOTE_COUNT_GTE = "vote_count.gte=";
|
||||||
|
private static final String PARAM_VOTE_AVERAGE_GTE = "vote_average.gte=";
|
||||||
|
private static final String PARAM_WITH_GENRES = "with_genres=";
|
||||||
|
private static final String PARAM_RELEASE_DATE_GTE = "release_date.gte=";
|
||||||
|
private static final String PARAM_RELEASE_DATE_LTE = "release_date.lte=";
|
||||||
|
private static final String PARAM_CERTIFICATION_COUNTRY = "certification_country=";
|
||||||
|
private static final String PARAM_CERTIFICATION_LTE = "certification.lte=";
|
||||||
|
private static final String PARAM_WITH_COMPANIES = "with_companies=";
|
||||||
|
private static final String PARAM_SORT_BY = "sort_by=";
|
||||||
|
private static final int YEAR_MIN = 1900;
|
||||||
|
private static final int YEAR_MAX = 2100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parameters
|
||||||
|
*
|
||||||
|
* This will be used to construct the URL in the API
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String, String> getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum value is 1 if included.
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
*/
|
||||||
|
public Discover page(int page) {
|
||||||
|
if (page > 0) {
|
||||||
|
params.put(PARAM_PAGE, String.valueOf(page));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ISO 639-1 code
|
||||||
|
*
|
||||||
|
* @param language
|
||||||
|
*/
|
||||||
|
public Discover language(String language) {
|
||||||
|
if (StringUtils.isNotBlank(language)) {
|
||||||
|
params.put(PARAM_LANGUAGE, language);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Available options are <br>
|
||||||
|
* vote_average.desc<br>
|
||||||
|
* vote_average.asc<br>
|
||||||
|
* release_date.desc<br>
|
||||||
|
* release_date.asc<br>
|
||||||
|
* popularity.desc<br>
|
||||||
|
* popularity.asc
|
||||||
|
*
|
||||||
|
* @param sortBy
|
||||||
|
*/
|
||||||
|
public Discover sortBy(String sortBy) {
|
||||||
|
if (StringUtils.isNotBlank(sortBy)) {
|
||||||
|
params.put(PARAM_SORT_BY, sortBy);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the inclusion of adult titles
|
||||||
|
*
|
||||||
|
* @param includeAdult
|
||||||
|
*/
|
||||||
|
public Discover includeAdult(boolean includeAdult) {
|
||||||
|
params.put(PARAM_ADULT, String.valueOf(includeAdult));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the results release dates to matches that include this value.
|
||||||
|
*
|
||||||
|
* @param year
|
||||||
|
*/
|
||||||
|
public Discover year(int year) {
|
||||||
|
if (checkYear(year)) {
|
||||||
|
params.put(PARAM_YEAR, String.valueOf(year));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the results so that only the primary release date year has this value
|
||||||
|
*
|
||||||
|
* @param primaryReleaseYear
|
||||||
|
*/
|
||||||
|
public Discover primaryReleaseYear(int primaryReleaseYear) {
|
||||||
|
if (checkYear(primaryReleaseYear)) {
|
||||||
|
params.put(PARAM_PRIMARY_RELEASE_YEAR, String.valueOf(primaryReleaseYear));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only include movies that are equal to, or have a vote count higher than this value
|
||||||
|
*
|
||||||
|
* @param voteCountGte
|
||||||
|
*/
|
||||||
|
public Discover voteCountGte(int voteCountGte) {
|
||||||
|
if (voteCountGte > 0) {
|
||||||
|
params.put(PARAM_VOTE_COUNT_GTE, String.valueOf(voteCountGte));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only include movies that are equal to, or have a higher average rating than this value
|
||||||
|
*
|
||||||
|
* @param voteAverageGte
|
||||||
|
*/
|
||||||
|
public Discover voteAverageGte(float voteAverageGte) {
|
||||||
|
if (voteAverageGte > 0) {
|
||||||
|
params.put(PARAM_VOTE_AVERAGE_GTE, String.valueOf(voteAverageGte));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 withGenres
|
||||||
|
*/
|
||||||
|
public Discover withGenres(String withGenres) {
|
||||||
|
if (StringUtils.isNotBlank(withGenres)) {
|
||||||
|
params.put(PARAM_WITH_GENRES, withGenres);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum release to include.
|
||||||
|
*
|
||||||
|
* Expected format is YYYY-MM-DD.
|
||||||
|
*
|
||||||
|
* @param releaseDateGte
|
||||||
|
*/
|
||||||
|
public Discover releaseDateGte(String releaseDateGte) {
|
||||||
|
if (StringUtils.isNotBlank(releaseDateGte)) {
|
||||||
|
params.put(PARAM_RELEASE_DATE_GTE, releaseDateGte);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum release to include.
|
||||||
|
*
|
||||||
|
* Expected format is YYYY-MM-DD.
|
||||||
|
*
|
||||||
|
* @param releaseDateLte
|
||||||
|
*/
|
||||||
|
public Discover releaseDateLte(String releaseDateLte) {
|
||||||
|
if (StringUtils.isNotBlank(releaseDateLte)) {
|
||||||
|
params.put(PARAM_RELEASE_DATE_LTE, releaseDateLte);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only include movies with certifications for a specific country.
|
||||||
|
*
|
||||||
|
* When this value is specified, 'certificationLte' is required.
|
||||||
|
*
|
||||||
|
* A ISO 3166-1 is expected
|
||||||
|
*
|
||||||
|
* @param certificationCountry
|
||||||
|
*/
|
||||||
|
public Discover certificationCountry(String certificationCountry) {
|
||||||
|
if (StringUtils.isNotBlank(certificationCountry)) {
|
||||||
|
params.put(PARAM_CERTIFICATION_COUNTRY, certificationCountry);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only include movies with this certification and lower.
|
||||||
|
*
|
||||||
|
* Expected value is a valid certification for the specified 'certificationCountry'.
|
||||||
|
*
|
||||||
|
* @param certificationLte
|
||||||
|
*/
|
||||||
|
public Discover certificationLte(String certificationLte) {
|
||||||
|
if (StringUtils.isNotBlank(certificationLte)) {
|
||||||
|
params.put(PARAM_CERTIFICATION_LTE, certificationLte);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* @param withCompanies
|
||||||
|
*/
|
||||||
|
public Discover withCompanies(String withCompanies) {
|
||||||
|
if (StringUtils.isNotBlank(withCompanies)) {
|
||||||
|
params.put(PARAM_WITH_COMPANIES, withCompanies);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check the year is between the min and max
|
||||||
|
*
|
||||||
|
* @param year
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean checkYear(int year) {
|
||||||
|
return (year >= YEAR_MIN && year <= YEAR_MAX);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.omertron.themoviedbapi.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import java.util.List;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class JobDepartment {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
// Logger
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(MovieChanges.class);
|
||||||
|
// Properties
|
||||||
|
@JsonProperty("department")
|
||||||
|
private String department;
|
||||||
|
@JsonProperty("job_list")
|
||||||
|
private List<String> jobs;
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="Getters">
|
||||||
|
public String getDepartment() {
|
||||||
|
return department;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getJobs() {
|
||||||
|
return jobs;
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="Setters">
|
||||||
|
public void setDepartment(String department) {
|
||||||
|
this.department = department;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobs(List<String> jobs) {
|
||||||
|
this.jobs = jobs;
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle unknown properties and print a message
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
@JsonAnySetter
|
||||||
|
public void handleUnknown(String key, Object value) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unknown property: '").append(key);
|
||||||
|
sb.append("' value: '").append(value).append("'");
|
||||||
|
LOG.trace(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,16 @@ package com.omertron.themoviedbapi.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperImages;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperMovie;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperMovieList;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperReviews;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperTrailers;
|
||||||
|
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -87,6 +97,27 @@ public class MovieDb implements Serializable {
|
|||||||
private int voteCount;
|
private int voteCount;
|
||||||
@JsonProperty("status")
|
@JsonProperty("status")
|
||||||
private String status;
|
private String status;
|
||||||
|
// AppendToResponse Properties
|
||||||
|
@JsonProperty("alternative_titles")
|
||||||
|
private WrapperAlternativeTitles alternativeTitles;
|
||||||
|
@JsonProperty("casts")
|
||||||
|
private WrapperMovieCasts casts;
|
||||||
|
@JsonProperty("images")
|
||||||
|
private WrapperImages images;
|
||||||
|
@JsonProperty("keywords")
|
||||||
|
private WrapperMovieKeywords keywords;
|
||||||
|
@JsonProperty("releases")
|
||||||
|
private WrapperReleaseInfo releases;
|
||||||
|
@JsonProperty("trailers")
|
||||||
|
private WrapperTrailers trailers;
|
||||||
|
@JsonProperty("translations")
|
||||||
|
private WrapperTranslations translations;
|
||||||
|
@JsonProperty("similar_movies")
|
||||||
|
private WrapperMovie similarMovies;
|
||||||
|
@JsonProperty("reviews")
|
||||||
|
private WrapperReviews reviews;
|
||||||
|
@JsonProperty("lists")
|
||||||
|
private WrapperMovieList lists;
|
||||||
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="Getter methods">
|
// <editor-fold defaultstate="collapsed" desc="Getter methods">
|
||||||
public String getBackdropPath() {
|
public String getBackdropPath() {
|
||||||
@@ -276,6 +307,96 @@ public class MovieDb implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
|
||||||
|
public List<AlternativeTitle> getAlternativeTitles() {
|
||||||
|
return alternativeTitles.getTitles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PersonCast> getCast() {
|
||||||
|
return casts.getCast();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PersonCrew> getCrew() {
|
||||||
|
return casts.getCrew();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Artwork> getImages() {
|
||||||
|
return images.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Keyword> getKeywords() {
|
||||||
|
return keywords.getKeywords();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ReleaseInfo> getReleases() {
|
||||||
|
return releases.getCountries();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Trailer> getTrailers() {
|
||||||
|
return trailers.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Translation> getTranslations() {
|
||||||
|
return translations.getTranslations();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MovieDb> getSimilarMovies() {
|
||||||
|
return similarMovies.getMovies();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MovieList> getLists() {
|
||||||
|
return lists.getMovieList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Reviews> getReviews() {
|
||||||
|
return reviews.getReviews();
|
||||||
|
}
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters">
|
||||||
|
public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) {
|
||||||
|
this.alternativeTitles = alternativeTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCasts(WrapperMovieCasts casts) {
|
||||||
|
this.casts = casts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImages(WrapperImages images) {
|
||||||
|
this.images = images;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeywords(WrapperMovieKeywords keywords) {
|
||||||
|
this.keywords = keywords;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReleases(WrapperReleaseInfo releases) {
|
||||||
|
this.releases = releases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrailers(WrapperTrailers trailers) {
|
||||||
|
this.trailers = trailers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTranslations(WrapperTranslations translations) {
|
||||||
|
this.translations = translations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimilarMovies(WrapperMovie similarMovies) {
|
||||||
|
this.similarMovies = similarMovies;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLists(WrapperMovieList lists) {
|
||||||
|
this.lists = lists;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReviews(WrapperReviews reviews) {
|
||||||
|
this.reviews = reviews;
|
||||||
|
}
|
||||||
|
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle unknown properties and print a message
|
* Handle unknown properties and print a message
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.omertron.themoviedbapi.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Stuart
|
||||||
|
*/
|
||||||
|
public class Reviews implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Logger
|
||||||
|
*/
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(Reviews.class);
|
||||||
|
/*
|
||||||
|
* Properties
|
||||||
|
*/
|
||||||
|
@JsonProperty("id")
|
||||||
|
private String id;
|
||||||
|
@JsonProperty("author")
|
||||||
|
private String author;
|
||||||
|
@JsonProperty("content")
|
||||||
|
private String content;
|
||||||
|
@JsonProperty("url")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Getter methods">
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
// </editor-fold>
|
||||||
|
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthor(String author) {
|
||||||
|
this.author = author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
// </editor-fold>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle unknown properties and print a message
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
@JsonAnySetter
|
||||||
|
public void handleUnknown(String key, Object value) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unknown property: '").append(key);
|
||||||
|
sb.append("' value: '").append(value).append("'");
|
||||||
|
LOG.trace(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,13 +19,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.omertron.themoviedbapi.tools;
|
package com.omertron.themoviedbapi.tools;
|
||||||
|
|
||||||
import com.omertron.themoviedbapi.TheMovieDbApi;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class ApiUrl {
|
|||||||
/*
|
/*
|
||||||
* Properties
|
* Properties
|
||||||
*/
|
*/
|
||||||
private TheMovieDbApi tmdb;
|
private String apiKey;
|
||||||
private String method;
|
private String method;
|
||||||
private String submethod;
|
private String submethod;
|
||||||
private Map<String, String> arguments = new HashMap<String, String>();
|
private Map<String, String> arguments = new HashMap<String, String>();
|
||||||
@@ -67,7 +67,6 @@ public class ApiUrl {
|
|||||||
public static final String PARAM_ID = "id=";
|
public static final String PARAM_ID = "id=";
|
||||||
public static final String PARAM_LANGUAGE = "language=";
|
public static final String PARAM_LANGUAGE = "language=";
|
||||||
public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
|
public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
|
||||||
// public static final String PARAM_MOVIE_ID = "movie_id=";
|
|
||||||
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist=";
|
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist=";
|
||||||
public static final String PARAM_PAGE = "page=";
|
public static final String PARAM_PAGE = "page=";
|
||||||
public static final String PARAM_QUERY = "query=";
|
public static final String PARAM_QUERY = "query=";
|
||||||
@@ -75,6 +74,7 @@ public class ApiUrl {
|
|||||||
public static final String PARAM_TOKEN = "request_token=";
|
public static final String PARAM_TOKEN = "request_token=";
|
||||||
public static final String PARAM_VALUE = "value=";
|
public static final String PARAM_VALUE = "value=";
|
||||||
public static final String PARAM_YEAR = "year=";
|
public static final String PARAM_YEAR = "year=";
|
||||||
|
private static final String APPEND_TO_RESPONSE = "append_to_response=";
|
||||||
|
|
||||||
//<editor-fold defaultstate="collapsed" desc="Constructor Methods">
|
//<editor-fold defaultstate="collapsed" desc="Constructor Methods">
|
||||||
/**
|
/**
|
||||||
@@ -82,8 +82,8 @@ public class ApiUrl {
|
|||||||
*
|
*
|
||||||
* @param method
|
* @param method
|
||||||
*/
|
*/
|
||||||
public ApiUrl(TheMovieDbApi tmdb, String method) {
|
public ApiUrl(String apiKey, String method) {
|
||||||
this.tmdb = tmdb;
|
this.apiKey = apiKey;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.submethod = DEFAULT_STRING;
|
this.submethod = DEFAULT_STRING;
|
||||||
}
|
}
|
||||||
@@ -94,8 +94,8 @@ public class ApiUrl {
|
|||||||
* @param method
|
* @param method
|
||||||
* @param submethod
|
* @param submethod
|
||||||
*/
|
*/
|
||||||
public ApiUrl(TheMovieDbApi tmdb, String method, String submethod) {
|
public ApiUrl(String apiKey, String method, String submethod) {
|
||||||
this.tmdb = tmdb;
|
this.apiKey = apiKey;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.submethod = submethod;
|
this.submethod = submethod;
|
||||||
}
|
}
|
||||||
@@ -113,11 +113,14 @@ public class ApiUrl {
|
|||||||
// We have either a queury, or a direct request
|
// We have either a queury, or a direct request
|
||||||
if (arguments.containsKey(PARAM_QUERY)) {
|
if (arguments.containsKey(PARAM_QUERY)) {
|
||||||
// Append the suffix of the API URL
|
// Append the suffix of the API URL
|
||||||
|
if(StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
|
||||||
|
urlString.deleteCharAt(urlString.length()-1);
|
||||||
|
}
|
||||||
urlString.append(submethod);
|
urlString.append(submethod);
|
||||||
|
|
||||||
// Append the key information
|
// Append the key information
|
||||||
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
|
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
|
||||||
urlString.append(tmdb.getApiKey());
|
urlString.append(apiKey);
|
||||||
|
|
||||||
// Append the search term
|
// Append the search term
|
||||||
urlString.append(DELIMITER_SUBSEQUENT);
|
urlString.append(DELIMITER_SUBSEQUENT);
|
||||||
@@ -128,11 +131,12 @@ public class ApiUrl {
|
|||||||
try {
|
try {
|
||||||
urlString.append(URLEncoder.encode(query, "UTF-8"));
|
urlString.append(URLEncoder.encode(query, "UTF-8"));
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} catch (UnsupportedEncodingException ex) {
|
||||||
LOG.trace("Unable to encode query: '" + query + "' trying raw.");
|
LOG.trace("Unable to encode query: '{}' trying raw.", query);
|
||||||
// If we can't encode it, try it raw
|
// If we can't encode it, try it raw
|
||||||
urlString.append(query);
|
urlString.append(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the query from the arguments so it is not added later
|
||||||
arguments.remove(PARAM_QUERY);
|
arguments.remove(PARAM_QUERY);
|
||||||
} else {
|
} else {
|
||||||
// Append the ID if provided
|
// Append the ID if provided
|
||||||
@@ -142,11 +146,14 @@ public class ApiUrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Append the suffix of the API URL
|
// Append the suffix of the API URL
|
||||||
|
if(StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
|
||||||
|
urlString.deleteCharAt(urlString.length()-1);
|
||||||
|
}
|
||||||
urlString.append(submethod);
|
urlString.append(submethod);
|
||||||
|
|
||||||
// Append the key information
|
// Append the key information
|
||||||
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
|
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
|
||||||
urlString.append(tmdb.getApiKey());
|
urlString.append(apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, String> argEntry : arguments.entrySet()) {
|
for (Map.Entry<String, String> argEntry : arguments.entrySet()) {
|
||||||
@@ -195,6 +202,16 @@ public class ApiUrl {
|
|||||||
arguments.put(key, Boolean.toString(value));
|
arguments.put(key, Boolean.toString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add arguments individually
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public void addArgument(String key, float value) {
|
||||||
|
arguments.put(key, Float.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the arguments
|
* Clear the arguments
|
||||||
*/
|
*/
|
||||||
@@ -210,4 +227,25 @@ public class ApiUrl {
|
|||||||
public void setArguments(Map<String, String> args) {
|
public void setArguments(Map<String, String> args) {
|
||||||
arguments.putAll(args);
|
arguments.putAll(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append any optional parameters to the URL
|
||||||
|
*
|
||||||
|
* @param appendToResponse
|
||||||
|
*/
|
||||||
|
public void appendToResponse(String[] appendToResponse) {
|
||||||
|
if (appendToResponse.length > 0) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
boolean first = Boolean.TRUE;
|
||||||
|
for (String append : appendToResponse) {
|
||||||
|
if (first) {
|
||||||
|
first = Boolean.FALSE;
|
||||||
|
} else {
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
sb.append(append);
|
||||||
|
}
|
||||||
|
addArgument(APPEND_TO_RESPONSE, sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ package com.omertron.themoviedbapi.wrapper;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.omertron.themoviedbapi.model.Artwork;
|
import com.omertron.themoviedbapi.model.Artwork;
|
||||||
|
import com.omertron.themoviedbapi.model.ArtworkType;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -34,11 +38,11 @@ public class WrapperImages extends WrapperBase {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@JsonProperty("backdrops")
|
@JsonProperty("backdrops")
|
||||||
private List<Artwork> backdrops;
|
private List<Artwork> backdrops = Collections.EMPTY_LIST;
|
||||||
@JsonProperty("posters")
|
@JsonProperty("posters")
|
||||||
private List<Artwork> posters;
|
private List<Artwork> posters = Collections.EMPTY_LIST;
|
||||||
@JsonProperty("profiles")
|
@JsonProperty("profiles")
|
||||||
private List<Artwork> profiles;
|
private List<Artwork> profiles = Collections.EMPTY_LIST;
|
||||||
|
|
||||||
public WrapperImages() {
|
public WrapperImages() {
|
||||||
super(LoggerFactory.getLogger(WrapperImages.class));
|
super(LoggerFactory.getLogger(WrapperImages.class));
|
||||||
@@ -71,4 +75,48 @@ public class WrapperImages extends WrapperBase {
|
|||||||
this.profiles = profiles;
|
this.profiles = profiles;
|
||||||
}
|
}
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of all the artwork with their types.
|
||||||
|
*
|
||||||
|
* Leaving the parameters blank will return all types
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Artwork> getAll(ArtworkType... artworkList) {
|
||||||
|
List<Artwork> artwork = new ArrayList<Artwork>();
|
||||||
|
List<ArtworkType> types;
|
||||||
|
|
||||||
|
if (artworkList.length > 0) {
|
||||||
|
types = new ArrayList<ArtworkType>(Arrays.asList(artworkList));
|
||||||
|
} else {
|
||||||
|
types = new ArrayList<ArtworkType>(Arrays.asList(ArtworkType.values()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (types.contains(ArtworkType.POSTER)) {
|
||||||
|
// Add all the posters to the list
|
||||||
|
for (Artwork poster : posters) {
|
||||||
|
poster.setArtworkType(ArtworkType.POSTER);
|
||||||
|
artwork.add(poster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (types.contains(ArtworkType.BACKDROP)) {
|
||||||
|
// Add all the backdrops to the list
|
||||||
|
for (Artwork backdrop : backdrops) {
|
||||||
|
backdrop.setArtworkType(ArtworkType.BACKDROP);
|
||||||
|
artwork.add(backdrop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (types.contains(ArtworkType.PROFILE)) {
|
||||||
|
// Add all the backdrops to the list
|
||||||
|
for (Artwork backdrop : profiles) {
|
||||||
|
backdrop.setArtworkType(ArtworkType.PROFILE);
|
||||||
|
artwork.add(backdrop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return artwork;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.omertron.themoviedbapi.wrapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.omertron.themoviedbapi.model.AlternativeTitle;
|
||||||
|
import com.omertron.themoviedbapi.model.JobDepartment;
|
||||||
|
import java.util.List;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Stuart
|
||||||
|
*/
|
||||||
|
public class WrapperJobList {
|
||||||
|
|
||||||
|
// Logger
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(WrapperJobList.class);
|
||||||
|
// Properties
|
||||||
|
@JsonProperty("jobs")
|
||||||
|
private List<JobDepartment> jobs;
|
||||||
|
|
||||||
|
public List<JobDepartment> getJobs() {
|
||||||
|
return jobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJobs(List<JobDepartment> jobs) {
|
||||||
|
this.jobs = jobs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle unknown properties and print a message
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
@JsonAnySetter
|
||||||
|
public void handleUnknown(String key, Object value) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Unknown property: '").append(key);
|
||||||
|
sb.append("' value: '").append(value).append("'");
|
||||||
|
LOG.trace(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.omertron.themoviedbapi.wrapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.omertron.themoviedbapi.model.MovieList;
|
||||||
|
import com.omertron.themoviedbapi.model.Person;
|
||||||
|
import java.util.List;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Stuart
|
||||||
|
*/
|
||||||
|
public class WrapperPersonList extends WrapperBase {
|
||||||
|
/*
|
||||||
|
* Properties
|
||||||
|
*/
|
||||||
|
|
||||||
|
@JsonProperty("results")
|
||||||
|
private List<Person> personList;
|
||||||
|
|
||||||
|
public WrapperPersonList() {
|
||||||
|
super(LoggerFactory.getLogger(WrapperPersonList.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Person> getPersonList() {
|
||||||
|
return personList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPersonList(List<Person> personList) {
|
||||||
|
this.personList = personList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2004-2013 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.omertron.themoviedbapi.wrapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.omertron.themoviedbapi.model.Reviews;
|
||||||
|
import java.util.List;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author stuart.boston
|
||||||
|
*/
|
||||||
|
public class WrapperReviews extends WrapperBase {
|
||||||
|
/*
|
||||||
|
* Properties
|
||||||
|
*/
|
||||||
|
|
||||||
|
@JsonProperty("results")
|
||||||
|
private List<Reviews> reviews;
|
||||||
|
|
||||||
|
public WrapperReviews() {
|
||||||
|
super(LoggerFactory.getLogger(WrapperReviews.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Reviews> getReviews() {
|
||||||
|
return reviews;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReviews(List<Reviews> reviews) {
|
||||||
|
this.reviews = reviews;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ package com.omertron.themoviedbapi.wrapper;
|
|||||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.omertron.themoviedbapi.model.Trailer;
|
import com.omertron.themoviedbapi.model.Trailer;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -74,6 +75,27 @@ public class WrapperTrailers {
|
|||||||
}
|
}
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a combined list of the trailers with their source website
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Trailer> getAll() {
|
||||||
|
List<Trailer> trailers = new ArrayList<Trailer>();
|
||||||
|
|
||||||
|
// Add the trailer to the return list along with it's source
|
||||||
|
for (Trailer trailer : quicktime) {
|
||||||
|
trailer.setWebsite(Trailer.WEBSITE_QUICKTIME);
|
||||||
|
trailers.add(trailer);
|
||||||
|
}
|
||||||
|
// Add the trailer to the return list along with it's source
|
||||||
|
for (Trailer trailer : youtube) {
|
||||||
|
trailer.setWebsite(Trailer.WEBSITE_YOUTUBE);
|
||||||
|
trailers.add(trailer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return trailers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle unknown properties and print a message
|
* Handle unknown properties and print a message
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<directory>${basedir}</directory>
|
<directory>${basedir}</directory>
|
||||||
<outputDirectory></outputDirectory>
|
<outputDirectory></outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>readme.txt</include>
|
<include>README.md</include>
|
||||||
</includes>
|
</includes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ import com.omertron.themoviedbapi.model.Artwork;
|
|||||||
import com.omertron.themoviedbapi.model.Collection;
|
import com.omertron.themoviedbapi.model.Collection;
|
||||||
import com.omertron.themoviedbapi.model.CollectionInfo;
|
import com.omertron.themoviedbapi.model.CollectionInfo;
|
||||||
import com.omertron.themoviedbapi.model.Company;
|
import com.omertron.themoviedbapi.model.Company;
|
||||||
|
import com.omertron.themoviedbapi.model.Discover;
|
||||||
import com.omertron.themoviedbapi.model.Genre;
|
import com.omertron.themoviedbapi.model.Genre;
|
||||||
|
import com.omertron.themoviedbapi.model.JobDepartment;
|
||||||
import com.omertron.themoviedbapi.model.Keyword;
|
import com.omertron.themoviedbapi.model.Keyword;
|
||||||
import com.omertron.themoviedbapi.model.KeywordMovie;
|
import com.omertron.themoviedbapi.model.KeywordMovie;
|
||||||
import com.omertron.themoviedbapi.model.MovieChanges;
|
import com.omertron.themoviedbapi.model.MovieChanges;
|
||||||
@@ -34,6 +36,7 @@ import com.omertron.themoviedbapi.model.MovieList;
|
|||||||
import com.omertron.themoviedbapi.model.Person;
|
import com.omertron.themoviedbapi.model.Person;
|
||||||
import com.omertron.themoviedbapi.model.PersonCredit;
|
import com.omertron.themoviedbapi.model.PersonCredit;
|
||||||
import com.omertron.themoviedbapi.model.ReleaseInfo;
|
import com.omertron.themoviedbapi.model.ReleaseInfo;
|
||||||
|
import com.omertron.themoviedbapi.model.Reviews;
|
||||||
import com.omertron.themoviedbapi.model.TmdbConfiguration;
|
import com.omertron.themoviedbapi.model.TmdbConfiguration;
|
||||||
import com.omertron.themoviedbapi.model.TokenAuthorisation;
|
import com.omertron.themoviedbapi.model.TokenAuthorisation;
|
||||||
import com.omertron.themoviedbapi.model.TokenSession;
|
import com.omertron.themoviedbapi.model.TokenSession;
|
||||||
@@ -62,7 +65,8 @@ public class TheMovieDbApiTest {
|
|||||||
private static TheMovieDbApi tmdb;
|
private static TheMovieDbApi tmdb;
|
||||||
// Test data
|
// Test data
|
||||||
private static final int ID_MOVIE_BLADE_RUNNER = 78;
|
private static final int ID_MOVIE_BLADE_RUNNER = 78;
|
||||||
private static final int ID_MOVIE_STAR_WARS_COLLECTION = 10;
|
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_PERSON_BRUCE_WILLIS = 62;
|
||||||
private static final int ID_COMPANY_LUCASFILM = 1;
|
private static final int ID_COMPANY_LUCASFILM = 1;
|
||||||
private static final String COMPANY_NAME = "Marvel Studios";
|
private static final String COMPANY_NAME = "Marvel Studios";
|
||||||
@@ -137,7 +141,7 @@ public class TheMovieDbApiTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetMovieInfo() throws MovieDbException {
|
public void testGetMovieInfo() throws MovieDbException {
|
||||||
LOG.info("getMovieInfo");
|
LOG.info("getMovieInfo");
|
||||||
MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH);
|
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());
|
assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +152,7 @@ public class TheMovieDbApiTest {
|
|||||||
public void testGetMovieAlternativeTitles() throws MovieDbException {
|
public void testGetMovieAlternativeTitles() throws MovieDbException {
|
||||||
LOG.info("getMovieAlternativeTitles");
|
LOG.info("getMovieAlternativeTitles");
|
||||||
String country = "";
|
String country = "";
|
||||||
List<AlternativeTitle> results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country);
|
List<AlternativeTitle> results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country, "casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
|
||||||
assertTrue("No alternative titles found", results.size() > 0);
|
assertTrue("No alternative titles found", results.size() > 0);
|
||||||
|
|
||||||
country = "US";
|
country = "US";
|
||||||
@@ -163,7 +167,7 @@ public class TheMovieDbApiTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetMovieCasts() throws MovieDbException {
|
public void testGetMovieCasts() throws MovieDbException {
|
||||||
LOG.info("getMovieCasts");
|
LOG.info("getMovieCasts");
|
||||||
List<Person> people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER);
|
List<Person> people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
|
||||||
assertTrue("No cast information", people.size() > 0);
|
assertTrue("No cast information", people.size() > 0);
|
||||||
|
|
||||||
String name1 = "Harrison Ford";
|
String name1 = "Harrison Ford";
|
||||||
@@ -242,7 +246,7 @@ public class TheMovieDbApiTest {
|
|||||||
public void testGetCollectionInfo() throws MovieDbException {
|
public void testGetCollectionInfo() throws MovieDbException {
|
||||||
LOG.info("getCollectionInfo");
|
LOG.info("getCollectionInfo");
|
||||||
String language = "";
|
String language = "";
|
||||||
CollectionInfo result = tmdb.getCollectionInfo(ID_MOVIE_STAR_WARS_COLLECTION, language);
|
CollectionInfo result = tmdb.getCollectionInfo(ID_COLLECTION_STAR_WARS, language);
|
||||||
assertFalse("No collection information", result.getParts().isEmpty());
|
assertFalse("No collection information", result.getParts().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,7 +482,7 @@ public class TheMovieDbApiTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetCollectionImages() throws Exception {
|
public void testGetCollectionImages() throws Exception {
|
||||||
LOG.info("getCollectionImages");
|
LOG.info("getCollectionImages");
|
||||||
List<Artwork> result = tmdb.getCollectionImages(ID_MOVIE_STAR_WARS_COLLECTION, LANGUAGE_DEFAULT);
|
List<Artwork> result = tmdb.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT);
|
||||||
assertFalse("No artwork found", result.isEmpty());
|
assertFalse("No artwork found", result.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,7 +519,7 @@ public class TheMovieDbApiTest {
|
|||||||
/**
|
/**
|
||||||
* Test of getGuestSessionToken method, of class TheMovieDbApi.
|
* Test of getGuestSessionToken method, of class TheMovieDbApi.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Ignore("Not ready yet")
|
||||||
public void testGetGuestSessionToken() throws Exception {
|
public void testGetGuestSessionToken() throws Exception {
|
||||||
LOG.info("getGuestSessionToken");
|
LOG.info("getGuestSessionToken");
|
||||||
TokenSession result = tmdb.getGuestSessionToken();
|
TokenSession result = tmdb.getGuestSessionToken();
|
||||||
@@ -585,7 +589,7 @@ public class TheMovieDbApiTest {
|
|||||||
LOG.info("searchList");
|
LOG.info("searchList");
|
||||||
String query = "watch";
|
String query = "watch";
|
||||||
int page = 0;
|
int page = 0;
|
||||||
List result = tmdb.searchList(query, LANGUAGE_DEFAULT, page);
|
List<MovieList> result = tmdb.searchList(query, LANGUAGE_DEFAULT, page);
|
||||||
assertFalse("No lists found", result == null);
|
assertFalse("No lists found", result == null);
|
||||||
assertTrue("No lists found", result.size() > 0);
|
assertTrue("No lists found", result.size() > 0);
|
||||||
}
|
}
|
||||||
@@ -608,6 +612,7 @@ public class TheMovieDbApiTest {
|
|||||||
*
|
*
|
||||||
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
|
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
|
||||||
*/
|
*/
|
||||||
|
@Ignore("Not ready yet")
|
||||||
public void testPostMovieRating() throws Exception {
|
public void testPostMovieRating() throws Exception {
|
||||||
LOG.info("postMovieRating");
|
LOG.info("postMovieRating");
|
||||||
String sessionId = "";
|
String sessionId = "";
|
||||||
@@ -622,8 +627,8 @@ public class TheMovieDbApiTest {
|
|||||||
/**
|
/**
|
||||||
* Test of getPersonChanges method, of class TheMovieDbApi.
|
* Test of getPersonChanges method, of class TheMovieDbApi.
|
||||||
*
|
*
|
||||||
* TODO: Fix the method before testing
|
|
||||||
*/
|
*/
|
||||||
|
@Ignore("Not ready yet")
|
||||||
public void testGetPersonChanges() throws Exception {
|
public void testGetPersonChanges() throws Exception {
|
||||||
LOG.info("getPersonChanges");
|
LOG.info("getPersonChanges");
|
||||||
String startDate = "";
|
String startDate = "";
|
||||||
@@ -662,4 +667,120 @@ public class TheMovieDbApiTest {
|
|||||||
List<KeywordMovie> result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page);
|
List<KeywordMovie> result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page);
|
||||||
assertFalse("No keyword movies found", result.isEmpty());
|
assertFalse("No keyword movies found", result.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getReviews method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetReviews() throws Exception {
|
||||||
|
LOG.info("getReviews");
|
||||||
|
int page = 0;
|
||||||
|
List<Reviews> result = tmdb.getReviews(ID_MOVIE_THE_AVENGERS, LANGUAGE_DEFAULT, page);
|
||||||
|
|
||||||
|
assertFalse("No reviews found", result.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of compareMovies method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Ignore("Not required")
|
||||||
|
public void testCompareMovies_3args() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of compareMovies method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Ignore("Not required")
|
||||||
|
public void testCompareMovies_4args() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getPersonPopular method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Ignore("Not required")
|
||||||
|
public void testGetPersonPopular_0args() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getPersonPopular method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetPersonPopular_int() throws Exception {
|
||||||
|
LOG.info("getPersonPopular");
|
||||||
|
int page = 0;
|
||||||
|
List<Person> result = tmdb.getPersonPopular(page);
|
||||||
|
assertFalse("No popular people", result.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getGenreMovies method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Ignore("Not required")
|
||||||
|
public void testGetGenreMovies_3args() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getGenreMovies method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Ignore("Not required")
|
||||||
|
public void testGetGenreMovies_4args() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getMovieChangesList method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Ignore("Not ready yet")
|
||||||
|
public void testGetMovieChangesList() throws Exception {
|
||||||
|
LOG.info("getMovieChangesList");
|
||||||
|
int page = 0;
|
||||||
|
String startDate = "";
|
||||||
|
String endDate = "";
|
||||||
|
tmdb.getMovieChangesList(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 getPersonChangesList method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Ignore("Not ready yet")
|
||||||
|
public void testGetPersonChangesList() throws Exception {
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetJobs() throws Exception {
|
||||||
|
LOG.info("getJobs");
|
||||||
|
List<JobDepartment> result = tmdb.getJobs();
|
||||||
|
assertFalse("No jobs found", result.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getDiscover method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Ignore("Not required")
|
||||||
|
public void testGetDiscover_14args() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getDiscover method, of class TheMovieDbApi.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetDiscover_Discover() throws Exception {
|
||||||
|
LOG.info("getDiscover");
|
||||||
|
Discover discover = new Discover();
|
||||||
|
discover.year(2013).language(LANGUAGE_ENGLISH);
|
||||||
|
|
||||||
|
List<MovieDb> result = tmdb.getDiscover(discover);
|
||||||
|
assertFalse("No movies discovered", result.isEmpty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user