From bb1d95e9e1b31f92e00ae9d14c43a4ebdac06032 Mon Sep 17 00:00:00 2001 From: Caleb Goh <46834785+heze8@users.noreply.github.com> Date: Wed, 6 Nov 2019 05:17:07 +0800 Subject: [PATCH] Added recommended movies method in tmdbMovies (#111) * Added reccomended movies method in tmdbMovies * Changed the MovieDb class to reflect the new Json data --- .../info/movito/themoviedbapi/TmdbMovies.java | 23 ++++++++++++++++++- .../movito/themoviedbapi/model/MovieDb.java | 17 +++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/info/movito/themoviedbapi/TmdbMovies.java b/src/main/java/info/movito/themoviedbapi/TmdbMovies.java index fb2362d9..f73b914a 100644 --- a/src/main/java/info/movito/themoviedbapi/TmdbMovies.java +++ b/src/main/java/info/movito/themoviedbapi/TmdbMovies.java @@ -34,7 +34,7 @@ public static enum MovieMethod { alternative_titles, credits, images, keywords, releases, release_dates, @Deprecated trailers, videos, // replacement for trailers - translations, similar, + translations, similar, recommendations, reviews, lists, changes, latest, upcoming, now_playing, popular, top_rated, } @@ -203,6 +203,27 @@ public MovieResultsPage getSimilarMovies(int movieId, String language, Integer p return mapJsonResult(apiUrl, MovieResultsPage.class); } + /** + * The recomendations movies method will let you retrieve the reccomended movies for a particular movie. + *
+ * This data is created dynamically but with the help of TMDb internal algorithm. + * + * The data is much better with movies that are more popular + * + * @param movieId + * @param language + * @param page + */ + public MovieResultsPage getRecommendedMovies(int movieId, String language, Integer page) { + ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, MovieMethod.recommendations); + + apiUrl.addLanguage(language); + + apiUrl.addPage(page); + + return mapJsonResult(apiUrl, MovieResultsPage.class); + } + /** * Get the lists that the movie belongs to diff --git a/src/main/java/info/movito/themoviedbapi/model/MovieDb.java b/src/main/java/info/movito/themoviedbapi/model/MovieDb.java index b886bc41..d8bcbe49 100644 --- a/src/main/java/info/movito/themoviedbapi/model/MovieDb.java +++ b/src/main/java/info/movito/themoviedbapi/model/MovieDb.java @@ -17,6 +17,7 @@ public class MovieDb extends IdElement implements Multi { @JsonProperty("title") private String title; + @JsonProperty("original_title") private String originalTitle; @@ -25,19 +26,25 @@ public class MovieDb extends IdElement implements Multi { @JsonProperty("backdrop_path") private String backdropPath; + @JsonProperty("poster_path") private String posterPath; @JsonProperty("release_date") private String releaseDate; + @JsonProperty("adult") private boolean adult; + @JsonProperty("belongs_to_collection") private Collection belongsToCollection; + @JsonProperty("budget") private long budget; + @JsonProperty("genres") private List