diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml
index 2064402e1..12bb18451 100644
--- a/themoviedbapi/pom.xml
+++ b/themoviedbapi/pom.xml
@@ -6,7 +6,7 @@
oss-parent
7
-
+
3.0.3
@@ -33,7 +33,7 @@
- true
+ false
UTF-8
UTF-8
zip
@@ -47,17 +47,17 @@
log4j
log4j
- 1.2.16
+ 1.2.17
org.codehaus.jackson
jackson-core-lgpl
- 1.9.6
+ 1.9.7
org.codehaus.jackson
jackson-mapper-lgpl
- 1.9.6
+ 1.9.7
commons-codec
@@ -116,12 +116,12 @@
org.apache.maven.plugins
maven-clean-plugin
- 2.4.1
+ 2.5
org.apache.maven.plugins
maven-compiler-plugin
- 2.3.2
+ 2.5.1
org.apache.maven.plugins
@@ -141,7 +141,7 @@
org.codehaus.mojo
buildnumber-maven-plugin
- 1.0
+ 1.1
org.codehaus.mojo
diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java
index 65c143ae6..bfaa5f21e 100644
--- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java
+++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java
@@ -28,8 +28,9 @@ import org.apache.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
/**
- * The MovieDb API. This is for version 3 of the API as specified here:
- * http://help.themoviedb.org/kb/api/about-3
+ * The MovieDb API
+ *
+ * This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3
*
* @author stuart.boston
*/
@@ -45,12 +46,14 @@ public class TheMovieDb {
private static final String BASE_MOVIE = "movie/";
private static final String BASE_PERSON = "person/";
private static final String BASE_COMPANY = "company/";
+ private static final String BASE_GENRE = "genre/";
// Configuration URL
private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration");
// Search URLS
private final ApiUrl tmdbSearchMovie = new ApiUrl(this, "search/movie");
private final ApiUrl tmdbSearchPeople = new ApiUrl(this, "search/person");
- // Collections
+ private final ApiUrl tmdbSearchCompanies = new ApiUrl(this, "search/company");
+ // Collections
private final ApiUrl tmdbCollectionInfo = new ApiUrl(this, "collection/");
// Movie Info
private final ApiUrl tmdbMovieInfo = new ApiUrl(this, BASE_MOVIE);
@@ -61,12 +64,13 @@ public class TheMovieDb {
private final ApiUrl tmdbMovieReleaseInfo = new ApiUrl(this, BASE_MOVIE, "/releases");
private final ApiUrl tmdbMovieTrailers = new ApiUrl(this, BASE_MOVIE, "/trailers");
private final ApiUrl tmdbMovieTranslations = new ApiUrl(this, BASE_MOVIE, "/translations");
+ private final ApiUrl tmdbMovieSimilarMovies = new ApiUrl(this, BASE_MOVIE, "/similar_movies");
// Person Info
private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON);
private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits");
private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images");
// Misc Movie
- // Movie Add Rating - See issue 9
+ // Movie Add Rating - See issue 9 http://code.google.com/p/themoviedbapi/issues/detail?id=9
private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie");
private final ApiUrl tmdbNowPlaying = new ApiUrl(this, "movie/now-playing");
private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, "movie/popular");
@@ -74,6 +78,10 @@ public class TheMovieDb {
// Company Info
private final ApiUrl tmdbCompanyInfo = new ApiUrl(this, BASE_COMPANY);
private final ApiUrl tmdbCompanyMovies = new ApiUrl(this, BASE_COMPANY, "/movies");
+ // Genre Info
+ private final ApiUrl tmdbGenreList = new ApiUrl(this, "genre/list");
+ private final ApiUrl tmdbGenreMovies = new ApiUrl(this, BASE_GENRE, "/movies");
+
/*
* Jackson JSON configuration
*/
@@ -193,9 +201,11 @@ public class TheMovieDb {
}
/**
- * Search Movies This is a good starting point to start finding movies on
- * TMDb. The idea is to be a quick and light method so you can iterate
- * through movies quickly. http://help.themoviedb.org/kb/api/search-movies
+ * Search Movies This is a good starting point to start finding movies on TMDb.
+ *
+ * The idea is to be a quick and light method so you can iterate through movies quickly.
+ *
+ * http://help.themoviedb.org/kb/api/search-movies
*
* TODO: Make the allResults work
*
@@ -210,8 +220,8 @@ public class TheMovieDb {
URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1);
String webPage = WebBrowser.request(url);
try {
- WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class);
- return resultList.getResults();
+ WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class);
+ return wrapper.getResults();
} catch (IOException ex) {
LOGGER.warn("Failed to find movie: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -219,8 +229,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the basic movie information. It
- * will return the single highest rated poster and backdrop.
+ * This method is used to retrieve all of the basic movie information.
+ *
+ * It will return the single highest rated poster and backdrop.
*
* @param movieId
* @param language
@@ -240,8 +251,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the basic movie information. It
- * will return the single highest rated poster and backdrop.
+ * This method is used to retrieve all of the basic movie information.
+ *
+ * It will return the single highest rated poster and backdrop.
*
* @param imdbId
* @param language
@@ -261,8 +273,7 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the alternative titles we have for
- * a particular movie.
+ * This method is used to retrieve all of the alternative titles we have for a particular movie.
*
* @param movieId
* @param country
@@ -274,8 +285,8 @@ public class TheMovieDb {
URL url = tmdbMovieAltTitles.getIdUrl(movieId, ApiUrl.DEFAULT_STRING, country);
String webPage = WebBrowser.request(url);
try {
- WrapperAlternativeTitles at = mapper.readValue(webPage, WrapperAlternativeTitles.class);
- return at.getTitles();
+ WrapperAlternativeTitles wrapper = mapper.readValue(webPage, WrapperAlternativeTitles.class);
+ return wrapper.getTitles();
} catch (IOException ex) {
LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -283,8 +294,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the movie cast information. TODO:
- * Add a function to enrich the data with the people methods
+ * This method is used to retrieve all of the movie cast information.
+ *
+ * TODO: Add a function to enrich the data with the people methods
*
* @param movieId
* @return
@@ -297,17 +309,17 @@ public class TheMovieDb {
URL url = tmdbMovieCasts.getIdUrl(movieId);
String webPage = WebBrowser.request(url);
try {
- WrapperMovieCasts mc = mapper.readValue(webPage, WrapperMovieCasts.class);
+ WrapperMovieCasts wrapper = mapper.readValue(webPage, WrapperMovieCasts.class);
// Add a cast member
- for (PersonCast cast : mc.getCast()) {
+ for (PersonCast cast : wrapper.getCast()) {
Person person = new Person();
person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder());
people.add(person);
}
// Add a crew member
- for (PersonCrew crew : mc.getCrew()) {
+ for (PersonCrew crew : wrapper.getCrew()) {
Person person = new Person();
person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob());
people.add(person);
@@ -321,8 +333,7 @@ public class TheMovieDb {
}
/**
- * This method should be used when you’re wanting to retrieve all of the
- * images for a particular movie.
+ * This method should be used when you’re wanting to retrieve all of the images for a particular movie.
*
* @param movieId
* @param language
@@ -335,16 +346,16 @@ public class TheMovieDb {
URL url = tmdbMovieImages.getIdUrl(movieId, language);
String webPage = WebBrowser.request(url);
try {
- WrapperImages mi = mapper.readValue(webPage, WrapperImages.class);
+ WrapperImages wrapper = mapper.readValue(webPage, WrapperImages.class);
// Add all the posters to the list
- for (Artwork poster : mi.getPosters()) {
+ for (Artwork poster : wrapper.getPosters()) {
poster.setArtworkType(ArtworkType.POSTER);
artwork.add(poster);
}
// Add all the backdrops to the list
- for (Artwork backdrop : mi.getBackdrops()) {
+ for (Artwork backdrop : wrapper.getBackdrops()) {
backdrop.setArtworkType(ArtworkType.BACKDROP);
artwork.add(backdrop);
}
@@ -357,8 +368,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the keywords that have been added
- * to a particular movie. Currently, only English keywords exist.
+ * This method is used to retrieve all of the keywords that have been added to a particular movie.
+ *
+ * Currently, only English keywords exist.
*
* @param movieId
* @return
@@ -370,8 +382,8 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperMovieKeywords mk = mapper.readValue(webPage, WrapperMovieKeywords.class);
- return mk.getKeywords();
+ WrapperMovieKeywords wrapper = mapper.readValue(webPage, WrapperMovieKeywords.class);
+ return wrapper.getKeywords();
} catch (IOException ex) {
LOGGER.warn("Failed to get movie keywords: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -379,8 +391,7 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the release and certification data
- * we have for a specific movie.
+ * This method is used to retrieve all of the release and certification data we have for a specific movie.
*
* @param movieId
* @param language
@@ -393,8 +404,8 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperReleaseInfo ri = mapper.readValue(webPage, WrapperReleaseInfo.class);
- return ri.getCountries();
+ WrapperReleaseInfo wrapper = mapper.readValue(webPage, WrapperReleaseInfo.class);
+ return wrapper.getCountries();
} catch (IOException ex) {
LOGGER.warn("Failed to get movie release information: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -402,8 +413,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the trailers for a particular
- * movie. Supported sites are YouTube and QuickTime.
+ * This method is used to retrieve all of the trailers for a particular movie.
+ *
+ * Supported sites are YouTube and QuickTime.
*
* @param movieId
* @param language
@@ -417,15 +429,15 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperTrailers wt = mapper.readValue(webPage, WrapperTrailers.class);
+ WrapperTrailers wrapper = mapper.readValue(webPage, WrapperTrailers.class);
// Add the trailer to the return list along with it's source
- for (Trailer trailer : wt.getQuicktime()) {
+ 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 : wt.getYoutube()) {
+ for (Trailer trailer : wrapper.getYoutube()) {
trailer.setWebsite(Trailer.WEBSITE_YOUTUBE);
trailers.add(trailer);
}
@@ -437,8 +449,7 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve a list of the available translations for
- * a specific movie.
+ * This method is used to retrieve a list of the available translations for a specific movie.
*
* @param movieId
* @return
@@ -450,8 +461,8 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperTranslations wt = mapper.readValue(webPage, WrapperTranslations.class);
- return wt.getTranslations();
+ WrapperTranslations wrapper = mapper.readValue(webPage, WrapperTranslations.class);
+ return wrapper.getTranslations();
} catch (IOException ex) {
LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -459,9 +470,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the basic information about a
- * movie collection. You can get the ID needed for this method by making a
- * getMovieInfo request for the belongs_to_collection.
+ * This method is used to retrieve all of the basic information about a movie collection.
+ *
+ * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection.
*
* @param movieId
* @param language
@@ -515,9 +526,9 @@ public class TheMovieDb {
}
/**
- * This is a good starting point to start finding people on TMDb. The idea
- * is to be a quick and light method so you can iterate through people
- * quickly.
+ * This is a good starting point to start finding people on TMDb.
+ *
+ * The idea is to be a quick and light method so you can iterate through people quickly.
*
* TODO: Fix allResults
*
@@ -532,8 +543,8 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperPerson resultList = mapper.readValue(webPage, WrapperPerson.class);
- return resultList.getResults();
+ WrapperPerson wrapper = mapper.readValue(webPage, WrapperPerson.class);
+ return wrapper.getResults();
} catch (IOException ex) {
LOGGER.warn("Failed to find person: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -541,8 +552,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the basic person information. It
- * will return the single highest rated profile image.
+ * This method is used to retrieve all of the basic person information.
+ *
+ * It will return the single highest rated profile image.
*
* @param personId
* @return
@@ -562,9 +574,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve all of the cast & crew information for
- * the person. It will return the single highest rated poster for each movie
- * record.
+ * This method is used to retrieve all of the cast & crew information for the person.
+ *
+ * It will return the single highest rated poster for each movie record.
*
* @param personId
* @return
@@ -578,15 +590,15 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperPersonCredits pc = mapper.readValue(webPage, WrapperPersonCredits.class);
+ WrapperPersonCredits wrapper = mapper.readValue(webPage, WrapperPersonCredits.class);
// Add a cast member
- for (PersonCredit cast : pc.getCast()) {
+ for (PersonCredit cast : wrapper.getCast()) {
cast.setPersonType(PersonType.CAST);
personCredits.add(cast);
}
// Add a crew member
- for (PersonCredit crew : pc.getCrew()) {
+ for (PersonCredit crew : wrapper.getCrew()) {
crew.setPersonType(PersonType.CREW);
personCredits.add(crew);
}
@@ -612,10 +624,10 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperImages images = mapper.readValue(webPage, WrapperImages.class);
+ WrapperImages wrapper = mapper.readValue(webPage, WrapperImages.class);
// Update the image type
- for (Artwork artwork : images.getProfiles()) {
+ for (Artwork artwork : wrapper.getProfiles()) {
artwork.setArtworkType(ArtworkType.PROFILE);
personImages.add(artwork);
}
@@ -645,9 +657,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve the movies currently in theatres. This is
- * a curated list that will normally contain 100 movies. The default
- * response will return 20 movies.
+ * This method is used to retrieve the movies currently in theatres.
+ *
+ * This is a curated list that will normally contain 100 movies. The default response will return 20 movies.
*
* TODO: Implement more than 20 movies
*
@@ -661,8 +673,8 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class);
- return resultList.getResults();
+ WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class);
+ return wrapper.getResults();
} catch (IOException ex) {
LOGGER.warn("Failed to get now playing movies: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -670,8 +682,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve the daily movie popularity list. This
- * list is updated daily. The default response will return 20 movies.
+ * This method is used to retrieve the daily movie popularity list.
+ *
+ * This list is updated daily. The default response will return 20 movies.
*
* TODO: Implement more than 20 movies
*
@@ -685,8 +698,8 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class);
- return resultList.getResults();
+ WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class);
+ return wrapper.getResults();
} catch (IOException ex) {
LOGGER.warn("Failed to get popular movie list: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -694,8 +707,9 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve the top rated movies that have over 10
- * votes on TMDb. The default response will return 20 movies.
+ * This method is used to retrieve the top rated movies that have over 10 votes on TMDb.
+ *
+ * The default response will return 20 movies.
*
* TODO: Implement more than 20 movies
*
@@ -709,8 +723,8 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class);
- return resultList.getResults();
+ WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class);
+ return wrapper.getResults();
} catch (IOException ex) {
LOGGER.warn("Failed to get top rated movies: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
@@ -718,8 +732,7 @@ public class TheMovieDb {
}
/**
- * This method is used to retrieve the basic information about a production
- * company on TMDb.
+ * This method is used to retrieve the basic information about a production company on TMDb.
*
* @param companyId
* @return
@@ -739,8 +752,9 @@ public class TheMovieDb {
/**
* This method is used to retrieve the movies associated with a company.
- * These movies are returned in order of most recently released to oldest.
- * The default response will return 20 movies per page.
+ *
+ * These movies are returned in order of most recently released to oldest. The default response will return 20
+ * movies per page.
*
* TODO: Implement more than 20 movies
*
@@ -755,11 +769,113 @@ public class TheMovieDb {
String webPage = WebBrowser.request(url);
try {
- WrapperCompanyMovies resultList = mapper.readValue(webPage, WrapperCompanyMovies.class);
- return resultList.getResults();
+ WrapperCompanyMovies wrapper = mapper.readValue(webPage, WrapperCompanyMovies.class);
+ return wrapper.getResults();
} catch (IOException ex) {
LOGGER.warn("Failed to get company movies: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
}
}
+
+ /**
+ * Search Companies.
+ *
+ * You can use this method to search for production companies that are part of TMDb. The company IDs will map to
+ * those returned on movie calls.
+ *
+ * http://help.themoviedb.org/kb/api/search-companies
+ *
+ * TODO: Make the allResults work
+ *
+ * @param companyName
+ * @param language
+ * @param allResults
+ * @return
+ * @throws MovieDbException
+ */
+ public List searchCompanies(String companyName, String language, boolean allResults) throws MovieDbException {
+
+ URL url = tmdbSearchCompanies.getQueryUrl(companyName, language, 1);
+ String webPage = WebBrowser.request(url);
+ try {
+ WrapperCompany wrapper = mapper.readValue(webPage, WrapperCompany.class);
+ return wrapper.getResults();
+ } catch (IOException ex) {
+ LOGGER.warn("Failed to find company: " + ex.getMessage());
+ throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
+ }
+ }
+
+ /**
+ * The similar movies method will let you retrieve the similar movies for a particular movie.
+ *
+ * This data is created dynamically but with the help of users votes on TMDb.
+ *
+ * The data is much better with movies that have more keywords
+ *
+ * @param movieId
+ * @param language
+ * @param allResults
+ * @return
+ * @throws MovieDbException
+ */
+ public List getSimilarMovies(int movieId, String language, boolean allResults) throws MovieDbException {
+
+ URL url = tmdbMovieSimilarMovies.getIdUrl(movieId, language);
+ String webPage = WebBrowser.request(url);
+
+ try {
+ WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class);
+ return wrapper.getResults();
+ } catch (IOException ex) {
+ LOGGER.warn("Failed to get similar movies: " + ex.getMessage());
+ throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
+ }
+ }
+
+ /**
+ * You can use this method to retrieve the list of genres used on TMDb.
+ *
+ * These IDs will correspond to those found in movie calls.
+ *
+ * @param language
+ * @return
+ */
+ public List getGenreList(String language) throws MovieDbException {
+ URL url = tmdbGenreList.getQueryUrl("", language);
+ String webPage = WebBrowser.request(url);
+
+ try {
+ WrapperGenres wrapper = mapper.readValue(webPage, WrapperGenres.class);
+ return wrapper.getGenres();
+ } catch (IOException ex) {
+ LOGGER.warn("Failed to get genre list: " + ex.getMessage());
+ throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
+ }
+ }
+
+ /**
+ * Get a list of movies per genre.
+ *
+ * It is important to understand that only movies with more than 10 votes get listed.
+ *
+ * This prevents movies from 1 10/10 rating from being listed first and for the first 5 pages.
+ *
+ * @param genreId
+ * @param language
+ * @param allResults
+ * @return
+ */
+ public List getGenreMovies(int genreId, String language, boolean allResults) throws MovieDbException {
+ URL url = tmdbGenreMovies.getIdUrl(genreId, language);
+ String webPage = WebBrowser.request(url);
+
+ try {
+ WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class);
+ return wrapper.getResults();
+ } catch (IOException ex) {
+ LOGGER.warn("Failed to get genre movie list: " + ex.getMessage());
+ throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex);
+ }
+ }
}
diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java
index b9cf34965..fe4281d29 100644
--- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java
+++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java
@@ -17,53 +17,56 @@ import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonProperty;
/**
+ * Company information
*
* @author Stuart
*/
public class Company {
// Logger
+
private static final Logger LOGGER = Logger.getLogger(Company.class);
+ private static final String DEFAULT_STRING = "";
// Properties
@JsonProperty("id")
- private int companyId;
+ private int companyId = 0;
@JsonProperty("name")
- private String name;
+ private String name = DEFAULT_STRING;
@JsonProperty("description")
- private String description;
+ private String description = DEFAULT_STRING;
@JsonProperty("headquarters")
- private String headquarters;
+ private String headquarters = DEFAULT_STRING;
@JsonProperty("homepage")
- private String homepage;
+ private String homepage = DEFAULT_STRING;
@JsonProperty("logo_path")
- private String logoPath;
+ private String logoPath = DEFAULT_STRING;
@JsonProperty("parent_company")
- private String parentCompany;
+ private String parentCompany = DEFAULT_STRING;
//
public int getCompanyId() {
return companyId;
}
-
+
public String getDescription() {
return description;
}
-
+
public String getHeadquarters() {
return headquarters;
}
-
+
public String getHomepage() {
return homepage;
}
-
+
public String getLogoPath() {
return logoPath;
}
-
+
public String getName() {
return name;
}
-
+
public String getParentCompany() {
return parentCompany;
}
@@ -73,32 +76,32 @@ public class Company {
public void setCompanyId(int companyId) {
this.companyId = companyId;
}
-
+
public void setDescription(String description) {
this.description = description;
}
-
+
public void setHeadquarters(String headquarters) {
this.headquarters = headquarters;
}
-
+
public void setHomepage(String homepage) {
this.homepage = homepage;
}
-
+
public void setLogoPath(String logoPath) {
this.logoPath = logoPath;
}
-
+
public void setName(String name) {
this.name = name;
}
-
+
public void setParentCompany(String parentCompany) {
this.parentCompany = parentCompany;
}
//
-
+
/**
* Handle unknown properties and print a message
*
@@ -112,4 +115,9 @@ public class Company {
sb.append("' value: '").append(value).append("'");
LOGGER.warn(sb.toString());
}
+
+ @Override
+ public String toString() {
+ return "Company{" + "companyId=" + companyId + ", name=" + name + ", description=" + description + ", headquarters=" + headquarters + ", homepage=" + homepage + ", logoPath=" + logoPath + ", parentCompany=" + parentCompany + '}';
+ }
}
diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java
index c0454277e..199656f25 100644
--- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java
+++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java
@@ -98,7 +98,7 @@ public class Genre {
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Genre=");
- sb.append("id=").append(id);
+ sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java
new file mode 100644
index 000000000..5b14bd678
--- /dev/null
+++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2004-2012 YAMJ Members
+ * http://code.google.com/p/moviejukebox/people/list
+ *
+ * Web: http://code.google.com/p/moviejukebox/
+ *
+ * This software is licensed under a Creative Commons License
+ * See this page: http://code.google.com/p/moviejukebox/wiki/License
+ *
+ * For any reuse or distribution, you must make clear to others the
+ * license terms of this work.
+ */
+package com.moviejukebox.themoviedb.wrapper;
+
+import com.moviejukebox.themoviedb.model.Company;
+import java.util.List;
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.annotate.JsonAnySetter;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ *
+ * @author stuart.boston
+ */
+public class WrapperCompany {
+ /*
+ * Logger
+ */
+
+ private static final Logger LOGGER = Logger.getLogger(WrapperCompany.class);
+ /*
+ * Properties
+ */
+ @JsonProperty("page")
+ private int page;
+ @JsonProperty("results")
+ private List results;
+ @JsonProperty("total_pages")
+ private int totalPages;
+ @JsonProperty("total_results")
+ private int totalResults;
+
+ //
+ public int getPage() {
+ return page;
+ }
+
+ public List getResults() {
+ return results;
+ }
+
+ public int getTotalPages() {
+ return totalPages;
+ }
+
+ public int getTotalResults() {
+ return totalResults;
+ }
+ //
+
+ //
+ public void setPage(int page) {
+ this.page = page;
+ }
+
+ public void setResults(List results) {
+ this.results = results;
+ }
+
+ public void setTotalPages(int totalPages) {
+ this.totalPages = totalPages;
+ }
+
+ public void setTotalResults(int totalResults) {
+ this.totalResults = totalResults;
+ }
+ //
+
+ /**
+ * 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("'");
+ LOGGER.warn(sb.toString());
+ }
+}
diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java
new file mode 100644
index 000000000..e6dff9b87
--- /dev/null
+++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2004-2012 YAMJ Members
+ * http://code.google.com/p/moviejukebox/people/list
+ *
+ * Web: http://code.google.com/p/moviejukebox/
+ *
+ * This software is licensed under a Creative Commons License
+ * See this page: http://code.google.com/p/moviejukebox/wiki/License
+ *
+ * For any reuse or distribution, you must make clear to others the
+ * license terms of this work.
+ */
+package com.moviejukebox.themoviedb.wrapper;
+
+import com.moviejukebox.themoviedb.model.Genre;
+import java.util.List;
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.annotate.JsonAnySetter;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Wrapper class for the Genres searches
+ *
+ * @author Stuart
+ */
+public class WrapperGenres {
+ /*
+ * Logger
+ */
+
+ private static final Logger LOGGER = Logger.getLogger(WrapperGenres.class);
+ /*
+ * Properties
+ */
+ @JsonProperty("genres")
+ private List genres;
+
+ public List getGenres() {
+ return genres;
+ }
+
+ public void setGenres(List genres) {
+ this.genres = genres;
+ }
+
+ /**
+ * 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("'");
+ LOGGER.warn(sb.toString());
+ }
+}
diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java
index 2badd7726..e44c987f3 100644
--- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java
+++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java
@@ -39,6 +39,8 @@ public class WrapperResultList {
private int totalPages;
@JsonProperty("total_results")
private int totalResults;
+ @JsonProperty("id")
+ private int id;
//
public int getPage() {
@@ -56,6 +58,10 @@ public class WrapperResultList {
public int getTotalResults() {
return totalResults;
}
+
+ public int getId() {
+ return id;
+ }
//
//
@@ -74,10 +80,15 @@ public class WrapperResultList {
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
+
+ public void setId(int id) {
+ this.id = id;
+ }
//
/**
* Handle unknown properties and print a message
+ *
* @param key
* @param value
*/
@@ -96,6 +107,7 @@ public class WrapperResultList {
sb.append("],[pageResults=").append(results.size());
sb.append("],[totalPages=").append(totalPages);
sb.append("],[totalResults=").append(totalResults);
+ sb.append("],[id=").append(id);
sb.append("]]");
return sb.toString();
}
diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java
index 79e479611..9df436f85 100644
--- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java
+++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java
@@ -17,8 +17,8 @@ import java.io.IOException;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
-import static org.junit.Assert.*;
import org.junit.*;
+import static org.junit.Assert.*;
/**
* Test cases for TheMovieDb API
@@ -37,6 +37,8 @@ public class TheMovieDbTest {
private static final int ID_MOVIE_STAR_WARS_COLLECTION = 10;
private static final int ID_PERSON_BRUCE_WILLIS = 62;
private static final int ID_COMPANY_LUCASFILM = 1;
+ private static final String COMPANY_NAME = "Marvel Studios";
+ private static final int ID_GENRE_ACTION = 28;
public TheMovieDbTest() throws MovieDbException {
tmdb = new TheMovieDb(API_KEY);
@@ -380,4 +382,51 @@ public class TheMovieDbTest {
List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true);
assertTrue("No company movies found", !results.isEmpty());
}
+
+ /**
+ * Test of showVersion method, of class TheMovieDb.
+ */
+ @Test
+ public void testShowVersion() {
+ // Not required
+ }
+
+ /**
+ * Test of searchCompanies method, of class TheMovieDb.
+ */
+ @Test
+ public void testSearchCompanies() throws Exception {
+ LOGGER.info("searchCompanies");
+ List results = tmdb.searchCompanies(COMPANY_NAME, "", true);
+ assertTrue("No company information found", !results.isEmpty());
+ }
+
+ /**
+ * Test of getSimilarMovies method, of class TheMovieDb.
+ */
+ @Test
+ public void testGetSimilarMovies() throws Exception {
+ LOGGER.info("getSimilarMovies");
+ List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true);
+ assertTrue("No similar movies found", !results.isEmpty());
+ }
+ /**
+ * Test of getGenreList method, of class TheMovieDb.
+ */
+ @Test
+ public void testGetGenreList() throws MovieDbException {
+ LOGGER.info("getGenreList");
+ List results = tmdb.getGenreList("");
+ assertTrue("No genres found", !results.isEmpty());
+ }
+
+ /**
+ * Test of getGenreMovies method, of class TheMovieDb.
+ */
+ @Test
+ public void testGetGenreMovies() throws MovieDbException {
+ LOGGER.info("getGenreMovies");
+ List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", true);
+ assertTrue("No genre movies found", !results.isEmpty());
+ }
}