Skip to content

Commit

Permalink
Added recommended movies method in tmdbMovies (#111)
Browse files Browse the repository at this point in the history
* Added reccomended movies method in tmdbMovies

* Changed the MovieDb class to reflect the new Json data
  • Loading branch information
heze8 authored and holgerbrandl committed Nov 5, 2019
1 parent efed5d2 commit bb1d95e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/main/java/info/movito/themoviedbapi/TmdbMovies.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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.
* <p/>
* This data is created dynamically but with the help of TMDb internal algorithm.
* <p/>
* 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
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/info/movito/themoviedbapi/model/MovieDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class MovieDb extends IdElement implements Multi {

@JsonProperty("title")
private String title;

@JsonProperty("original_title")
private String originalTitle;

Expand All @@ -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<Genre> genres;

@JsonProperty("homepage")
private String homepage;

Expand All @@ -53,11 +60,13 @@ public class MovieDb extends IdElement implements Multi {

@JsonProperty("production_companies")
private List<ProductionCompany> productionCompanies;

@JsonProperty("production_countries")
private List<ProductionCountry> productionCountries;

@JsonProperty("revenue")
private long revenue;

@JsonProperty("runtime")
private int runtime;

Expand All @@ -72,14 +81,14 @@ public class MovieDb extends IdElement implements Multi {

@JsonProperty("vote_average")
private float voteAverage;

@JsonProperty("vote_count")
private int voteCount;

@JsonProperty("status")
private String status;

// Appendable responses

@JsonProperty("alternative_titles")
private MoviesAlternativeTitles alternativeTitles;

Expand All @@ -105,6 +114,9 @@ public class MovieDb extends IdElement implements Multi {
@JsonProperty("similar")
private ResultsPage<MovieDb> similarMovies;

@JsonProperty("recommendations")
private ResultsPage<MovieDb> recommendedMovies;

@JsonProperty("reviews")
private ResultsPage<Reviews> reviews;

Expand Down Expand Up @@ -270,6 +282,9 @@ public List<MovieDb> getSimilarMovies() {
return similarMovies != null ? similarMovies.getResults() : null;
}

public List<MovieDb> getRecommendations() {
return recommendedMovies != null ? recommendedMovies.getResults() : null;
}

public List<MovieList> getLists() {
return lists != null ? lists.getResults() : null;
Expand Down

0 comments on commit bb1d95e

Please sign in to comment.