22 Commits

Author SHA1 Message Date
Omertron 7900b6d25b [maven-release-plugin] prepare release themoviedbapi-3.5 2013-05-15 20:34:15 +02:00
Omertron 4747c42fc6 Updated POM versions 2013-05-15 20:31:44 +02:00
Stuart Boston 1a96343924 Updated Test class 2013-05-15 18:15:12 +01:00
Stuart Boston 76191c13c0 Add overview to CollectionInfo 2013-05-15 18:14:54 +01:00
Stuart Boston ce533c2b41 removed unused log messages in test class 2013-05-15 18:06:54 +01:00
Stuart Boston de623ff0db Add discover method 2013-05-15 16:24:57 +01:00
Stuart Boston 6745f5f3d5 Fix issue with WrapperImages not having initialised collections 2013-05-15 14:16:15 +01:00
Stuart Boston 955ef0369e Add Job List 2013-05-15 14:09:57 +01:00
Stuart Boston 4c682731b6 Add PopularPerson method 2013-05-15 13:46:59 +01:00
Stuart Boston c99f60f636 Un"ignored" the tests 2013-05-15 13:22:06 +01:00
Stuart Boston 265878d016 Added AppendToResponse for MovieDb (MovieInfo methods) 2013-05-15 13:19:02 +01:00
Stuart Boston 9bf7175ee8 Add "getAll" method to Images and Trailers 2013-05-15 13:18:14 +01:00
Stuart Boston 00063cc85d Add reviews 2013-05-15 13:16:44 +01:00
Stuart Boston 2f7468914c Allow AppendToReponse to contain multiple elements 2013-05-15 11:51:20 +01:00
Stuart Boston 4d9d53421f Add placeholder "append_to_response" parameters 2013-05-14 16:20:27 +01:00
Stuart Boston 9f135c3ca7 Removed reliance on MovieDb object from ApiBuilder 2013-05-14 16:01:25 +01:00
Stuart Boston 7d9552a08c Updated bin.xml to add correct README 2013-04-19 10:03:42 +01:00
Stuart Boston 3acf07b36a Non-functional changes to POM and bin.xml 2013-04-19 09:35:09 +01:00
Stuart Boston f501126b76 Reverted build version to 1.6 2013-04-03 15:05:45 +01:00
Stuart Boston 8ab8699dd5 updated version.txt 2013-03-25 22:08:40 +00:00
Stuart Boston 6c4ba2a492 Updated version.txt 2013-03-25 21:49:50 +00:00
Stuart Boston 44df73f2d1 Updated POM versions and build number 2013-03-25 20:57:44 +00:00
15 changed files with 4198 additions and 3093 deletions
+16 -15
View File
@@ -13,7 +13,7 @@
<groupId>com.omertron</groupId> <groupId>com.omertron</groupId>
<artifactId>themoviedbapi</artifactId> <artifactId>themoviedbapi</artifactId>
<version>3.5-SNAPSHOT</version> <version>3.5</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>API-The MovieDB</name> <name>API-The MovieDB</name>
@@ -62,7 +62,7 @@
</issueManagement> </issueManagement>
<ciManagement> <ciManagement>
<system>Hudson CI</system> <system>Jenkins CI</system>
<url>http://jenkins.omertron.com/job/API-TheMovieDb/</url> <url>http://jenkins.omertron.com/job/API-TheMovieDb/</url>
</ciManagement> </ciManagement>
@@ -83,22 +83,22 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
<version>2.1.4</version> <version>2.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>2.1.4</version> <version>2.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.1.4</version> <version>2.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
<version>1.7</version> <version>1.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
@@ -108,18 +108,18 @@
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>1.7.3</version> <version>1.7.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId> <artifactId>slf4j-jdk14</artifactId>
<version>1.7.3</version> <version>1.7.5</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>${project.artifactId}-${project.version}-r${buildNumber}</finalName> <finalName>${project.artifactId}-${project.version}-${buildNumber}</finalName>
<plugins> <plugins>
<plugin> <plugin>
@@ -127,8 +127,9 @@
<artifactId>buildnumber-maven-plugin</artifactId> <artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version> <version>1.2</version>
<configuration> <configuration>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce> <shortRevisionLength>10</shortRevisionLength>
<revisionOnScmFailure>0000</revisionOnScmFailure> <doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat> <timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
</configuration> </configuration>
<executions> <executions>
@@ -190,12 +191,12 @@
<property name="header_line" value="The MovieDb API${line.separator}" /> <property name="header_line" value="The MovieDb API${line.separator}" />
<property name="build_date_line" value="Build Date: ${timestamp}${line.separator}" /> <property name="build_date_line" value="Build Date: ${timestamp}${line.separator}" />
<property name="version_line" value="Version: ${project.version}${line.separator}" /> <property name="version_line" value="Version: ${project.version}${line.separator}" />
<!--<property name="revision_line" value="Revision: r${buildNumber}${line.separator}" />--> <property name="buildnumber_line" value="Git-SHA: ${buildNumber}${line.separator}" />
<echo>Writing version file: ${version_file}</echo> <echo>Writing version file: ${version_file}</echo>
<echo file="${version_file}" append="false">${header_line}</echo> <echo file="${version_file}" append="false">${header_line}</echo>
<echo file="${version_file}" append="true">${build_date_line}</echo> <echo file="${version_file}" append="true">${build_date_line}</echo>
<echo file="${version_file}" append="true">${version_line}</echo> <echo file="${version_file}" append="true">${version_line}</echo>
<!--<echo file="${version_file}" append="true">${revision_line}</echo>--> <echo file="${version_file}" append="true">${buildnumber_line}</echo>
</target> </target>
</configuration> </configuration>
<goals> <goals>
@@ -290,12 +291,12 @@
<extension> <extension>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId> <artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.4</version> <version>1.8.1</version>
</extension> </extension>
<extension> <extension>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId> <artifactId>maven-scm-manager-plexus</artifactId>
<version>1.4</version> <version>1.8.1</version>
</extension> </extension>
<extension> <extension>
<groupId>org.kathrynhuxtable.maven.wagon</groupId> <groupId>org.kathrynhuxtable.maven.wagon</groupId>
File diff suppressed because it is too large Load Diff
@@ -1,124 +1,135 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class CollectionInfo implements Serializable { public class CollectionInfo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/* /*
* Logger * Logger
*/ */
private static final Logger LOG = LoggerFactory.getLogger(CollectionInfo.class); private static final Logger LOG = LoggerFactory.getLogger(CollectionInfo.class);
/* /*
* Properties * Properties
*/ */
@JsonProperty("id") @JsonProperty("id")
private int id; private int id;
@JsonProperty("name") @JsonProperty("name")
private String name; private String name;
@JsonProperty("poster_path") @JsonProperty("overview")
private String posterPath; private String overview;
@JsonProperty("backdrop_path") @JsonProperty("poster_path")
private String backdropPath; private String posterPath;
@JsonProperty("parts") @JsonProperty("backdrop_path")
private List<Collection> parts = new ArrayList<Collection>(); private String backdropPath;
@JsonProperty("parts")
//<editor-fold defaultstate="collapsed" desc="Getter methods"> private List<Collection> parts = new ArrayList<Collection>();
public String getBackdropPath() {
return backdropPath; //<editor-fold defaultstate="collapsed" desc="Getter methods">
} public String getBackdropPath() {
return backdropPath;
public int getId() { }
return id;
} public int getId() {
return id;
public String getName() { }
return name;
} public String getName() {
return name;
public List<Collection> getParts() { }
return parts;
} public String getOverview() {
return overview;
public String getPosterPath() { }
return posterPath;
} public List<Collection> getParts() {
//</editor-fold> return parts;
}
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public String getPosterPath() {
this.backdropPath = backdropPath; return posterPath;
} }
//</editor-fold>
public void setId(int id) {
this.id = id; //<editor-fold defaultstate="collapsed" desc="Setter methods">
} public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath;
public void setName(String name) { }
this.name = name;
} public void setId(int id) {
this.id = id;
public void setParts(List<Collection> parts) { }
this.parts = parts;
} public void setName(String name) {
this.name = name;
public void setPosterPath(String posterPath) { }
this.posterPath = posterPath;
} public void setOverview(String overview) {
//</editor-fold> this.overview = overview;
}
/**
* Handle unknown properties and print a message public void setParts(List<Collection> parts) {
* this.parts = parts;
* @param key }
* @param value
*/ public void setPosterPath(String posterPath) {
@JsonAnySetter this.posterPath = posterPath;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder(); //</editor-fold>
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'"); /**
LOG.trace(sb.toString()); * Handle unknown properties and print a message
} *
* @param key
@Override * @param value
public String toString() { */
StringBuilder sb = new StringBuilder("[CollectionInfo="); @JsonAnySetter
sb.append("[id=").append(id); public void handleUnknown(String key, Object value) {
sb.append("],[name=").append(name); StringBuilder sb = new StringBuilder();
sb.append("],[posterPath=").append(posterPath); sb.append("Unknown property: '").append(key);
sb.append("],[backdropPath=").append(backdropPath); sb.append("' value: '").append(value).append("'");
sb.append("],[# of parts=").append(parts.size()); LOG.trace(sb.toString());
sb.append("]]"); }
return sb.toString();
} @Override
} public String toString() {
StringBuilder sb = new StringBuilder("[CollectionInfo=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("],[overview=").append(overview);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[backdropPath=").append(backdropPath);
sb.append("],[# of parts=").append(parts.size());
sb.append("]]");
return sb.toString();
}
}
@@ -0,0 +1,262 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import java.util.HashMap;
import java.util.Map;
import static com.omertron.themoviedbapi.tools.ApiUrl.*;
import org.apache.commons.lang3.StringUtils;
/**
* Generate a discover object for use in the MovieDbApi
*
* This allows you to just add the search components you are concerned with
*
* @author stuart.boston
*/
public class Discover {
private Map<String, String> params = new HashMap<String, String>();
private static final String PARAM_PRIMARY_RELEASE_YEAR = "primary_release_year=";
private static final String PARAM_VOTE_COUNT_GTE = "vote_count.gte=";
private static final String PARAM_VOTE_AVERAGE_GTE = "vote_average.gte=";
private static final String PARAM_WITH_GENRES = "with_genres=";
private static final String PARAM_RELEASE_DATE_GTE = "release_date.gte=";
private static final String PARAM_RELEASE_DATE_LTE = "release_date.lte=";
private static final String PARAM_CERTIFICATION_COUNTRY = "certification_country=";
private static final String PARAM_CERTIFICATION_LTE = "certification.lte=";
private static final String PARAM_WITH_COMPANIES = "with_companies=";
private static final String PARAM_SORT_BY = "sort_by=";
private static final int YEAR_MIN = 1900;
private static final int YEAR_MAX = 2100;
/**
* Get the parameters
*
* This will be used to construct the URL in the API
*
* @return
*/
public Map<String, String> getParams() {
return params;
}
/**
* Minimum value is 1 if included.
*
* @param page
*/
public Discover page(int page) {
if (page > 0) {
params.put(PARAM_PAGE, String.valueOf(page));
}
return this;
}
/**
* ISO 639-1 code
*
* @param language
*/
public Discover language(String language) {
if (StringUtils.isNotBlank(language)) {
params.put(PARAM_LANGUAGE, language);
}
return this;
}
/**
* Available options are <br>
* vote_average.desc<br>
* vote_average.asc<br>
* release_date.desc<br>
* release_date.asc<br>
* popularity.desc<br>
* popularity.asc
*
* @param sortBy
*/
public Discover sortBy(String sortBy) {
if (StringUtils.isNotBlank(sortBy)) {
params.put(PARAM_SORT_BY, sortBy);
}
return this;
}
/**
* Toggle the inclusion of adult titles
*
* @param includeAdult
*/
public Discover includeAdult(boolean includeAdult) {
params.put(PARAM_ADULT, String.valueOf(includeAdult));
return this;
}
/**
* Filter the results release dates to matches that include this value.
*
* @param year
*/
public Discover year(int year) {
if (checkYear(year)) {
params.put(PARAM_YEAR, String.valueOf(year));
}
return this;
}
/**
* Filter the results so that only the primary release date year has this value
*
* @param primaryReleaseYear
*/
public Discover primaryReleaseYear(int primaryReleaseYear) {
if (checkYear(primaryReleaseYear)) {
params.put(PARAM_PRIMARY_RELEASE_YEAR, String.valueOf(primaryReleaseYear));
}
return this;
}
/**
* Only include movies that are equal to, or have a vote count higher than this value
*
* @param voteCountGte
*/
public Discover voteCountGte(int voteCountGte) {
if (voteCountGte > 0) {
params.put(PARAM_VOTE_COUNT_GTE, String.valueOf(voteCountGte));
}
return this;
}
/**
* Only include movies that are equal to, or have a higher average rating than this value
*
* @param voteAverageGte
*/
public Discover voteAverageGte(float voteAverageGte) {
if (voteAverageGte > 0) {
params.put(PARAM_VOTE_AVERAGE_GTE, String.valueOf(voteAverageGte));
}
return this;
}
/**
* Only include movies with the specified genres.
*
* Expected value is an integer (the id of a genre).
*
* Multiple values can be specified.
*
* Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR'
*
* @param withGenres
*/
public Discover withGenres(String withGenres) {
if (StringUtils.isNotBlank(withGenres)) {
params.put(PARAM_WITH_GENRES, withGenres);
}
return this;
}
/**
* The minimum release to include.
*
* Expected format is YYYY-MM-DD.
*
* @param releaseDateGte
*/
public Discover releaseDateGte(String releaseDateGte) {
if (StringUtils.isNotBlank(releaseDateGte)) {
params.put(PARAM_RELEASE_DATE_GTE, releaseDateGte);
}
return this;
}
/**
* The maximum release to include.
*
* Expected format is YYYY-MM-DD.
*
* @param releaseDateLte
*/
public Discover releaseDateLte(String releaseDateLte) {
if (StringUtils.isNotBlank(releaseDateLte)) {
params.put(PARAM_RELEASE_DATE_LTE, releaseDateLte);
}
return this;
}
/**
* Only include movies with certifications for a specific country.
*
* When this value is specified, 'certificationLte' is required.
*
* A ISO 3166-1 is expected
*
* @param certificationCountry
*/
public Discover certificationCountry(String certificationCountry) {
if (StringUtils.isNotBlank(certificationCountry)) {
params.put(PARAM_CERTIFICATION_COUNTRY, certificationCountry);
}
return this;
}
/**
* Only include movies with this certification and lower.
*
* Expected value is a valid certification for the specified 'certificationCountry'.
*
* @param certificationLte
*/
public Discover certificationLte(String certificationLte) {
if (StringUtils.isNotBlank(certificationLte)) {
params.put(PARAM_CERTIFICATION_LTE, certificationLte);
}
return this;
}
/**
* Filter movies to include a specific company.
*
* Expected value is an integer (the id of a company).
*
* They can be comma separated to indicate an 'AND' query
*
* @param withCompanies
*/
public Discover withCompanies(String withCompanies) {
if (StringUtils.isNotBlank(withCompanies)) {
params.put(PARAM_WITH_COMPANIES, withCompanies);
}
return this;
}
/**
* check the year is between the min and max
*
* @param year
* @return
*/
private boolean checkYear(int year) {
return (year >= YEAR_MIN && year <= YEAR_MAX);
}
}
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JobDepartment {
private static final long serialVersionUID = 1L;
// Logger
private static final Logger LOG = LoggerFactory.getLogger(MovieChanges.class);
// Properties
@JsonProperty("department")
private String department;
@JsonProperty("job_list")
private List<String> jobs;
//<editor-fold defaultstate="collapsed" desc="Getters">
public String getDepartment() {
return department;
}
public List<String> getJobs() {
return jobs;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setters">
public void setDepartment(String department) {
this.department = department;
}
public void setJobs(List<String> jobs) {
this.jobs = jobs;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
}
@@ -1,354 +1,475 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
import java.util.List; import com.omertron.themoviedbapi.wrapper.WrapperImages;
import org.slf4j.Logger; import com.omertron.themoviedbapi.wrapper.WrapperMovie;
import org.slf4j.LoggerFactory; import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts;
import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
/** import com.omertron.themoviedbapi.wrapper.WrapperMovieList;
* Movie Bean import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
* import com.omertron.themoviedbapi.wrapper.WrapperReviews;
* @author stuart.boston import com.omertron.themoviedbapi.wrapper.WrapperTrailers;
*/ import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
public class MovieDb implements Serializable { import java.io.Serializable;
import java.util.List;
private static final long serialVersionUID = 1L; import org.slf4j.Logger;
/* import org.slf4j.LoggerFactory;
* Logger
*/ /**
private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class); * Movie Bean
/* *
* Properties * @author stuart.boston
*/ */
@JsonProperty("backdrop_path") public class MovieDb implements Serializable {
private String backdropPath;
@JsonProperty("id") private static final long serialVersionUID = 1L;
private int id; /*
@JsonProperty("original_title") * Logger
private String originalTitle; */
@JsonProperty("popularity") private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class);
private float popularity; /*
@JsonProperty("poster_path") * Properties
private String posterPath; */
@JsonProperty("release_date") @JsonProperty("backdrop_path")
private String releaseDate; private String backdropPath;
@JsonProperty("title") @JsonProperty("id")
private String title; private int id;
@JsonProperty("adult") @JsonProperty("original_title")
private boolean adult; private String originalTitle;
@JsonProperty("belongs_to_collection") @JsonProperty("popularity")
private Collection belongsToCollection; private float popularity;
@JsonProperty("budget") @JsonProperty("poster_path")
private long budget; private String posterPath;
@JsonProperty("genres") @JsonProperty("release_date")
private List<Genre> genres; private String releaseDate;
@JsonProperty("homepage") @JsonProperty("title")
private String homepage; private String title;
@JsonProperty("imdb_id") @JsonProperty("adult")
private String imdbID; private boolean adult;
@JsonProperty("overview") @JsonProperty("belongs_to_collection")
private String overview; private Collection belongsToCollection;
@JsonProperty("production_companies") @JsonProperty("budget")
private List<ProductionCompany> productionCompanies; private long budget;
@JsonProperty("production_countries") @JsonProperty("genres")
private List<ProductionCountry> productionCountries; private List<Genre> genres;
@JsonProperty("revenue") @JsonProperty("homepage")
private long revenue; private String homepage;
@JsonProperty("runtime") @JsonProperty("imdb_id")
private int runtime; private String imdbID;
@JsonProperty("spoken_languages") @JsonProperty("overview")
private List<Language> spokenLanguages; private String overview;
@JsonProperty("tagline") @JsonProperty("production_companies")
private String tagline; private List<ProductionCompany> productionCompanies;
@JsonProperty("vote_average") @JsonProperty("production_countries")
private float voteAverage; private List<ProductionCountry> productionCountries;
@JsonProperty("vote_count") @JsonProperty("revenue")
private int voteCount; private long revenue;
@JsonProperty("status") @JsonProperty("runtime")
private String status; private int runtime;
@JsonProperty("spoken_languages")
// <editor-fold defaultstate="collapsed" desc="Getter methods"> private List<Language> spokenLanguages;
public String getBackdropPath() { @JsonProperty("tagline")
return backdropPath; private String tagline;
} @JsonProperty("vote_average")
private float voteAverage;
public int getId() { @JsonProperty("vote_count")
return id; private int voteCount;
} @JsonProperty("status")
private String status;
public String getOriginalTitle() { // AppendToResponse Properties
return originalTitle; @JsonProperty("alternative_titles")
} private WrapperAlternativeTitles alternativeTitles;
@JsonProperty("casts")
public float getPopularity() { private WrapperMovieCasts casts;
return popularity; @JsonProperty("images")
} private WrapperImages images;
@JsonProperty("keywords")
public String getPosterPath() { private WrapperMovieKeywords keywords;
return posterPath; @JsonProperty("releases")
} private WrapperReleaseInfo releases;
@JsonProperty("trailers")
public String getReleaseDate() { private WrapperTrailers trailers;
return releaseDate; @JsonProperty("translations")
} private WrapperTranslations translations;
@JsonProperty("similar_movies")
public String getTitle() { private WrapperMovie similarMovies;
return title; @JsonProperty("reviews")
} private WrapperReviews reviews;
@JsonProperty("lists")
public boolean isAdult() { private WrapperMovieList lists;
return adult;
} // <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() {
public Collection getBelongsToCollection() { return backdropPath;
return belongsToCollection; }
}
public int getId() {
public long getBudget() { return id;
return budget; }
}
public String getOriginalTitle() {
public List<Genre> getGenres() { return originalTitle;
return genres; }
}
public float getPopularity() {
public String getHomepage() { return popularity;
return homepage; }
}
public String getPosterPath() {
public String getImdbID() { return posterPath;
return imdbID; }
}
public String getReleaseDate() {
public String getOverview() { return releaseDate;
return overview; }
}
public String getTitle() {
public List<ProductionCompany> getProductionCompanies() { return title;
return productionCompanies; }
}
public boolean isAdult() {
public List<ProductionCountry> getProductionCountries() { return adult;
return productionCountries; }
}
public Collection getBelongsToCollection() {
public long getRevenue() { return belongsToCollection;
return revenue; }
}
public long getBudget() {
public int getRuntime() { return budget;
return runtime; }
}
public List<Genre> getGenres() {
public List<Language> getSpokenLanguages() { return genres;
return spokenLanguages; }
}
public String getHomepage() {
public String getTagline() { return homepage;
return tagline; }
}
public String getImdbID() {
public float getVoteAverage() { return imdbID;
return voteAverage; }
}
public String getOverview() {
public int getVoteCount() { return overview;
return voteCount; }
}
public List<ProductionCompany> getProductionCompanies() {
public String getStatus() { return productionCompanies;
return status; }
}
// </editor-fold> public List<ProductionCountry> getProductionCountries() {
return productionCountries;
// <editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; public long getRevenue() {
} return revenue;
}
public void setId(int id) {
this.id = id; public int getRuntime() {
} return runtime;
}
public void setOriginalTitle(String originalTitle) {
this.originalTitle = originalTitle; public List<Language> getSpokenLanguages() {
} return spokenLanguages;
}
public void setPopularity(float popularity) {
this.popularity = popularity; public String getTagline() {
} return tagline;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath; public float getVoteAverage() {
} return voteAverage;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate; public int getVoteCount() {
} return voteCount;
}
public void setTitle(String title) {
this.title = title; public String getStatus() {
} return status;
}
public void setAdult(boolean adult) { // </editor-fold>
this.adult = adult;
} // <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) {
public void setBelongsToCollection(Collection belongsToCollection) { this.backdropPath = backdropPath;
this.belongsToCollection = belongsToCollection; }
}
public void setId(int id) {
public void setBudget(long budget) { this.id = id;
this.budget = budget; }
}
public void setOriginalTitle(String originalTitle) {
public void setGenres(List<Genre> genres) { this.originalTitle = originalTitle;
this.genres = genres; }
}
public void setPopularity(float popularity) {
public void setHomepage(String homepage) { this.popularity = popularity;
this.homepage = homepage; }
}
public void setPosterPath(String posterPath) {
public void setImdbID(String imdbID) { this.posterPath = posterPath;
this.imdbID = imdbID; }
}
public void setReleaseDate(String releaseDate) {
public void setOverview(String overview) { this.releaseDate = releaseDate;
this.overview = overview; }
}
public void setTitle(String title) {
public void setProductionCompanies(List<ProductionCompany> productionCompanies) { this.title = title;
this.productionCompanies = productionCompanies; }
}
public void setAdult(boolean adult) {
public void setProductionCountries(List<ProductionCountry> productionCountries) { this.adult = adult;
this.productionCountries = productionCountries; }
}
public void setBelongsToCollection(Collection belongsToCollection) {
public void setRevenue(long revenue) { this.belongsToCollection = belongsToCollection;
this.revenue = revenue; }
}
public void setBudget(long budget) {
public void setRuntime(int runtime) { this.budget = budget;
this.runtime = runtime; }
}
public void setGenres(List<Genre> genres) {
public void setSpokenLanguages(List<Language> spokenLanguages) { this.genres = genres;
this.spokenLanguages = spokenLanguages; }
}
public void setHomepage(String homepage) {
public void setTagline(String tagline) { this.homepage = homepage;
this.tagline = tagline; }
}
public void setImdbID(String imdbID) {
public void setVoteAverage(float voteAverage) { this.imdbID = imdbID;
this.voteAverage = voteAverage; }
}
public void setOverview(String overview) {
public void setVoteCount(int voteCount) { this.overview = overview;
this.voteCount = voteCount; }
}
public void setProductionCompanies(List<ProductionCompany> productionCompanies) {
public void setStatus(String status) { this.productionCompanies = productionCompanies;
this.status = status; }
}
public void setProductionCountries(List<ProductionCountry> productionCountries) {
// </editor-fold> this.productionCountries = productionCountries;
/** }
* Handle unknown properties and print a message
* public void setRevenue(long revenue) {
* @param key this.revenue = revenue;
* @param value }
*/
@JsonAnySetter public void setRuntime(int runtime) {
public void handleUnknown(String key, Object value) { this.runtime = runtime;
StringBuilder sb = new StringBuilder(); }
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'"); public void setSpokenLanguages(List<Language> spokenLanguages) {
LOG.trace(sb.toString()); this.spokenLanguages = spokenLanguages;
} }
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode"> public void setTagline(String tagline) {
@Override this.tagline = tagline;
public boolean equals(Object obj) { }
if (obj == null) {
return false; public void setVoteAverage(float voteAverage) {
} this.voteAverage = voteAverage;
if (getClass() != obj.getClass()) { }
return false;
} public void setVoteCount(int voteCount) {
final MovieDb other = (MovieDb) obj; this.voteCount = voteCount;
if (this.id != other.id) { }
return false;
} public void setStatus(String status) {
if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { this.status = status;
return false; }
}
if (this.runtime != other.runtime) { // </editor-fold>
return false;
} //<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
return true; public List<AlternativeTitle> getAlternativeTitles() {
} return alternativeTitles.getTitles();
}
@Override
public int hashCode() { public List<PersonCast> getCast() {
int hash = 5; return casts.getCast();
hash = 89 * hash + this.id; }
hash = 89 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0);
hash = 89 * hash + this.runtime; public List<PersonCrew> getCrew() {
return hash; return casts.getCrew();
} }
//</editor-fold>
public List<Artwork> getImages() {
@Override return images.getAll();
public String toString() { }
StringBuilder sb = new StringBuilder("[MovieDB=");
sb.append("[backdropPath=").append(backdropPath); public List<Keyword> getKeywords() {
sb.append("],[id=").append(id); return keywords.getKeywords();
sb.append("],[originalTitle=").append(originalTitle); }
sb.append("],[popularity=").append(popularity);
sb.append("],[posterPath=").append(posterPath); public List<ReleaseInfo> getReleases() {
sb.append("],[releaseDate=").append(releaseDate); return releases.getCountries();
sb.append("],[title=").append(title); }
sb.append("],[adult=").append(adult);
sb.append("],[belongsToCollection=").append(belongsToCollection); public List<Trailer> getTrailers() {
sb.append("],[budget=").append(budget); return trailers.getAll();
sb.append("],[genres=").append(genres); }
sb.append("],[homepage=").append(homepage);
sb.append("],[imdbID=").append(imdbID); public List<Translation> getTranslations() {
sb.append("],[overview=").append(overview); return translations.getTranslations();
sb.append("],[productionCompanies=").append(productionCompanies); }
sb.append("],[productionCountries=").append(productionCountries);
sb.append("],[revenue=").append(revenue); public List<MovieDb> getSimilarMovies() {
sb.append("],[runtime=").append(runtime); return similarMovies.getMovies();
sb.append("],[spokenLanguages=").append(spokenLanguages); }
sb.append("],[tagline=").append(tagline);
sb.append("],[voteAverage=").append(voteAverage); public List<MovieList> getLists() {
sb.append("],[voteCount=").append(voteCount); return lists.getMovieList();
sb.append("],[status=").append(status); }
sb.append("]]");
return sb.toString(); public List<Reviews> getReviews() {
} return reviews.getReviews();
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters">
public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) {
this.alternativeTitles = alternativeTitles;
}
public void setCasts(WrapperMovieCasts casts) {
this.casts = casts;
}
public void setImages(WrapperImages images) {
this.images = images;
}
public void setKeywords(WrapperMovieKeywords keywords) {
this.keywords = keywords;
}
public void setReleases(WrapperReleaseInfo releases) {
this.releases = releases;
}
public void setTrailers(WrapperTrailers trailers) {
this.trailers = trailers;
}
public void setTranslations(WrapperTranslations translations) {
this.translations = translations;
}
public void setSimilarMovies(WrapperMovie similarMovies) {
this.similarMovies = similarMovies;
}
public void setLists(WrapperMovieList lists) {
this.lists = lists;
}
public void setReviews(WrapperReviews reviews) {
this.reviews = reviews;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final MovieDb other = (MovieDb) obj;
if (this.id != other.id) {
return false;
}
if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) {
return false;
}
if (this.runtime != other.runtime) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash = 89 * hash + this.id;
hash = 89 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0);
hash = 89 * hash + this.runtime;
return hash;
}
//</editor-fold>
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[MovieDB=");
sb.append("[backdropPath=").append(backdropPath);
sb.append("],[id=").append(id);
sb.append("],[originalTitle=").append(originalTitle);
sb.append("],[popularity=").append(popularity);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("],[title=").append(title);
sb.append("],[adult=").append(adult);
sb.append("],[belongsToCollection=").append(belongsToCollection);
sb.append("],[budget=").append(budget);
sb.append("],[genres=").append(genres);
sb.append("],[homepage=").append(homepage);
sb.append("],[imdbID=").append(imdbID);
sb.append("],[overview=").append(overview);
sb.append("],[productionCompanies=").append(productionCompanies);
sb.append("],[productionCountries=").append(productionCountries);
sb.append("],[revenue=").append(revenue);
sb.append("],[runtime=").append(runtime);
sb.append("],[spokenLanguages=").append(spokenLanguages);
sb.append("],[tagline=").append(tagline);
sb.append("],[voteAverage=").append(voteAverage);
sb.append("],[voteCount=").append(voteCount);
sb.append("],[status=").append(status);
sb.append("]]");
return sb.toString();
}
}
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Stuart
*/
public class Reviews implements Serializable {
private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Reviews.class);
/*
* Properties
*/
@JsonProperty("id")
private String id;
@JsonProperty("author")
private String author;
@JsonProperty("content")
private String content;
@JsonProperty("url")
private String url;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getId() {
return id;
}
public String getAuthor() {
return author;
}
public String getContent() {
return content;
}
public String getUrl() {
return url;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(String id) {
this.id = id;
}
public void setAuthor(String author) {
this.author = author;
}
public void setContent(String content) {
this.content = content;
}
public void setUrl(String url) {
this.url = url;
}
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
}
@@ -1,213 +1,251 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.tools; package com.omertron.themoviedbapi.tools;
import com.omertron.themoviedbapi.TheMovieDbApi; import java.io.UnsupportedEncodingException;
import java.io.UnsupportedEncodingException; import java.net.MalformedURLException;
import java.net.MalformedURLException; import java.net.URL;
import java.net.URL; import java.net.URLEncoder;
import java.net.URLEncoder; import java.util.HashMap;
import java.util.HashMap; import java.util.Map;
import java.util.Map; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* The API URL that is used to construct the API call * The API URL that is used to construct the API call
* *
* @author Stuart * @author Stuart
*/ */
public class ApiUrl { public class ApiUrl {
/* /*
* Logger * Logger
*/ */
private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class); private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class);
/* /*
* TheMovieDbApi API Base URL * TheMovieDbApi API Base URL
*/ */
private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
/* /*
* Parameter configuration * Parameter configuration
*/ */
private static final String DELIMITER_FIRST = "?"; private static final String DELIMITER_FIRST = "?";
private static final String DELIMITER_SUBSEQUENT = "&"; private static final String DELIMITER_SUBSEQUENT = "&";
private static final String DEFAULT_STRING = ""; private static final String DEFAULT_STRING = "";
/* /*
* Properties * Properties
*/ */
private TheMovieDbApi tmdb; private String apiKey;
private String method; private String method;
private String submethod; private String submethod;
private Map<String, String> arguments = new HashMap<String, String>(); private Map<String, String> arguments = new HashMap<String, String>();
/* /*
* API Parameters * API Parameters
*/ */
public static final String PARAM_ADULT = "include_adult="; public static final String PARAM_ADULT = "include_adult=";
public static final String PARAM_API_KEY = "api_key="; public static final String PARAM_API_KEY = "api_key=";
public static final String PARAM_COUNTRY = "country="; public static final String PARAM_COUNTRY = "country=";
public static final String PARAM_FAVORITE = "favorite="; public static final String PARAM_FAVORITE = "favorite=";
public static final String PARAM_ID = "id="; public static final String PARAM_ID = "id=";
public static final String PARAM_LANGUAGE = "language="; public static final String PARAM_LANGUAGE = "language=";
public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies="; public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
// public static final String PARAM_MOVIE_ID = "movie_id="; public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist=";
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist="; public static final String PARAM_PAGE = "page=";
public static final String PARAM_PAGE = "page="; public static final String PARAM_QUERY = "query=";
public static final String PARAM_QUERY = "query="; public static final String PARAM_SESSION = "session_id=";
public static final String PARAM_SESSION = "session_id="; public static final String PARAM_TOKEN = "request_token=";
public static final String PARAM_TOKEN = "request_token="; public static final String PARAM_VALUE = "value=";
public static final String PARAM_VALUE = "value="; public static final String PARAM_YEAR = "year=";
public static final String PARAM_YEAR = "year="; private static final String APPEND_TO_RESPONSE = "append_to_response=";
//<editor-fold defaultstate="collapsed" desc="Constructor Methods"> //<editor-fold defaultstate="collapsed" desc="Constructor Methods">
/** /**
* Constructor for the simple API URL method without a sub-method * Constructor for the simple API URL method without a sub-method
* *
* @param method * @param method
*/ */
public ApiUrl(TheMovieDbApi tmdb, String method) { public ApiUrl(String apiKey, String method) {
this.tmdb = tmdb; this.apiKey = apiKey;
this.method = method; this.method = method;
this.submethod = DEFAULT_STRING; this.submethod = DEFAULT_STRING;
} }
/** /**
* Constructor for the API URL with a sub-method * Constructor for the API URL with a sub-method
* *
* @param method * @param method
* @param submethod * @param submethod
*/ */
public ApiUrl(TheMovieDbApi tmdb, String method, String submethod) { public ApiUrl(String apiKey, String method, String submethod) {
this.tmdb = tmdb; this.apiKey = apiKey;
this.method = method; this.method = method;
this.submethod = submethod; this.submethod = submethod;
} }
//</editor-fold> //</editor-fold>
/** /**
* Build the URL from the pre-created arguments. * Build the URL from the pre-created arguments.
*/ */
public URL buildUrl() { public URL buildUrl() {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE); StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
// Get the start of the URL // Get the start of the URL
urlString.append(method); urlString.append(method);
// We have either a queury, or a direct request // We have either a queury, or a direct request
if (arguments.containsKey(PARAM_QUERY)) { if (arguments.containsKey(PARAM_QUERY)) {
// Append the suffix of the API URL // Append the suffix of the API URL
urlString.append(submethod); if(StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
urlString.deleteCharAt(urlString.length()-1);
// Append the key information }
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); urlString.append(submethod);
urlString.append(tmdb.getApiKey());
// Append the key information
// Append the search term urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(DELIMITER_SUBSEQUENT); urlString.append(apiKey);
urlString.append(PARAM_QUERY);
// Append the search term
String query = arguments.get(PARAM_QUERY); urlString.append(DELIMITER_SUBSEQUENT);
urlString.append(PARAM_QUERY);
try {
urlString.append(URLEncoder.encode(query, "UTF-8")); String query = arguments.get(PARAM_QUERY);
} catch (UnsupportedEncodingException ex) {
LOG.trace("Unable to encode query: '" + query + "' trying raw."); try {
// If we can't encode it, try it raw urlString.append(URLEncoder.encode(query, "UTF-8"));
urlString.append(query); } catch (UnsupportedEncodingException ex) {
} LOG.trace("Unable to encode query: '{}' trying raw.", query);
// If we can't encode it, try it raw
arguments.remove(PARAM_QUERY); urlString.append(query);
} else { }
// Append the ID if provided
if (arguments.containsKey(PARAM_ID)) { // Remove the query from the arguments so it is not added later
urlString.append(arguments.get(PARAM_ID)); arguments.remove(PARAM_QUERY);
arguments.remove(PARAM_ID); } else {
} // Append the ID if provided
if (arguments.containsKey(PARAM_ID)) {
// Append the suffix of the API URL urlString.append(arguments.get(PARAM_ID));
urlString.append(submethod); arguments.remove(PARAM_ID);
}
// Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); // Append the suffix of the API URL
urlString.append(tmdb.getApiKey()); if(StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
} urlString.deleteCharAt(urlString.length()-1);
}
for (Map.Entry<String, String> argEntry : arguments.entrySet()) { urlString.append(submethod);
urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey());
urlString.append(argEntry.getValue()); // Append the key information
} urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(apiKey);
try { }
LOG.trace("URL: {}", urlString.toString());
return new URL(urlString.toString()); for (Map.Entry<String, String> argEntry : arguments.entrySet()) {
} catch (MalformedURLException ex) { urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey());
LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString()); urlString.append(argEntry.getValue());
return null; }
} finally {
arguments.clear(); try {
} LOG.trace("URL: {}", urlString.toString());
} return new URL(urlString.toString());
} catch (MalformedURLException ex) {
/** LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString());
* Add arguments individually return null;
* } finally {
* @param key arguments.clear();
* @param value }
*/ }
public void addArgument(String key, String value) {
arguments.put(key, value); /**
} * Add arguments individually
*
/** * @param key
* Add arguments individually * @param value
* */
* @param key public void addArgument(String key, String value) {
* @param value arguments.put(key, value);
*/ }
public void addArgument(String key, int value) {
arguments.put(key, Integer.toString(value)); /**
} * Add arguments individually
*
/** * @param key
* Add arguments individually * @param value
* */
* @param key public void addArgument(String key, int value) {
* @param value arguments.put(key, Integer.toString(value));
*/ }
public void addArgument(String key, boolean value) {
arguments.put(key, Boolean.toString(value)); /**
} * Add arguments individually
*
/** * @param key
* Clear the arguments * @param value
*/ */
public void clearArguments() { public void addArgument(String key, boolean value) {
arguments.clear(); arguments.put(key, Boolean.toString(value));
} }
/** /**
* Set the arguments directly * Add arguments individually
* *
* @param args * @param key
*/ * @param value
public void setArguments(Map<String, String> args) { */
arguments.putAll(args); 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<String, String> 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());
}
}
}
@@ -1,74 +1,122 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Artwork; import com.omertron.themoviedbapi.model.Artwork;
import java.util.List; import com.omertron.themoviedbapi.model.ArtworkType;
import org.slf4j.LoggerFactory; import java.util.ArrayList;
import java.util.Arrays;
/** import java.util.Collections;
* import java.util.List;
* @author Stuart import org.slf4j.LoggerFactory;
*/
public class WrapperImages extends WrapperBase { /**
/* *
* Properties * @author Stuart
*/ */
public class WrapperImages extends WrapperBase {
@JsonProperty("backdrops") /*
private List<Artwork> backdrops; * Properties
@JsonProperty("posters") */
private List<Artwork> posters;
@JsonProperty("profiles") @JsonProperty("backdrops")
private List<Artwork> profiles; private List<Artwork> backdrops = Collections.EMPTY_LIST;
@JsonProperty("posters")
public WrapperImages() { private List<Artwork> posters = Collections.EMPTY_LIST;
super(LoggerFactory.getLogger(WrapperImages.class)); @JsonProperty("profiles")
} private List<Artwork> profiles = Collections.EMPTY_LIST;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> public WrapperImages() {
public List<Artwork> getBackdrops() { super(LoggerFactory.getLogger(WrapperImages.class));
return backdrops; }
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public List<Artwork> getPosters() { public List<Artwork> getBackdrops() {
return posters; return backdrops;
} }
public List<Artwork> getProfiles() { public List<Artwork> getPosters() {
return profiles; return posters;
} }
//</editor-fold>
public List<Artwork> getProfiles() {
//<editor-fold defaultstate="collapsed" desc="Setter methods"> return profiles;
public void setBackdrops(List<Artwork> backdrops) { }
this.backdrops = backdrops; //</editor-fold>
}
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setPosters(List<Artwork> posters) { public void setBackdrops(List<Artwork> backdrops) {
this.posters = posters; this.backdrops = backdrops;
} }
public void setProfiles(List<Artwork> profiles) { public void setPosters(List<Artwork> posters) {
this.profiles = profiles; this.posters = posters;
} }
//</editor-fold>
} public void setProfiles(List<Artwork> profiles) {
this.profiles = profiles;
}
//</editor-fold>
/**
* Return a list of all the artwork with their types.
*
* Leaving the parameters blank will return all types
*
* @return
*/
public List<Artwork> getAll(ArtworkType... artworkList) {
List<Artwork> artwork = new ArrayList<Artwork>();
List<ArtworkType> types;
if (artworkList.length > 0) {
types = new ArrayList<ArtworkType>(Arrays.asList(artworkList));
} else {
types = new ArrayList<ArtworkType>(Arrays.asList(ArtworkType.values()));
}
if (types.contains(ArtworkType.POSTER)) {
// Add all the posters to the list
for (Artwork poster : posters) {
poster.setArtworkType(ArtworkType.POSTER);
artwork.add(poster);
}
}
if (types.contains(ArtworkType.BACKDROP)) {
// Add all the backdrops to the list
for (Artwork backdrop : backdrops) {
backdrop.setArtworkType(ArtworkType.BACKDROP);
artwork.add(backdrop);
}
}
if (types.contains(ArtworkType.PROFILE)) {
// Add all the backdrops to the list
for (Artwork backdrop : profiles) {
backdrop.setArtworkType(ArtworkType.PROFILE);
artwork.add(backdrop);
}
}
return artwork;
}
}
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.JobDepartment;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Stuart
*/
public class WrapperJobList {
// Logger
private static final Logger LOG = LoggerFactory.getLogger(WrapperJobList.class);
// Properties
@JsonProperty("jobs")
private List<JobDepartment> jobs;
public List<JobDepartment> getJobs() {
return jobs;
}
public void setJobs(List<JobDepartment> jobs) {
this.jobs = jobs;
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
}
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieList;
import com.omertron.themoviedbapi.model.Person;
import java.util.List;
import org.slf4j.LoggerFactory;
/**
*
* @author Stuart
*/
public class WrapperPersonList extends WrapperBase {
/*
* Properties
*/
@JsonProperty("results")
private List<Person> personList;
public WrapperPersonList() {
super(LoggerFactory.getLogger(WrapperPersonList.class));
}
public List<Person> getPersonList() {
return personList;
}
public void setPersonList(List<Person> personList) {
this.personList = personList;
}
}
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Reviews;
import java.util.List;
import org.slf4j.LoggerFactory;
/**
*
* @author stuart.boston
*/
public class WrapperReviews extends WrapperBase {
/*
* Properties
*/
@JsonProperty("results")
private List<Reviews> reviews;
public WrapperReviews() {
super(LoggerFactory.getLogger(WrapperReviews.class));
}
public List<Reviews> getReviews() {
return reviews;
}
public void setReviews(List<Reviews> reviews) {
this.reviews = reviews;
}
}
@@ -1,90 +1,112 @@
/* /*
* Copyright (c) 2004-2013 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Trailer; import com.omertron.themoviedbapi.model.Trailer;
import java.util.List; import java.util.ArrayList;
import org.slf4j.Logger; import java.util.List;
import org.slf4j.LoggerFactory; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* /**
* @author Stuart *
*/ * @author Stuart
public class WrapperTrailers { */
/* public class WrapperTrailers {
* Logger /*
*/ * Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperTrailers.class);
/* private static final Logger LOG = LoggerFactory.getLogger(WrapperTrailers.class);
* Properties /*
*/ * Properties
@JsonProperty("id") */
private int id; @JsonProperty("id")
@JsonProperty("quicktime") private int id;
private List<Trailer> quicktime; @JsonProperty("quicktime")
@JsonProperty("youtube") private List<Trailer> quicktime;
private List<Trailer> youtube; @JsonProperty("youtube")
private List<Trailer> youtube;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() { //<editor-fold defaultstate="collapsed" desc="Getter methods">
return id; public int getId() {
} return id;
}
public List<Trailer> getQuicktime() {
return quicktime; public List<Trailer> getQuicktime() {
} return quicktime;
}
public List<Trailer> getYoutube() {
return youtube; public List<Trailer> getYoutube() {
} return youtube;
//</editor-fold> }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { //<editor-fold defaultstate="collapsed" desc="Setter methods">
this.id = id; public void setId(int id) {
} this.id = id;
}
public void setQuicktime(List<Trailer> quicktime) {
this.quicktime = quicktime; public void setQuicktime(List<Trailer> quicktime) {
} this.quicktime = quicktime;
}
public void setYoutube(List<Trailer> youtube) {
this.youtube = youtube; public void setYoutube(List<Trailer> youtube) {
} this.youtube = youtube;
//</editor-fold> }
//</editor-fold>
/**
* Handle unknown properties and print a message /**
* * Get a combined list of the trailers with their source website
* @param key * @return
* @param value */
*/ public List<Trailer> getAll() {
@JsonAnySetter List<Trailer> trailers = new ArrayList<Trailer>();
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder(); // Add the trailer to the return list along with it's source
sb.append("Unknown property: '").append(key); for (Trailer trailer : quicktime) {
sb.append("' value: '").append(value).append("'"); trailer.setWebsite(Trailer.WEBSITE_QUICKTIME);
LOG.trace(sb.toString()); trailers.add(trailer);
} }
} // Add the trailer to the return list along with it's source
for (Trailer trailer : youtube) {
trailer.setWebsite(Trailer.WEBSITE_YOUTUBE);
trailers.add(trailer);
}
return trailers;
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
}
+36 -36
View File
@@ -1,39 +1,39 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id> <id>bin</id>
<formats> <formats>
<format>${distribution.format}</format> <format>${distribution.format}</format>
</formats> </formats>
<includeBaseDirectory>false</includeBaseDirectory> <includeBaseDirectory>false</includeBaseDirectory>
<fileSets> <fileSets>
<!-- add version.txt file --> <!-- add version.txt file -->
<fileSet> <fileSet>
<directory>${project.build.directory}</directory> <directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory> <outputDirectory></outputDirectory>
<includes> <includes>
<include>version.txt</include> <include>version.txt</include>
</includes> </includes>
</fileSet> </fileSet>
<!-- add readme.txt file --> <!-- add readme.txt file -->
<fileSet> <fileSet>
<directory>${basedir}</directory> <directory>${basedir}</directory>
<outputDirectory></outputDirectory> <outputDirectory></outputDirectory>
<includes> <includes>
<include>readme.txt</include> <include>README.md</include>
</includes> </includes>
</fileSet> </fileSet>
<!-- add jar files --> <!-- add jar files -->
<fileSet> <fileSet>
<directory>${project.build.directory}</directory> <directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory> <outputDirectory></outputDirectory>
<includes> <includes>
<include>**/*.jar</include> <include>**/*.jar</include>
</includes> </includes>
</fileSet> </fileSet>
</fileSets> </fileSets>
</assembly> </assembly>
File diff suppressed because it is too large Load Diff