From 588c61820893b1860a044d09beaea8a9b98884e9 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Tue, 30 Dec 2014 19:51:19 +0000 Subject: [PATCH] Update copyright date --- .../themoviedbapi/model/ArtworkType.java | 33 ++ .../themoviedbapi/model/Discover.java | 279 ++++++++++++ .../themoviedbapi/model/KeywordMovie.java | 148 ++++++ .../omertron/themoviedbapi/model/MovieDb.java | 425 ++++++++++++++++++ .../themoviedbapi/model/MovieDbList.java | 143 ++++++ .../model/MovieDbListStatus.java | 36 ++ .../themoviedbapi/model/MovieList.java | 111 +++++ .../omertron/themoviedbapi/model/Person.java | 296 ++++++++++++ .../themoviedbapi/model/PersonCast.java | 134 ++++++ .../themoviedbapi/model/PersonCredit.java | 246 ++++++++++ .../themoviedbapi/model/PersonCrew.java | 123 +++++ .../themoviedbapi/model/PersonType.java | 33 ++ .../omertron/themoviedbapi/model/Reviews.java | 74 +++ .../model/TmdbConfiguration.java | 183 ++++++++ .../omertron/themoviedbapi/tools/ApiUrl.java | 257 +++++++++++ .../themoviedbapi/tools/WebBrowser.java | 333 ++++++++++++++ .../themoviedbapi/wrapper/WrapperMovie.java | 44 ++ .../wrapper/WrapperMovieCasts.java | 77 ++++ .../wrapper/WrapperMovieChanges.java | 39 ++ .../wrapper/WrapperMovieDbList.java | 39 ++ .../wrapper/WrapperMovieKeywords.java | 44 ++ .../wrapper/WrapperMovieList.java | 44 ++ .../themoviedbapi/wrapper/WrapperPerson.java | 42 ++ .../wrapper/WrapperPersonCredits.java | 77 ++++ .../wrapper/WrapperPersonList.java | 42 ++ 25 files changed, 3302 insertions(+) create mode 100644 src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/Discover.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/MovieDb.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/MovieDbListStatus.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/MovieList.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/Person.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/PersonCast.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/PersonType.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/Reviews.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java create mode 100644 src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java create mode 100644 src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieChanges.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieDbList.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonList.java diff --git a/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java b/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java new file mode 100644 index 000000000..091319f1a --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +/** + * ArtworkType enum List of the artwork types that are available + */ +public enum ArtworkType { + + // Poster artwork + POSTER, + // Fanart/backdrop + BACKDROP, + // Person image + PROFILE +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Discover.java b/src/main/java/com/omertron/themoviedbapi/model/Discover.java new file mode 100644 index 000000000..c1306e578 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/Discover.java @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation;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 . + * + */ +package com.omertron.themoviedbapi.model; + +import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_ADULT; +import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_LANGUAGE; +import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_PAGE; +import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_YEAR; +import java.util.HashMap; +import java.util.Map; +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 final Map params = new HashMap(); + 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 getParams() { + return params; + } + + /** + * Minimum value is 1 if included. + * + * @param page + * @return + */ + public Discover page(int page) { + if (page > 0) { + params.put(PARAM_PAGE, String.valueOf(page)); + } + return this; + } + + /** + * ISO 639-1 code + * + * @param language + * @return + */ + public Discover language(String language) { + if (StringUtils.isNotBlank(language)) { + params.put(PARAM_LANGUAGE, language); + } + return this; + } + + /** + * Available options are
+ * vote_average.desc
+ * vote_average.asc
+ * release_date.desc
+ * release_date.asc
+ * popularity.desc
+ * popularity.asc + * + * @param sortBy + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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 + * @return + */ + 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; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java b/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java new file mode 100644 index 000000000..4dc11e0bd --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author Stuart + */ +public class KeywordMovie extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + + /* + * Properties + */ + @JsonProperty("id") + private String id; + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("original_title") + private String originalTitle; + @JsonProperty("release_date") + private String releaseDate; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("title") + private String title; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private double voteCount; + @JsonProperty("adult") + private boolean adult; + @JsonProperty("popularity") + private float popularity; + @JsonProperty("video") + private boolean video; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getBackdropPath() { + return backdropPath; + } + + public String getId() { + return id; + } + + public String getOriginalTitle() { + return originalTitle; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getPosterPath() { + return posterPath; + } + + public String getTitle() { + return title; + } + + public float getVoteAverage() { + return voteAverage; + } + + public double getVoteCount() { + return voteCount; + } + + public boolean isAdult() { + return adult; + } + + public float getPopularity() { + return popularity; + } + + public boolean isVideo() { + return video; + } + + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(String id) { + this.id = id; + } + + public void setOriginalTitle(String originalTitle) { + this.originalTitle = originalTitle; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(double voteCount) { + this.voteCount = voteCount; + } + + public void setAdult(boolean adult) { + this.adult = adult; + } + + public void setPopularity(float popularity) { + this.popularity = popularity; + } + + public void setVideo(boolean video) { + this.video = video; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java new file mode 100644 index 000000000..f8665225d --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java @@ -0,0 +1,425 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.wrapper.*; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import java.util.List; + +/** + * Movie Bean + * + * @author stuart.boston + */ +public class MovieDb extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("id") + private int id; + @JsonProperty("original_title") + private String originalTitle; + @JsonProperty("popularity") + private float popularity; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("release_date") + private String releaseDate; + @JsonProperty("title") + private String title; + @JsonProperty("adult") + private boolean adult; + @JsonProperty("belongs_to_collection") + private Collection belongsToCollection; + @JsonProperty("budget") + private long budget; + @JsonProperty("genres") + private List genres; + @JsonProperty("homepage") + private String homepage; + @JsonProperty("imdb_id") + private String imdbID; + @JsonProperty("overview") + private String overview; + @JsonProperty("production_companies") + private List productionCompanies; + @JsonProperty("production_countries") + private List productionCountries; + @JsonProperty("revenue") + private long revenue; + @JsonProperty("runtime") + private int runtime; + @JsonProperty("spoken_languages") + private List spokenLanguages; + @JsonProperty("tagline") + private String tagline; + @JsonProperty("rating") + private float userRating; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private int voteCount; + @JsonProperty("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("videos") + private WrapperTrailers trailers; + @JsonProperty("translations") + private WrapperTranslations translations; + @JsonProperty("similar_movies") + private WrapperMovie similarMovies; + @JsonProperty("reviews") + private WrapperReviews reviews; + @JsonProperty("lists") + private WrapperMovieList lists; + @JsonProperty("video") + private Boolean video = null; + + // + public String getBackdropPath() { + return backdropPath; + } + + public int getId() { + return id; + } + + public String getOriginalTitle() { + return originalTitle; + } + + public float getPopularity() { + return popularity; + } + + public String getPosterPath() { + return posterPath; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getTitle() { + return title; + } + + public boolean isAdult() { + return adult; + } + + public Collection getBelongsToCollection() { + return belongsToCollection; + } + + public long getBudget() { + return budget; + } + + public List getGenres() { + return genres; + } + + public String getHomepage() { + return homepage; + } + + public String getImdbID() { + return imdbID; + } + + public String getOverview() { + return overview; + } + + public List getProductionCompanies() { + return productionCompanies; + } + + public List getProductionCountries() { + return productionCountries; + } + + public long getRevenue() { + return revenue; + } + + public int getRuntime() { + return runtime; + } + + public List getSpokenLanguages() { + return spokenLanguages; + } + + public String getTagline() { + return tagline; + } + + public float getVoteAverage() { + return voteAverage; + } + + public int getVoteCount() { + return voteCount; + } + + public String getStatus() { + return status; + } + + public float getUserRating() { + return userRating; + } + + public Boolean getVideo() { + return video; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(int id) { + this.id = id; + } + + public void setOriginalTitle(String originalTitle) { + this.originalTitle = originalTitle; + } + + public void setPopularity(float popularity) { + this.popularity = popularity; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setAdult(boolean adult) { + this.adult = adult; + } + + public void setBelongsToCollection(Collection belongsToCollection) { + this.belongsToCollection = belongsToCollection; + } + + public void setBudget(long budget) { + this.budget = budget; + } + + public void setGenres(List genres) { + this.genres = genres; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public void setImdbID(String imdbID) { + this.imdbID = imdbID; + } + + public void setOverview(String overview) { + this.overview = overview; + } + + public void setProductionCompanies(List productionCompanies) { + this.productionCompanies = productionCompanies; + } + + public void setProductionCountries(List productionCountries) { + this.productionCountries = productionCountries; + } + + public void setRevenue(long revenue) { + this.revenue = revenue; + } + + public void setRuntime(int runtime) { + this.runtime = runtime; + } + + public void setSpokenLanguages(List spokenLanguages) { + this.spokenLanguages = spokenLanguages; + } + + public void setTagline(String tagline) { + this.tagline = tagline; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(int voteCount) { + this.voteCount = voteCount; + } + + public void setStatus(String status) { + this.status = status; + } + + public void setUserRating(float userRating) { + this.userRating = userRating; + } + + public void setVideo(Boolean video) { + this.video = video; + } + // + + // + public List getAlternativeTitles() { + return alternativeTitles.getTitles(); + } + + public List getCast() { + return casts.getCast(); + } + + public List getCrew() { + return casts.getCrew(); + } + + public List getImages() { + return images.getAll(); + } + + public List getKeywords() { + return keywords.getKeywords(); + } + + public List getReleases() { + return releases.getCountries(); + } + + public List getTrailers() { + return trailers.getTrailers(); + } + + public List getTranslations() { + return translations.getTranslations(); + } + + public List getSimilarMovies() { + return similarMovies.getMovies(); + } + + public List getLists() { + return lists.getMovieList(); + } + + public List getReviews() { + return reviews.getReviews(); + } + // + + // + 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; + } + // + + // + @Override + public boolean equals(Object obj) { + if (obj instanceof MovieDb) { + final MovieDb other = (MovieDb) obj; + return new EqualsBuilder() + .append(id, other.id) + .append(imdbID, other.imdbID) + .append(runtime, other.runtime) + .isEquals(); + } else { + return false; + } + } + + @Override + public int hashCode() { + return new HashCodeBuilder() + .append(id) + .append(imdbID) + .append(runtime) + .toHashCode(); + } + // +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java new file mode 100644 index 000000000..7dbc9c700 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Collections; +import java.util.List; + +/** + * Wrapper for the MovieDbList function + * + * @author stuart.boston + */ +public class MovieDbList extends AbstractJsonMapping { + + @JsonProperty("id") + private String id; + @JsonProperty("created_by") + private String createdBy; + @JsonProperty("description") + private String description; + @JsonProperty("favorite_count") + private int favoriteCount; + @JsonProperty("items") + private List items = Collections.emptyList(); + @JsonProperty("item_count") + private int itemCount; + @JsonProperty("iso_639_1") + private String language; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("status_code") + private String statusCode; + @JsonProperty("status_message") + private String statusMessage; + + public String getId() { + return id; + } + + public String getCreatedBy() { + return createdBy; + } + + public String getDescription() { + return description; + } + + public int getFavoriteCount() { + return favoriteCount; + } + + public List getItems() { + return items; + } + + public int getItemCount() { + return itemCount; + } + + public String getLanguage() { + return language; + } + + public String getName() { + return name; + } + + public String getPosterPath() { + return posterPath; + } + + public String getStatusCode() { + return statusCode; + } + + public String getStatusMessage() { + return statusMessage; + } + + public void setId(String id) { + this.id = id; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setFavoriteCount(int favoriteCount) { + this.favoriteCount = favoriteCount; + } + + public void setItems(List items) { + this.items = items; + } + + public void setItemCount(int itemCount) { + this.itemCount = itemCount; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setName(String name) { + this.name = name; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDbListStatus.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDbListStatus.java new file mode 100644 index 000000000..3f63f12dc --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDbListStatus.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation;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 . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class MovieDbListStatus extends StatusCode { + + @JsonProperty("list_id") + private String listId; + + public String getListId() { + return listId; + } + + public void setListId(String listId) { + this.listId = listId; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieList.java b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java new file mode 100644 index 000000000..a910d83b5 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author Stuart + */ +public class MovieList extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + + @JsonProperty("description") + private String description; + @JsonProperty("favorite_count") + private int favoriteCount; + @JsonProperty("id") + private String id; + @JsonProperty("item_count") + private int itemCount; + @JsonProperty("iso_639_1") + private String language; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("list_type") + private String listType; + + public String getDescription() { + return description; + } + + public int getFavoriteCount() { + return favoriteCount; + } + + public String getId() { + return id; + } + + public int getItemCount() { + return itemCount; + } + + public String getLanguage() { + return language; + } + + public String getName() { + return name; + } + + public String getPosterPath() { + return posterPath; + } + + public String getListType() { + return listType; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setFavoriteCount(int favoriteCount) { + this.favoriteCount = favoriteCount; + } + + public void setId(String id) { + this.id = id; + } + + public void setItemCount(int itemCount) { + this.itemCount = itemCount; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setName(String name) { + this.name = name; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setListType(String listType) { + this.listType = listType; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Person.java b/src/main/java/com/omertron/themoviedbapi/model/Person.java new file mode 100644 index 000000000..9bb2da42a --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/Person.java @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +/** + * @author stuart.boston + */ +public class Person extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + + /* + * Static fields for default cast information + */ + private static final String CAST_DEPARTMENT = "acting"; + private static final String CAST_JOB = "actor"; + private static final String DEFAULT_STRING = ""; + /* + * Properties + */ + @JsonProperty("id") + private int id = -1; + @JsonProperty("name") + private String name = ""; + @JsonProperty("profile_path") + private String profilePath = DEFAULT_STRING; + private PersonType personType = PersonType.PERSON; + // Crew + private String department = DEFAULT_STRING; + // Crew + private String job = DEFAULT_STRING; + // Cast + private String character = DEFAULT_STRING; + // Cast + private int order = -1; + @JsonProperty("adult") + // Person info + private boolean adult = false; + @JsonProperty("also_known_as") + private List aka = new ArrayList(); + @JsonProperty("biography") + private String biography = DEFAULT_STRING; + @JsonProperty("birthday") + private String birthday = DEFAULT_STRING; + @JsonProperty("deathday") + private String deathday = DEFAULT_STRING; + @JsonProperty("homepage") + private String homepage = DEFAULT_STRING; + @JsonProperty("place_of_birth") + private String birthplace = DEFAULT_STRING; + @JsonProperty("imdb_id") + private String imdbId = DEFAULT_STRING; + @JsonProperty("popularity") + private float popularity = 0.0f; + @JsonProperty("known_for") + private List knownFor; + + /** + * Add a crew member + * + * @param id + * @param name + * @param profilePath + * @param department + * @param job + */ + public void addCrew(int id, String name, String profilePath, String department, String job) { + setPersonType(PersonType.CREW); + setId(id); + setName(name); + setProfilePath(profilePath); + setDepartment(department); + setJob(job); + setCharacter(""); + setOrder(-1); + } + + /** + * Add a cast member + * + * @param id + * @param name + * @param profilePath + * @param character + * @param order + */ + public void addCast(int id, String name, String profilePath, String character, int order) { + setPersonType(PersonType.CAST); + setId(id); + setName(name); + setProfilePath(profilePath); + setCharacter(character); + setOrder(order); + setDepartment(CAST_DEPARTMENT); + setJob(CAST_JOB); + } + + public String getCharacter() { + return character; + } + + public String getDepartment() { + return department; + } + + public int getId() { + return id; + } + + public String getJob() { + return job; + } + + public String getName() { + return name; + } + + public int getOrder() { + return order; + } + + public PersonType getPersonType() { + return personType; + } + + public String getProfilePath() { + return profilePath; + } + + public boolean isAdult() { + return adult; + } + + public List getAka() { + return aka; + } + + public String getBiography() { + return biography; + } + + public String getBirthday() { + return birthday; + } + + public String getBirthplace() { + return birthplace; + } + + public String getDeathday() { + return deathday; + } + + public String getHomepage() { + return homepage; + } + + public String getImdbId() { + return imdbId; + } + + public float getPopularity() { + return popularity; + } + + public void setCharacter(String character) { + this.character = character; + } + + public void setDepartment(String department) { + this.department = department; + } + + public void setId(int id) { + this.id = id; + } + + public void setJob(String job) { + this.job = StringUtils.trimToEmpty(job); + } + + public void setName(String name) { + this.name = StringUtils.trimToEmpty(name); + } + + public void setOrder(int order) { + this.order = order; + } + + public void setPersonType(PersonType personType) { + this.personType = personType; + } + + public void setProfilePath(String profilePath) { + this.profilePath = StringUtils.trimToEmpty(profilePath); + } + + public void setAdult(boolean adult) { + this.adult = adult; + } + + public void setAka(List aka) { + this.aka = aka; + } + + public void setBiography(String biography) { + this.biography = StringUtils.trimToEmpty(biography); + } + + public void setBirthday(String birthday) { + this.birthday = StringUtils.trimToEmpty(birthday); + } + + public void setBirthplace(String birthplace) { + this.birthplace = StringUtils.trimToEmpty(birthplace); + } + + public void setDeathday(String deathday) { + this.deathday = StringUtils.trimToEmpty(deathday); + } + + public void setHomepage(String homepage) { + this.homepage = StringUtils.trimToEmpty(homepage); + } + + public void setImdbId(String imdbId) { + this.imdbId = StringUtils.trimToEmpty(imdbId); + } + + public void setPopularity(float popularity) { + this.popularity = popularity; + } + + public List getKnownFor() { + return knownFor; + } + + public void setKnownFor(List knownFor) { + this.knownFor = knownFor; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Person) { + final Person other = (Person) obj; + return new EqualsBuilder() + .append(id, other.id) + .append(name, other.name) + .append(profilePath, other.profilePath) + .append(personType, other.personType) + .append(department, other.department) + .append(job, other.job) + .append(character, other.character) + .isEquals(); + } else { + return false; + } + } + + @Override + public int hashCode() { + return new HashCodeBuilder() + .append(id) + .append(name) + .append(profilePath) + .append(personType) + .append(department) + .append(job) + .append(character) + .toHashCode(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java new file mode 100644 index 000000000..724761e07 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +/** + * @author Stuart + */ +public class PersonCast extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("character") + private String character; + @JsonProperty("name") + private String name; + @JsonProperty("order") + private int order; + @JsonProperty("profile_path") + private String profilePath; + @JsonProperty("cast_id") + private int castId; + @JsonProperty("credit_id") + private String creditId; + + public String getCharacter() { + return character; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public int getOrder() { + return order; + } + + public String getProfilePath() { + return profilePath; + } + + public int getCastId() { + return castId; + } + + public void setCharacter(String character) { + this.character = StringUtils.trimToEmpty(character); + } + + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = StringUtils.trimToEmpty(name); + } + + public void setOrder(int order) { + this.order = order; + } + + public void setProfilePath(String profilePath) { + this.profilePath = StringUtils.trimToEmpty(profilePath); + } + + public void setCastId(int castId) { + this.castId = castId; + } + + public String getCreditId() { + return creditId; + } + + public void setCreditId(String creditId) { + this.creditId = creditId; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof PersonCast) { + final PersonCast other = (PersonCast) obj; + return new EqualsBuilder() + .append(id, other.id) + .append(name, other.name) + .append(character, other.character) + .append(order, other.order) + .append(profilePath, other.profilePath) + .isEquals(); + } else { + return false; + } + } + + @Override + public int hashCode() { + return new HashCodeBuilder() + .append(id) + .append(character) + .append(name) + .append(order) + .append(profilePath) + .toHashCode(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java new file mode 100644 index 000000000..7636e0f3b --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Collections; +import java.util.List; +import org.apache.commons.lang3.StringUtils; + +/** + * @author stuart.boston + */ +public class PersonCredit extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + private static final String DEFAULT_STRING = ""; + /* + * Properties + */ + @JsonProperty("id") + private int movieId = 0; + @JsonProperty("character") + private String character = DEFAULT_STRING; + @JsonProperty("original_title") + private String movieOriginalTitle = DEFAULT_STRING; + @JsonProperty("poster_path") + private String posterPath = DEFAULT_STRING; + @JsonProperty("backdrop_path") + private String backdropPath = DEFAULT_STRING; + @JsonProperty("release_date") + private String releaseDate = DEFAULT_STRING; + @JsonProperty("title") + private String movieTitle = DEFAULT_STRING; + @JsonProperty("department") + private String department = DEFAULT_STRING; + @JsonProperty("job") + private String job = DEFAULT_STRING; + @JsonProperty("adult") + private String adult = DEFAULT_STRING; + @JsonProperty("credit_id") + private String creditId = DEFAULT_STRING; + private PersonType personType = PersonType.PERSON; + @JsonProperty("popularity") + private float popularity; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private int voteCount; + @JsonProperty("media_type") + private String mediaType; + @JsonProperty("video") + private boolean video; + @JsonProperty("original_name") + private String tvOriginalName = DEFAULT_STRING; + @JsonProperty("name") + private String tvName = DEFAULT_STRING; + @JsonProperty("first_air_date") + private String firstAirDate = DEFAULT_STRING; + @JsonProperty("origin_country") + private List originCountry = Collections.emptyList(); + + public String getCharacter() { + return character; + } + + public String getDepartment() { + return department; + } + + public String getJob() { + return job; + } + + public int getMovieId() { + return movieId; + } + + public String getMovieOriginalTitle() { + return movieOriginalTitle; + } + + public String getMovieTitle() { + return movieTitle; + } + + public PersonType getPersonType() { + return personType; + } + + public String getPosterPath() { + return posterPath; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getAdult() { + return adult; + } + + public String getCreditId() { + return creditId; + } + + public boolean getVideo() { + return video; + } + + public String getTvOriginalName() { + return tvOriginalName; + } + + public String getTvName() { + return tvName; + } + + public String getFirstAirDate() { + return firstAirDate; + } + + public List getOriginCountry() { + return originCountry; + } + + public void setCharacter(String character) { + this.character = StringUtils.trimToEmpty(character); + } + + public void setDepartment(String department) { + this.department = StringUtils.trimToEmpty(department); + } + + public void setJob(String job) { + this.job = StringUtils.trimToEmpty(job); + } + + public void setMovieId(int movieId) { + this.movieId = movieId; + } + + public void setMovieOriginalTitle(String movieOriginalTitle) { + this.movieOriginalTitle = StringUtils.trimToEmpty(movieOriginalTitle); + } + + public void setMovieTitle(String movieTitle) { + this.movieTitle = StringUtils.trimToEmpty(movieTitle); + } + + public void setPersonType(PersonType personType) { + this.personType = personType; + } + + public void setPosterPath(String posterPath) { + this.posterPath = StringUtils.trimToEmpty(posterPath); + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = StringUtils.trimToEmpty(releaseDate); + } + + public void setAdult(String adult) { + this.adult = StringUtils.trimToEmpty(adult); + } + + public void setCreditId(String creditId) { + this.creditId = creditId; + } + + public String getBackdropPath() { + return backdropPath; + } + + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public float getPopularity() { + return popularity; + } + + public void setPopularity(float popularity) { + this.popularity = popularity; + } + + public float getVoteAverage() { + return voteAverage; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public int getVoteCount() { + return voteCount; + } + + public void setVoteCount(int voteCount) { + this.voteCount = voteCount; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public void setVideo(boolean video) { + this.video = video; + } + + public void setTvOriginalName(String tvOriginalName) { + this.tvOriginalName = tvOriginalName; + } + + public void setTvName(String tvName) { + this.tvName = tvName; + } + + public void setFirstAirDate(String firstAirDate) { + this.firstAirDate = firstAirDate; + } + + public void setOriginCountry(List originCountry) { + this.originCountry = originCountry; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java new file mode 100644 index 000000000..192f7e437 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +/** + * @author Stuart + */ +public class PersonCrew extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("department") + private String department; + @JsonProperty("job") + private String job; + @JsonProperty("name") + private String name; + @JsonProperty("profile_path") + private String profilePath; + @JsonProperty("credit_id") + private String creditId; + + public String getDepartment() { + return department; + } + + public int getId() { + return id; + } + + public String getJob() { + return job; + } + + public String getName() { + return name; + } + + public String getProfilePath() { + return profilePath; + } + + public String getCreditId() { + return creditId; + } + + public void setCreditId(String creditId) { + this.creditId = creditId; + } + + public void setDepartment(String department) { + this.department = StringUtils.trimToEmpty(department); + } + + public void setId(int id) { + this.id = id; + } + + public void setJob(String job) { + this.job = StringUtils.trimToEmpty(job); + } + + public void setName(String name) { + this.name = StringUtils.trimToEmpty(name); + } + + public void setProfilePath(String profilePath) { + this.profilePath = StringUtils.trimToEmpty(profilePath); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof PersonCrew) { + final PersonCrew other = (PersonCrew) obj; + return new EqualsBuilder() + .append(id, other.id) + .append(name, other.name) + .append(department, other.department) + .append(job, other.job) + .isEquals(); + } else { + return false; + } + } + + @Override + public int hashCode() { + return new HashCodeBuilder() + .append(id) + .append(department) + .append(job) + .append(name) + .append(profilePath) + .toHashCode(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonType.java b/src/main/java/com/omertron/themoviedbapi/model/PersonType.java new file mode 100644 index 000000000..daf8816ee --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonType.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +/** + * @author stuart.boston + */ +public enum PersonType { + + // A member of the cast + CAST, + // A member of the crew + CREW, + // No specific type + PERSON +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Reviews.java b/src/main/java/com/omertron/themoviedbapi/model/Reviews.java new file mode 100644 index 000000000..13d78541d --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/Reviews.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * @author Stuart + */ +public class Reviews extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + + /* + * Properties + */ + @JsonProperty("id") + private String id; + @JsonProperty("author") + private String author; + @JsonProperty("content") + private String content; + @JsonProperty("url") + private String url; + + public String getId() { + return id; + } + + public String getAuthor() { + return author; + } + + public String getContent() { + return content; + } + + public String getUrl() { + return url; + } + + 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; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java new file mode 100644 index 000000000..1bf4d7119 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import org.apache.commons.lang3.StringUtils; + +/** + * @author stuart.boston + */ +public class TmdbConfiguration extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + /* + * Properties + */ + @JsonProperty("base_url") + private String baseUrl; + @JsonProperty("secure_base_url") + private String secureBaseUrl; + @JsonProperty("poster_sizes") + private List posterSizes; + @JsonProperty("backdrop_sizes") + private List backdropSizes; + @JsonProperty("profile_sizes") + private List profileSizes; + @JsonProperty("logo_sizes") + private List logoSizes; + @JsonProperty("still_sizes") + private List stillSizes; + + public List getBackdropSizes() { + return backdropSizes; + } + + public String getBaseUrl() { + return baseUrl; + } + + public List getPosterSizes() { + return posterSizes; + } + + public List getProfileSizes() { + return profileSizes; + } + + public List getLogoSizes() { + return logoSizes; + } + + public String getSecureBaseUrl() { + return secureBaseUrl; + } + + public List getStillSizes() { + return stillSizes; + } + + public void setBackdropSizes(List backdropSizes) { + this.backdropSizes = backdropSizes; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + public void setPosterSizes(List posterSizes) { + this.posterSizes = posterSizes; + } + + public void setProfileSizes(List profileSizes) { + this.profileSizes = profileSizes; + } + + public void setLogoSizes(List logoSizes) { + this.logoSizes = logoSizes; + } + + public void setSecureBaseUrl(String secureBaseUrl) { + this.secureBaseUrl = secureBaseUrl; + } + + public void setStillSizes(List stillSizes) { + this.stillSizes = stillSizes; + } + + /** + * Copy the data from the passed object to this one + * + * @param config + */ + public void clone(TmdbConfiguration config) { + backdropSizes = config.getBackdropSizes(); + baseUrl = config.getBaseUrl(); + posterSizes = config.getPosterSizes(); + profileSizes = config.getProfileSizes(); + logoSizes = config.getLogoSizes(); + } + + /** + * Check that the poster size is valid + * + * @param posterSize + * @return + */ + public boolean isValidPosterSize(String posterSize) { + if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { + return false; + } + return posterSizes.contains(posterSize); + } + + /** + * Check that the backdrop size is valid + * + * @param backdropSize + * @return + */ + public boolean isValidBackdropSize(String backdropSize) { + if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { + return false; + } + return backdropSizes.contains(backdropSize); + } + + /** + * Check that the profile size is valid + * + * @param profileSize + * @return + */ + public boolean isValidProfileSize(String profileSize) { + if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { + return false; + } + return profileSizes.contains(profileSize); + } + + /** + * Check that the logo size is valid + * + * @param logoSize + * @return + */ + public boolean isValidLogoSize(String logoSize) { + if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { + return false; + } + return logoSizes.contains(logoSize); + } + + /** + * Check to see if the size is valid for any of the images types + * + * @param sizeToCheck + * @return + */ + public boolean isValidSize(String sizeToCheck) { + return isValidPosterSize(sizeToCheck) + || isValidBackdropSize(sizeToCheck) + || isValidProfileSize(sizeToCheck) + || isValidLogoSize(sizeToCheck); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java new file mode 100644 index 000000000..200f996b2 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.tools; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Map; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The API URL that is used to construct the API call + * + * @author Stuart + */ +public class ApiUrl { + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class); + /* + * TheMovieDbApi API Base URL + */ + private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; + /* + * Parameter configuration + */ + private static final String DELIMITER_FIRST = "?"; + private static final String DELIMITER_SUBSEQUENT = "&"; + private static final String DEFAULT_STRING = ""; + /* + * Properties + */ + private final String apiKey; + private final String method; + private final String submethod; + private final Map arguments = new HashMap(); + /* + * API Parameters + */ + public static final String PARAM_ADULT = "include_adult="; + public static final String PARAM_API_KEY = "api_key="; + public static final String PARAM_COUNTRY = "country="; + public static final String PARAM_FAVORITE = "favorite="; + public static final String PARAM_ID = "id="; + public static final String PARAM_LANGUAGE = "language="; + public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies="; + public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist="; + public static final String PARAM_PAGE = "page="; + public static final String PARAM_QUERY = "query="; + public static final String PARAM_SESSION = "session_id="; + public static final String PARAM_TOKEN = "request_token="; + public static final String PARAM_VALUE = "value="; + public static final String PARAM_YEAR = "year="; + public static final String PARAM_START_DATE = "start_date="; + public static final String PARAM_END_DATE = "end_date="; + private static final String APPEND_TO_RESPONSE = "append_to_response="; + + // + /** + * Constructor for the simple API URL method without a sub-method + * + * @param apiKey + * @param method + */ + public ApiUrl(String apiKey, String method) { + this.apiKey = apiKey; + this.method = method; + this.submethod = DEFAULT_STRING; + } + + /** + * Constructor for the API URL with a sub-method + * + * @param apiKey + * @param method + * @param submethod + */ + public ApiUrl(String apiKey, String method, String submethod) { + this.apiKey = apiKey; + this.method = method; + this.submethod = submethod; + } + // + + /** + * Build the URL from the pre-created arguments. + * + * @return + */ + public URL buildUrl() { + StringBuilder urlString = new StringBuilder(TMDB_API_BASE); + + // Get the start of the URL + urlString.append(method); + + // We have either a queury, or a direct request + if (arguments.containsKey(PARAM_QUERY)) { + // Append the suffix of the API URL + if (StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) { + urlString.deleteCharAt(urlString.length() - 1); + } + urlString.append(submethod); + + // Append the key information + urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); + urlString.append(apiKey); + + // Append the search term + urlString.append(DELIMITER_SUBSEQUENT); + urlString.append(PARAM_QUERY); + + String query = arguments.get(PARAM_QUERY); + + try { + urlString.append(URLEncoder.encode(query, "UTF-8")); + } catch (UnsupportedEncodingException ex) { + LOG.trace("Unable to encode query: '{}' trying raw.", query, ex); + // If we can't encode it, try it raw + urlString.append(query); + } + + // Remove the query from the arguments so it is not added later + arguments.remove(PARAM_QUERY); + } else { + // Append the ID if provided + if (arguments.containsKey(PARAM_ID)) { + urlString.append(arguments.get(PARAM_ID)); + arguments.remove(PARAM_ID); + } + + // Append the suffix of the API URL + if (StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) { + urlString.deleteCharAt(urlString.length() - 1); + } + urlString.append(submethod); + + // Append the key information + urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); + urlString.append(apiKey); + } + + for (Map.Entry argEntry : arguments.entrySet()) { + urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey()); + urlString.append(argEntry.getValue()); + } + + try { + LOG.trace("URL: {}", urlString.toString()); + return new URL(urlString.toString()); + } catch (MalformedURLException ex) { + LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString()); + return null; + } finally { + arguments.clear(); + } + } + + /** + * Add arguments individually + * + * @param key + * @param value + */ + public void addArgument(String key, String value) { + arguments.put(key, value); + } + + /** + * Add arguments individually + * + * @param key + * @param value + */ + public void addArgument(String key, int value) { + arguments.put(key, Integer.toString(value)); + } + + /** + * Add arguments individually + * + * @param key + * @param value + */ + public void addArgument(String key, boolean 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 + */ + public void clearArguments() { + arguments.clear(); + } + + /** + * Set the arguments directly + * + * @param args + */ + public void setArguments(Map 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()); + } + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java new file mode 100644 index 000000000..c8020554a --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java @@ -0,0 +1,333 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.tools; + +import com.omertron.themoviedbapi.MovieDbException; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Web browser with simple cookies support + */ +public final class WebBrowser { + + private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class); + private static final Map BROWSER_PROPERTIES = new HashMap(); + private static final Map> COOKIES = new HashMap>(); + private static String proxyHost = null; + private static int proxyPort = 0; + private static String proxyUsername = null; + private static String proxyPassword = null; + private static String proxyEncodedPassword = null; + // 25 second timeout + private static int webTimeoutConnect = 25000; + // 90 second timeout + private static int webTimeoutRead = 90000; + + // Hide the constructor + protected WebBrowser() { + // prevents calls from subclass + throw new UnsupportedOperationException(); + } + + /** + * Populate the browser properties + */ + private static void populateBrowserProperties() { + if (BROWSER_PROPERTIES.isEmpty()) { + BROWSER_PROPERTIES.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); + BROWSER_PROPERTIES.put("Accept", "application/json"); + BROWSER_PROPERTIES.put("Content-type", "application/json"); + } + } + + public static String request(String url) throws MovieDbException { + try { + return request(new URL(url)); + } catch (MalformedURLException ex) { + throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, url, ex); + } + } + + public static URLConnection openProxiedConnection(URL url) throws MovieDbException { + try { + if (proxyHost != null) { + System.getProperties().put("proxySet", "true"); + System.getProperties().put("proxyHost", proxyHost); + System.getProperties().put("proxyPort", proxyPort); + } + + URLConnection cnx = url.openConnection(); + + if (proxyUsername != null) { + cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); + } + + return cnx; + } catch (IOException ex) { + throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, url, ex); + } + } + + public static String request(URL url) throws MovieDbException { + return request(url, null, Boolean.FALSE); + } + + public static String request(URL url, String jsonBody) throws MovieDbException { + return request(url, jsonBody, Boolean.FALSE); + } + + public static String request(URL url, String jsonBody, boolean isDeleteRequest) throws MovieDbException { + + StringWriter content = null; + + try { + content = new StringWriter(); + + BufferedReader in = null; + HttpURLConnection cnx = null; + OutputStreamWriter wr = null; + try { + cnx = (HttpURLConnection) openProxiedConnection(url); + + // If we get a null connection, then throw an exception + if (cnx == null) { + throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, "No HTTP connection could be made.", url); + } + + if (isDeleteRequest) { + cnx.setDoOutput(true); + cnx.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + cnx.setRequestMethod("DELETE"); + } + + sendHeader(cnx); + + if (StringUtils.isNotBlank(jsonBody)) { + cnx.setDoOutput(true); + wr = new OutputStreamWriter(cnx.getOutputStream()); + wr.write(jsonBody); + } + + readHeader(cnx); + + // http://stackoverflow.com/questions/4633048/httpurlconnection-reading-response-content-on-403-error + if (cnx.getResponseCode() >= 400) { + in = new BufferedReader(new InputStreamReader(cnx.getErrorStream(), getCharset(cnx))); + } else { + in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); + } + + String line; + while ((line = in.readLine()) != null) { + content.write(line); + } + } finally { + if (wr != null) { + wr.flush(); + wr.close(); + } + + if (in != null) { + in.close(); + } + + if (cnx instanceof HttpURLConnection) { + ((HttpURLConnection) cnx).disconnect(); + } + } + return content.toString(); + } catch (IOException ex) { + throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, url, ex); + } finally { + if (content != null) { + try { + content.close(); + } catch (IOException ex) { + LOG.debug("Failed to close connection: " + ex.getMessage()); + } + } + } + } + + private static void sendHeader(URLConnection cnx) { + populateBrowserProperties(); + + // send browser properties + for (Map.Entry browserProperty : BROWSER_PROPERTIES.entrySet()) { + cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue()); + } + // send cookies + String cookieHeader = createCookieHeader(cnx); + if (!cookieHeader.isEmpty()) { + cnx.setRequestProperty("Cookie", cookieHeader); + } + } + + private static String createCookieHeader(URLConnection cnx) { + String host = cnx.getURL().getHost(); + StringBuilder cookiesHeader = new StringBuilder(); + for (Map.Entry> domainCookies : COOKIES.entrySet()) { + if (host.endsWith(domainCookies.getKey())) { + for (Map.Entry cookie : domainCookies.getValue().entrySet()) { + cookiesHeader.append(cookie.getKey()); + cookiesHeader.append("="); + cookiesHeader.append(cookie.getValue()); + cookiesHeader.append(";"); + } + } + } + if (cookiesHeader.length() > 0) { + // remove last ; char + cookiesHeader.deleteCharAt(cookiesHeader.length() - 1); + } + return cookiesHeader.toString(); + } + + private static void readHeader(URLConnection cnx) { + // read new cookies and update our cookies + for (Map.Entry> header : cnx.getHeaderFields().entrySet()) { + if ("Set-Cookie".equals(header.getKey())) { + for (String cookieHeader : header.getValue()) { + String[] cookieElements = cookieHeader.split(" *; *"); + if (cookieElements.length >= 1) { + String[] firstElem = cookieElements[0].split(" *= *"); + String cookieName = firstElem[0]; + String cookieValue = firstElem.length > 1 ? firstElem[1] : null; + String cookieDomain = null; + // find cookie domain + for (int i = 1; i < cookieElements.length; i++) { + String[] cookieElement = cookieElements[i].split(" *= *"); + if ("domain".equals(cookieElement[0])) { + cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null; + break; + } + } + if (cookieDomain == null) { + // if domain isn't set take current host + cookieDomain = cnx.getURL().getHost(); + } + Map domainCookies = COOKIES.get(cookieDomain); + if (domainCookies == null) { + domainCookies = new HashMap(); + COOKIES.put(cookieDomain, domainCookies); + } + // add or replace cookie + domainCookies.put(cookieName, cookieValue); + } + } + } + } + } + + private static Charset getCharset(URLConnection cnx) { + Charset charset = null; + // content type will be string like "text/html; charset=UTF-8" or "text/html" + String contentType = cnx.getContentType(); + if (contentType != null) { + // changed 'charset' to 'harset' in regexp because some sites send 'Charset' + Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType); + if (m.find()) { + String encoding = m.group(1); + try { + charset = Charset.forName(encoding); + } catch (UnsupportedCharsetException e) { + // there will be used default charset + } + } + } + if (charset == null) { + charset = Charset.defaultCharset(); + } + + return charset; + } + + public static String getProxyHost() { + return proxyHost; + } + + public static void setProxyHost(String myProxyHost) { + WebBrowser.proxyHost = myProxyHost; + } + + public static int getProxyPort() { + return proxyPort; + } + + public static void setProxyPort(int myProxyPort) { + WebBrowser.proxyPort = myProxyPort; + } + + public static String getProxyUsername() { + return proxyUsername; + } + + public static void setProxyUsername(String myProxyUsername) { + WebBrowser.proxyUsername = myProxyUsername; + } + + public static String getProxyPassword() { + return proxyPassword; + } + + public static void setProxyPassword(String myProxyPassword) { + WebBrowser.proxyPassword = myProxyPassword; + + if (proxyUsername != null) { + proxyEncodedPassword = proxyUsername + ":" + proxyPassword; + proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes())); + } + } + + public static int getWebTimeoutConnect() { + return webTimeoutConnect; + } + + public static int getWebTimeoutRead() { + return webTimeoutRead; + } + + public static void setWebTimeoutConnect(int webTimeoutConnect) { + WebBrowser.webTimeoutConnect = webTimeoutConnect; + } + + public static void setWebTimeoutRead(int webTimeoutRead) { + WebBrowser.webTimeoutRead = webTimeoutRead; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java new file mode 100644 index 000000000..996c14636 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.MovieDb; +import java.io.Serializable; +import java.util.List; + +/** + * + * @author stuart.boston + */ +public class WrapperMovie extends AbstractWrapperAll implements Serializable { + + private static final long serialVersionUID = 1L; + @JsonProperty("results") + private List movies; + + public List getMovies() { + return movies; + } + + public void setMovies(List movies) { + this.movies = movies; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java new file mode 100644 index 000000000..b2f822a9c --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Person; +import com.omertron.themoviedbapi.model.PersonCast; +import com.omertron.themoviedbapi.model.PersonCrew; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author Stuart + */ +public class WrapperMovieCasts extends AbstractWrapperId implements Serializable { + + private static final long serialVersionUID = 1L; + @JsonProperty("cast") + private List cast; + @JsonProperty("crew") + private List crew; + + public List getCast() { + return cast; + } + + public List getCrew() { + return crew; + } + + public void setCast(List cast) { + this.cast = cast; + } + + public void setCrew(List crew) { + this.crew = crew; + } + + public List getAll() { + List people = new ArrayList(); + + // Add a cast member + for (PersonCast member : cast) { + Person person = new Person(); + person.addCast(member.getId(), member.getName(), member.getProfilePath(), member.getCharacter(), member.getOrder()); + people.add(person); + } + + // Add a crew member + for (PersonCrew member : crew) { + Person person = new Person(); + person.addCrew(member.getId(), member.getName(), member.getProfilePath(), member.getDepartment(), member.getJob()); + people.add(person); + } + + return people; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieChanges.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieChanges.java new file mode 100644 index 000000000..08980b1e4 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieChanges.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.ChangedMovie; + +public class WrapperMovieChanges extends AbstractWrapperAll { + + @JsonProperty("results") + private List results; + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieDbList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieDbList.java new file mode 100644 index 000000000..37cdf8945 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieDbList.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.MovieDbList; +import java.util.List; + +public class WrapperMovieDbList extends AbstractWrapperAll { + + + @JsonProperty("results") + private List lists; + + public List getLists() { + return lists; + } + + public void setLists(List lists) { + this.lists = lists; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java new file mode 100644 index 000000000..2937b26d8 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Keyword; +import java.io.Serializable; +import java.util.List; + +/** + * + * @author Stuart + */ +public class WrapperMovieKeywords extends AbstractWrapperId implements Serializable { + + private static final long serialVersionUID = 1L; + @JsonProperty("keywords") + private List keywords; + + public List getKeywords() { + return keywords; + } + + public void setKeywords(List keywords) { + this.keywords = keywords; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java new file mode 100644 index 000000000..6e9607e24 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.MovieList; +import java.io.Serializable; +import java.util.List; + +/** + * + * @author Stuart + */ +public class WrapperMovieList extends AbstractWrapperAll implements Serializable { + + private static final long serialVersionUID = 1L; + @JsonProperty("results") + private List movieList; + + public List getMovieList() { + return movieList; + } + + public void setMovieList(List movieList) { + this.movieList = movieList; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java new file mode 100644 index 000000000..90fa0902d --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Person; +import java.util.List; + +/** + * + * @author stuart.boston + */ +public class WrapperPerson extends AbstractWrapperAll { + + @JsonProperty("results") + private List results; + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java new file mode 100644 index 000000000..d4aafdbbe --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.PersonCredit; +import com.omertron.themoviedbapi.model.PersonType; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author stuart.boston + */ +public class WrapperPersonCredits extends AbstractWrapperAll { + + @JsonProperty("cast") + private List cast; + @JsonProperty("crew") + private List crew; + + public List getCast() { + return cast; + } + + public void setCast(List cast) { + this.cast = cast; + } + + public List getCrew() { + return crew; + } + + public void setCrew(List crew) { + this.crew = crew; + } + + public List getAll(PersonType... typeList) { + List personCredits = new ArrayList(); + List types = getTypeList(PersonType.class, typeList); + + // Add a cast member + if (types.contains(PersonType.CAST)) { + for (PersonCredit member : cast) { + member.setPersonType(PersonType.CAST); + personCredits.add(member); + } + } + + // Add a crew member + if (types.contains(PersonType.CREW)) { + for (PersonCredit member : crew) { + member.setPersonType(PersonType.CREW); + personCredits.add(member); + } + } + + return personCredits; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonList.java new file mode 100644 index 000000000..6bbe82279 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonList.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Person; +import java.util.List; + +/** + * + * @author Stuart + */ +public class WrapperPersonList extends AbstractWrapperAll { + + @JsonProperty("results") + private List personList; + + public List getPersonList() { + return personList; + } + + public void setPersonList(List personList) { + this.personList = personList; + } +}