diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/ReleaseType.java b/src/main/java/com/omertron/themoviedbapi/enumeration/ReleaseType.java
new file mode 100644
index 000000000..e2b8fbe86
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/enumeration/ReleaseType.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004-2016 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.enumeration;
+
+/**
+ * Release Type for the video
+ *
+ * @author stuar
+ */
+public enum ReleaseType {
+ PREMIERE(1),
+ THEATRICAL_LIMITED(2),
+ THEATRICAL(3),
+ DIGITAL(4),
+ PHYSICAL(5),
+ TV(6),
+ UNKNOWN(0);
+
+ private final int type;
+
+ private ReleaseType(int type) {
+ this.type = type;
+ }
+
+ /**
+ * Get the Release Type from an integer type
+ *
+ * @param type
+ * @return
+ */
+ public static ReleaseType fromInteger(int type) {
+ for (ReleaseType rt : ReleaseType.values()) {
+ if (rt.type == type) {
+ return rt;
+ }
+ }
+ return UNKNOWN;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java
index 71625f086..3d3d27b90 100644
--- a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java
+++ b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java
@@ -32,6 +32,7 @@ import com.omertron.themoviedbapi.model.list.UserList;
import com.omertron.themoviedbapi.model.media.AlternativeTitle;
import com.omertron.themoviedbapi.model.movie.MovieBasic;
import com.omertron.themoviedbapi.model.movie.MovieInfo;
+import com.omertron.themoviedbapi.model.movie.ReleaseDates;
import com.omertron.themoviedbapi.model.person.ContentRating;
import com.omertron.themoviedbapi.model.person.PersonInfo;
import com.omertron.themoviedbapi.model.person.PersonFind;
@@ -100,6 +101,8 @@ public class AbstractMethod {
});
TYPE_REFS.put(AlternativeTitle.class, new TypeReference>() {
});
+ TYPE_REFS.put(ReleaseDates.class, new TypeReference>() {
+ });
}
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java
index a3f6129ff..bf2b67eff 100644
--- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java
+++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java
@@ -32,6 +32,7 @@ import com.omertron.themoviedbapi.model.media.MediaState;
import com.omertron.themoviedbapi.model.media.Translation;
import com.omertron.themoviedbapi.model.media.Video;
import com.omertron.themoviedbapi.model.movie.MovieInfo;
+import com.omertron.themoviedbapi.model.movie.ReleaseDates;
import com.omertron.themoviedbapi.model.movie.ReleaseInfo;
import com.omertron.themoviedbapi.model.review.Review;
import com.omertron.themoviedbapi.results.ResultList;
@@ -78,8 +79,7 @@ public class TmdbMovies extends AbstractMethod {
*
* It will return the single highest rated poster and backdrop.
*
- * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies
- * found.
+ * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found.
*
* @param movieId
* @param language
@@ -111,8 +111,7 @@ public class TmdbMovies extends AbstractMethod {
*
* It will return the single highest rated poster and backdrop.
*
- * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies
- * found.
+ * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found.
*
* @param imdbId
* @param language
@@ -141,8 +140,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * This method lets a user get the status of whether or not the movie has
- * been rated or added to their favourite or movie watch list.
+ * This method lets a user get the status of whether or not the movie has been rated or added to their favourite or movie watch
+ * list.
*
* A valid session id is required.
*
@@ -167,8 +166,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * This method is used to retrieve all of the alternative titles we have for
- * a particular movie.
+ * This method is used to retrieve all of the alternative titles we have for a particular movie.
*
* @param movieId
* @param country
@@ -213,8 +211,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * This method should be used when you’re wanting to retrieve all of the
- * images for a particular movie.
+ * This method should be used when you’re wanting to retrieve all of the images for a particular movie.
*
* @param movieId
* @param language
@@ -240,8 +237,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * This method is used to retrieve all of the keywords that have been added
- * to a particular movie.
+ * This method is used to retrieve all of the keywords that have been added to a particular movie.
*
* Currently, only English keywords exist.
*
@@ -267,8 +263,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * This method is used to retrieve all of the release and certification data
- * we have for a specific movie.
+ * This method is used to retrieve all of the release and certification data we have for a specific movie.
*
* @param movieId
* @param language
@@ -294,8 +289,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * This method is used to retrieve all of the trailers for a particular
- * movie.
+ * This method is used to retrieve all of the trailers for a particular movie.
*
* Supported sites are YouTube and QuickTime.
*
@@ -323,8 +317,25 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * This method is used to retrieve a list of the available translations for
- * a specific movie.
+ * Get the release dates, certifications and related information by country for a specific movie id.
+ *
+ * The results are keyed by country code and contain a type value.
+ *
+ * @param movieId
+ * @return
+ * @throws MovieDbException
+ */
+ public ResultList getReleaseDates(int movieId) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.ID, movieId);
+
+ URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.RELEASE_DATES).buildUrl(parameters);
+ WrapperGenericList wrapper = processWrapper(getTypeReference(ReleaseDates.class), url, "release dates");
+ return wrapper.getResultsList();
+ }
+
+ /**
+ * This method is used to retrieve a list of the available translations for a specific movie.
*
* @param movieId
* @return
@@ -348,11 +359,9 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * The similar movies method will let you retrieve the similar movies for a
- * particular movie.
+ * The similar movies method will let you retrieve the similar movies for a particular movie.
*
- * This data is created dynamically but with the help of users votes on
- * TMDb.
+ * This data is created dynamically but with the help of users votes on TMDb.
*
* The data is much better with movies that have more keywords
*
@@ -420,8 +429,7 @@ public class TmdbMovies extends AbstractMethod {
*
* By default, only the last 24 hours of changes are returned.
*
- * The maximum number of days that can be returned in a single request is
- * 14.
+ * The maximum number of days that can be returned in a single request is 14.
*
* The language is present on fields that are translatable.
*
@@ -513,8 +521,7 @@ public class TmdbMovies extends AbstractMethod {
/**
* This method is used to retrieve the movies currently in theatres.
*
- * This is a curated list that will normally contain 100 movies. The default
- * response will return 20 movies.
+ * This is a curated list that will normally contain 100 movies. The default response will return 20 movies.
*
* @param language
* @param page
@@ -552,8 +559,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
- * This method is used to retrieve the top rated movies that have over 10
- * votes on TMDb.
+ * This method is used to retrieve the top rated movies that have over 10 votes on TMDb.
*
* The default response will return 20 movies.
*
diff --git a/src/main/java/com/omertron/themoviedbapi/model/movie/Release.java b/src/main/java/com/omertron/themoviedbapi/model/movie/Release.java
new file mode 100644
index 000000000..207ae416d
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/movie/Release.java
@@ -0,0 +1,29 @@
+package com.omertron.themoviedbapi.model.movie;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
+
+public class Release extends AbstractJsonMapping {
+
+ @JsonProperty("certification")
+ private String certification;
+ @JsonProperty("release_date")
+ private String releaseDate;
+
+ public String getCertification() {
+ return certification;
+ }
+
+ public void setCertification(String certification) {
+ this.certification = certification;
+ }
+
+ public String getReleaseDate() {
+ return releaseDate;
+ }
+
+ public void setReleaseDate(String releaseDate) {
+ this.releaseDate = releaseDate;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseDate.java b/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseDate.java
new file mode 100644
index 000000000..ddb1a2fc1
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseDate.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2004-2016 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.movie;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSetter;
+import com.omertron.themoviedbapi.enumeration.ReleaseType;
+
+public class ReleaseDate extends Release {
+
+ private static final long serialVersionUID = 100L;
+
+ @JsonProperty("note")
+ private String note;
+ @JsonProperty("iso_639_1")
+ private String language;
+ private ReleaseType releaseType;
+
+ public String getNote() {
+ return note;
+ }
+
+ public void setNote(String note) {
+ this.note = note;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public ReleaseType getType() {
+ return releaseType;
+ }
+
+ @JsonSetter("type")
+ public void setType(int type) {
+ this.releaseType = ReleaseType.fromInteger(type);
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseDates.java b/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseDates.java
new file mode 100644
index 000000000..f733cced9
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseDates.java
@@ -0,0 +1,30 @@
+package com.omertron.themoviedbapi.model.movie;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model.AbstractJsonMapping;
+import java.util.List;
+
+public class ReleaseDates extends AbstractJsonMapping {
+
+ @JsonProperty("iso_3166_1")
+ private String country;
+ @JsonProperty("release_dates")
+ private List releaseDates;
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ public List getReleaseDates() {
+ return releaseDates;
+ }
+
+ public void setReleaseDates(List releaseDates) {
+ this.releaseDates = releaseDates;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseInfo.java
index d850b37e1..c4949047d 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseInfo.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/movie/ReleaseInfo.java
@@ -19,7 +19,6 @@
*/
package com.omertron.themoviedbapi.model.movie;
-import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.EqualsBuilder;
@@ -28,43 +27,23 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
/**
* @author Stuart
*/
-public class ReleaseInfo extends AbstractJsonMapping implements Serializable {
+public class ReleaseInfo extends Release implements Serializable {
private static final long serialVersionUID = 100L;
@JsonProperty("iso_3166_1")
private String country;
- @JsonProperty("certification")
- private String certification;
- @JsonProperty("release_date")
- private String releaseDate;
@JsonProperty("primary")
private boolean primary;
- public String getCertification() {
- return certification;
- }
-
public String getCountry() {
return country;
}
- public String getReleaseDate() {
- return releaseDate;
- }
-
- public void setCertification(String certification) {
- this.certification = certification;
- }
-
public void setCountry(String country) {
this.country = country;
}
- public void setReleaseDate(String releaseDate) {
- this.releaseDate = releaseDate;
- }
-
public boolean isPrimary() {
return primary;
}
@@ -78,9 +57,9 @@ public class ReleaseInfo extends AbstractJsonMapping implements Serializable {
if (obj instanceof ReleaseInfo) {
final ReleaseInfo other = (ReleaseInfo) obj;
return new EqualsBuilder()
- .append(country, other.country)
- .append(certification, other.certification)
- .append(releaseDate, other.releaseDate)
+ .append(getCountry(), other.getCountry())
+ .append(getCertification(), other.getCertification())
+ .append(getReleaseDate(), other.getReleaseDate())
.append(primary, other.primary)
.isEquals();
} else {
@@ -91,9 +70,9 @@ public class ReleaseInfo extends AbstractJsonMapping implements Serializable {
@Override
public int hashCode() {
return new HashCodeBuilder()
- .append(country)
- .append(certification)
- .append(releaseDate)
+ .append(getCountry())
+ .append(getCertification())
+ .append(getReleaseDate())
.append(primary)
.toHashCode();
}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java
index af3bc6d11..7e60fe7ca 100644
--- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java
@@ -39,6 +39,7 @@ import com.omertron.themoviedbapi.model.media.MediaState;
import com.omertron.themoviedbapi.model.media.Translation;
import com.omertron.themoviedbapi.model.media.Video;
import com.omertron.themoviedbapi.model.movie.MovieInfo;
+import com.omertron.themoviedbapi.model.movie.ReleaseDates;
import com.omertron.themoviedbapi.model.movie.ReleaseInfo;
import com.omertron.themoviedbapi.model.review.Review;
import com.omertron.themoviedbapi.results.ResultList;
@@ -487,4 +488,33 @@ public class TmdbMoviesTest extends AbstractTests {
TestSuite.test(result, "Top Rated");
}
+ /**
+ * Test of getReleaseDates method, of class TmdbMovies.
+ *
+ * @throws com.omertron.themoviedbapi.MovieDbException
+ */
+ @Test
+ public void testGetReleaseDates() throws MovieDbException {
+ LOG.info("getReleaseDates");
+
+ for (TestID test : FILM_IDS) {
+ ResultList result = instance.getReleaseDates(test.getTmdb());
+ LOG.info("ID: {}, Page {} of {}, {} results", result.getId(), result.getPage(), result.getTotalPages(), result.getTotalResults());
+
+ TestSuite.test(result, "release dates");
+
+ // There should always be a US release
+ boolean found = false;
+ for (ReleaseDates check : result.getResults()) {
+ if ("US".equals(check.getCountry())) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("No US release found", found);
+
+ }
+
+ }
+
}