TV Shows #1
This commit is contained in:
@@ -30,10 +30,12 @@ import com.omertron.themoviedbapi.model.keyword.Keyword;
|
||||
import com.omertron.themoviedbapi.model.list.UserList;
|
||||
import com.omertron.themoviedbapi.model.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.model.movie.MovieDb;
|
||||
import com.omertron.themoviedbapi.model.person.ContentRating;
|
||||
import com.omertron.themoviedbapi.model.person.Person;
|
||||
import com.omertron.themoviedbapi.model.person.PersonFind;
|
||||
import com.omertron.themoviedbapi.model.review.Review;
|
||||
import com.omertron.themoviedbapi.model.tv.TVBasic;
|
||||
import com.omertron.themoviedbapi.model.tv.TVInfo;
|
||||
import com.omertron.themoviedbapi.tools.HttpTools;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
|
||||
import java.io.IOException;
|
||||
@@ -83,6 +85,11 @@ public class AbstractMethod {
|
||||
});
|
||||
TYPE_REFS.put(ArtworkMedia.class, new TypeReference<WrapperGenericList<ArtworkMedia>>() {
|
||||
});
|
||||
TYPE_REFS.put(ContentRating.class, new TypeReference<WrapperGenericList<ContentRating>>() {
|
||||
});
|
||||
TYPE_REFS.put(TVInfo.class, new TypeReference<WrapperGenericList<TVInfo>>() {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,7 +67,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public Account getAccount(String sessionId) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).buildUrl(parameters);
|
||||
String webpage = httpTools.getRequest(url);
|
||||
@@ -89,7 +89,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public List<UserList> getUserLists(String sessionId, int accountId) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.LISTS).buildUrl(parameters);
|
||||
@@ -106,7 +106,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public List<MovieBasic> getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.FAVORITE_MOVIES).buildUrl(parameters);
|
||||
@@ -123,7 +123,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public List<TVBasic> getFavoriteTv(String sessionId, int accountId) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).subMethod(MethodSub.FAVORITE_TV).buildUrl(parameters);
|
||||
@@ -143,7 +143,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public StatusCode modifyFavoriteStatus(String sessionId, int accountId, MediaType mediaType, int mediaId, boolean setFavorite) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
|
||||
String jsonBody = new PostTools()
|
||||
@@ -175,7 +175,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public List<MovieBasic> getRatedMovies(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
parameters.add(Param.PAGE, page);
|
||||
parameters.add(Param.SORT_BY, sortBy);
|
||||
@@ -198,7 +198,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public List<TVBasic> getRatedTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
parameters.add(Param.PAGE, page);
|
||||
parameters.add(Param.SORT_BY, sortBy);
|
||||
@@ -221,7 +221,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public List<MovieBasic> getWatchListMovie(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
parameters.add(Param.PAGE, page);
|
||||
parameters.add(Param.SORT_BY, sortBy);
|
||||
@@ -244,7 +244,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public List<TVBasic> getWatchListTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
parameters.add(Param.PAGE, page);
|
||||
parameters.add(Param.SORT_BY, sortBy);
|
||||
@@ -267,7 +267,7 @@ public class TmdbAccount extends AbstractMethod {
|
||||
*/
|
||||
public StatusCode modifyWatchList(String sessionId, int accountId, MediaType mediaType, Integer movieId, boolean addToWatchlist) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, accountId);
|
||||
|
||||
String jsonBody = new PostTools()
|
||||
|
||||
@@ -112,7 +112,7 @@ public class TmdbLists extends AbstractMethod {
|
||||
*/
|
||||
public String createList(String sessionId, String name, String description) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
|
||||
String jsonBody = new PostTools()
|
||||
.add(PostBody.NAME, StringUtils.trimToEmpty(name))
|
||||
@@ -140,7 +140,7 @@ public class TmdbLists extends AbstractMethod {
|
||||
public StatusCode deleteList(String sessionId, String listId) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, listId);
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters);
|
||||
String webpage = httpTools.deleteRequest(url);
|
||||
@@ -166,7 +166,7 @@ public class TmdbLists extends AbstractMethod {
|
||||
*/
|
||||
private StatusCode modifyMovieList(String sessionId, String listId, int movieId, MethodSub operation) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, listId);
|
||||
|
||||
String jsonBody = new PostTools()
|
||||
@@ -228,7 +228,7 @@ public class TmdbLists extends AbstractMethod {
|
||||
*/
|
||||
public StatusCode clear(String sessionId, String listId, boolean confirm) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.ID, listId);
|
||||
parameters.add(Param.CONFIRM, confirm);
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
}
|
||||
return movie;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie info", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get info", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
}
|
||||
return movie;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie info (IMDB)", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get info (IMDB)", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
public MediaState getMovieAccountState(int movieId, String sessionId) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, movieId);
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.ACCOUNT_STATES).buildUrl(parameters);
|
||||
String webpage = httpTools.getRequest(url);
|
||||
@@ -212,7 +212,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
try {
|
||||
return MAPPER.readValue(webpage, MediaCreditList.class);
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie credits", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get credits", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie images", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get images", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie keywords", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get keywords", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie release information", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get release information", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie trailers", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get videos", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie tranlations", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get translations", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
try {
|
||||
return MAPPER.readValue(webpage, WrapperChanges.class);
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie changes", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get changes", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, movieId);
|
||||
parameters.add(Param.SESSION, sessionId);
|
||||
parameters.add(Param.SESSION_ID, sessionId);
|
||||
parameters.add(Param.GUEST_SESSION_ID, guestSessionId);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.RATING).buildUrl(parameters);
|
||||
@@ -499,7 +499,7 @@ public class TmdbMovies extends AbstractMethod {
|
||||
try {
|
||||
return MAPPER.readValue(webpage, StatusCode.class);
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to post movie rating", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to post rating", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,14 @@ package com.omertron.themoviedbapi.methods;
|
||||
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import static com.omertron.themoviedbapi.methods.AbstractMethod.MAPPER;
|
||||
import com.omertron.themoviedbapi.model.StatusCode;
|
||||
import com.omertron.themoviedbapi.model.artwork.Artwork;
|
||||
import com.omertron.themoviedbapi.model.keyword.Keyword;
|
||||
import com.omertron.themoviedbapi.model.media.MediaCreditList;
|
||||
import com.omertron.themoviedbapi.model.media.MediaState;
|
||||
import com.omertron.themoviedbapi.model.movie.AlternativeTitle;
|
||||
import com.omertron.themoviedbapi.model.person.ContentRating;
|
||||
import com.omertron.themoviedbapi.model.person.ExternalID;
|
||||
import com.omertron.themoviedbapi.model.tv.TVInfo;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import com.omertron.themoviedbapi.tools.ApiUrl;
|
||||
@@ -30,9 +36,13 @@ import com.omertron.themoviedbapi.tools.HttpTools;
|
||||
import com.omertron.themoviedbapi.tools.MethodBase;
|
||||
import com.omertron.themoviedbapi.tools.MethodSub;
|
||||
import com.omertron.themoviedbapi.tools.Param;
|
||||
import com.omertron.themoviedbapi.tools.PostBody;
|
||||
import com.omertron.themoviedbapi.tools.PostTools;
|
||||
import com.omertron.themoviedbapi.tools.TmdbParameters;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperChanges;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperImages;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import org.yamj.api.common.exception.ApiExceptionType;
|
||||
@@ -44,6 +54,8 @@ import org.yamj.api.common.exception.ApiExceptionType;
|
||||
*/
|
||||
public class TmdbTV extends AbstractMethod {
|
||||
|
||||
private static final int RATING_MAX = 10;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -80,8 +92,8 @@ public class TmdbTV extends AbstractMethod {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method lets users get the status of whether or not the TV show has been rated or added to their favourite or watch
|
||||
* lists.
|
||||
* This method lets users get the status of whether or not the TV show has
|
||||
* been rated or added to their favourite or watch lists.
|
||||
*
|
||||
* A valid session id is required.
|
||||
*
|
||||
@@ -93,7 +105,7 @@ public class TmdbTV extends AbstractMethod {
|
||||
public MediaState getTVAccountState(int tvID, String sessionID) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, tvID);
|
||||
parameters.add(Param.SESSION, sessionID);
|
||||
parameters.add(Param.SESSION_ID, sessionID);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.ACCOUNT_STATES).buildUrl(parameters);
|
||||
String webpage = httpTools.getRequest(url);
|
||||
@@ -160,12 +172,13 @@ public class TmdbTV extends AbstractMethod {
|
||||
* @return
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
public String getTVContentRatings(int tvID) throws MovieDbException {
|
||||
public TmdbResultsList<ContentRating> getTVContentRatings(int tvID) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, tvID);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.CONTENT_RATINGS).buildUrl(parameters);
|
||||
return null;
|
||||
WrapperGenericList<ContentRating> wrapper = processWrapper(getTypeReference(ContentRating.class), url, "content rating");
|
||||
return wrapper.getTmdbResultsList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,14 +190,19 @@ public class TmdbTV extends AbstractMethod {
|
||||
* @return
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
public String getTVCredits(int tvID, String language, String... appendToResponse) throws MovieDbException {
|
||||
public MediaCreditList getTVCredits(int tvID, String language, String... appendToResponse) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, tvID);
|
||||
parameters.add(Param.LANGUAGE, language);
|
||||
parameters.add(Param.APPEND, appendToResponse);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.CREDITS).buildUrl(parameters);
|
||||
return null;
|
||||
String webpage = httpTools.getRequest(url);
|
||||
try {
|
||||
return MAPPER.readValue(webpage, MediaCreditList.class);
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie credits", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,13 +213,19 @@ public class TmdbTV extends AbstractMethod {
|
||||
* @return
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
public String getTVExternalIDs(int tvID, String language) throws MovieDbException {
|
||||
public ExternalID getTVExternalIDs(int tvID, String language) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, tvID);
|
||||
parameters.add(Param.LANGUAGE, language);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.EXTERNAL_IDS).buildUrl(parameters);
|
||||
return null;
|
||||
String webpage = httpTools.getRequest(url);
|
||||
|
||||
try {
|
||||
return MAPPER.readValue(webpage, ExternalID.class);
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get external IDs", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,13 +237,22 @@ public class TmdbTV extends AbstractMethod {
|
||||
* @return
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
public String getTVImages(int tvID, String language, String... includeImageLanguage) throws MovieDbException {
|
||||
public TmdbResultsList<Artwork> getTVImages(int tvID, String language, String... includeImageLanguage) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, tvID);
|
||||
parameters.add(Param.LANGUAGE, language);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.IMAGES).buildUrl(parameters);
|
||||
return null;
|
||||
String webpage = httpTools.getRequest(url);
|
||||
|
||||
try {
|
||||
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
|
||||
TmdbResultsList<Artwork> results = new TmdbResultsList<Artwork>(wrapper.getAll());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get images", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,13 +263,14 @@ public class TmdbTV extends AbstractMethod {
|
||||
* @return
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
public String getTVKeywords(int tvID, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<Keyword> getTVKeywords(int tvID, String... appendToResponse) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, tvID);
|
||||
parameters.add(Param.APPEND, appendToResponse);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.KEYWORDS).buildUrl(parameters);
|
||||
return null;
|
||||
WrapperGenericList<Keyword> wrapper = processWrapper(getTypeReference(Keyword.class), url, "keywords");
|
||||
return wrapper.getTmdbResultsList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,14 +285,27 @@ public class TmdbTV extends AbstractMethod {
|
||||
* @return
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
public String postTVRating(int tvID, int rating, String sessionID, String guestSessionID) throws MovieDbException {
|
||||
public StatusCode postTVRating(int tvID, int rating, String sessionID, String guestSessionID) throws MovieDbException {
|
||||
if (rating < 0 || rating > RATING_MAX) {
|
||||
throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Rating out of range");
|
||||
}
|
||||
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, tvID);
|
||||
parameters.add(Param.SESSION, sessionID);
|
||||
parameters.add(Param.SESSION_ID, sessionID);
|
||||
parameters.add(Param.GUEST_SESSION_ID, guestSessionID);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.RATING).buildUrl(parameters);
|
||||
return null;
|
||||
String jsonBody = new PostTools()
|
||||
.add(PostBody.VALUE, rating)
|
||||
.build();
|
||||
String webpage = httpTools.postRequest(url, jsonBody);
|
||||
|
||||
try {
|
||||
return MAPPER.readValue(webpage, StatusCode.class);
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to post rating", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,7 +318,7 @@ public class TmdbTV extends AbstractMethod {
|
||||
* @return
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
public String getTVSimilar(int tvID, Integer page, String language, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<TVInfo> getTVSimilar(int tvID, Integer page, String language, String... appendToResponse) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, tvID);
|
||||
parameters.add(Param.PAGE, page);
|
||||
@@ -279,11 +326,13 @@ public class TmdbTV extends AbstractMethod {
|
||||
parameters.add(Param.APPEND, appendToResponse);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.SIMILAR).buildUrl(parameters);
|
||||
return null;
|
||||
WrapperGenericList<TVInfo> wrapper = processWrapper(getTypeReference(TVInfo.class), url, "similar TV shows");
|
||||
return wrapper.getTmdbResultsList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of translations that exist for a TV series. These translations cascade down to the episode level.
|
||||
* Get the list of translations that exist for a TV series. These
|
||||
* translations cascade down to the episode level.
|
||||
*
|
||||
* @param tvID
|
||||
* @return
|
||||
@@ -298,7 +347,8 @@ public class TmdbTV extends AbstractMethod {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the videos that have been added to a TV series (trailers, opening credits, etc...)
|
||||
* Get the videos that have been added to a TV series (trailers, opening
|
||||
* credits, etc...)
|
||||
*
|
||||
* @param tvID
|
||||
* @param language
|
||||
@@ -328,7 +378,8 @@ public class TmdbTV extends AbstractMethod {
|
||||
/**
|
||||
* Get the list of TV shows that are currently on the air.
|
||||
*
|
||||
* This query looks for any TV show that has an episode with an air date in the next 7 days.
|
||||
* This query looks for any TV show that has an episode with an air date in
|
||||
* the next 7 days.
|
||||
*
|
||||
* @param page
|
||||
* @param language
|
||||
@@ -368,7 +419,8 @@ public class TmdbTV extends AbstractMethod {
|
||||
/**
|
||||
* Get the list of top rated TV shows.
|
||||
*
|
||||
* By default, this list will only include TV shows that have 2 or more votes.
|
||||
* By default, this list will only include TV shows that have 2 or more
|
||||
* votes.
|
||||
*
|
||||
* This list refreshes every day.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model.person;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stuart.Boston
|
||||
*/
|
||||
public class ContentRating {
|
||||
|
||||
@JsonProperty("iso_3166_1")
|
||||
private String language;
|
||||
@JsonProperty("rating")
|
||||
private String rating;
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public String getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public void setRating(String rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public enum Param {
|
||||
PASSWORD("password="),
|
||||
QUERY("query="),
|
||||
SEARCH_TYPE("search_type="),
|
||||
SESSION("session_id="),
|
||||
SESSION_ID("session_id="),
|
||||
START_DATE("start_date="),
|
||||
TIMEZONE("timezone="),
|
||||
TOKEN("request_token="),
|
||||
|
||||
@@ -24,10 +24,18 @@ import static com.omertron.themoviedbapi.AbstractTests.getApiKey;
|
||||
import static com.omertron.themoviedbapi.AbstractTests.getHttpTools;
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.TestID;
|
||||
import com.omertron.themoviedbapi.enumeration.ArtworkType;
|
||||
import com.omertron.themoviedbapi.model.StatusCode;
|
||||
import com.omertron.themoviedbapi.model.artwork.Artwork;
|
||||
import com.omertron.themoviedbapi.model.change.ChangeKeyItem;
|
||||
import com.omertron.themoviedbapi.model.change.ChangeListItem;
|
||||
import com.omertron.themoviedbapi.model.keyword.Keyword;
|
||||
import com.omertron.themoviedbapi.model.media.MediaCreditCast;
|
||||
import com.omertron.themoviedbapi.model.media.MediaCreditList;
|
||||
import com.omertron.themoviedbapi.model.media.MediaState;
|
||||
import com.omertron.themoviedbapi.model.movie.AlternativeTitle;
|
||||
import com.omertron.themoviedbapi.model.person.ContentRating;
|
||||
import com.omertron.themoviedbapi.model.person.ExternalID;
|
||||
import com.omertron.themoviedbapi.model.tv.TVInfo;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import com.omertron.themoviedbapi.tools.MethodBase;
|
||||
@@ -36,7 +44,10 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -62,9 +73,9 @@ public class TmdbTVTest extends AbstractTests {
|
||||
doConfiguration();
|
||||
instance = new TmdbTV(getApiKey(), getHttpTools());
|
||||
|
||||
TV_IDS.add(new TestID("The Walking Dead", "tt1520211", 1402));
|
||||
// TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622));
|
||||
// TV_IDS.add(new TestID("The Big Bang Theory", "tt0898266", 1418));
|
||||
TV_IDS.add(new TestID("The Walking Dead", "tt1520211", 1402, "Andrew Lincoln"));
|
||||
// TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622,"Misha Collins"));
|
||||
// TV_IDS.add(new TestID("The Big Bang Theory", "tt0898266", 1418,"Kaley Cuoco"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,12 +167,15 @@ public class TmdbTVTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
// @Test
|
||||
public void testGetTVContentRatings() throws MovieDbException {
|
||||
LOG.info("getTVContentRatings");
|
||||
|
||||
for (TestID test : TV_IDS) {
|
||||
String result = instance.getTVContentRatings(test.getTmdb());
|
||||
TmdbResultsList<ContentRating> result = instance.getTVContentRatings(test.getTmdb());
|
||||
assertFalse("No ratings", result.isEmpty());
|
||||
assertTrue("No language", StringUtils.isNotBlank(result.getResults().get(0).getLanguage()));
|
||||
assertTrue("No rating", StringUtils.isNotBlank(result.getResults().get(0).getRating()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,18 +184,27 @@ public class TmdbTVTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
// @Test
|
||||
public void testGetTVCredits() throws MovieDbException {
|
||||
LOG.info("getTVCredits");
|
||||
|
||||
String language = LANGUAGE_DEFAULT;
|
||||
String[] appendToResponse = null;
|
||||
|
||||
for (TestID test : TV_IDS) {
|
||||
String result = instance.getTVCredits(test.getTmdb(), language, appendToResponse);
|
||||
MediaCreditList result = instance.getTVCredits(test.getTmdb(), LANGUAGE_DEFAULT);
|
||||
assertNotNull(result);
|
||||
assertFalse(result.getCast().isEmpty());
|
||||
|
||||
boolean found = false;
|
||||
for (MediaCreditCast p : result.getCast()) {
|
||||
if (test.getOther().equals(p.getName())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(test.getOther() + " not found in cast!", found);
|
||||
|
||||
assertFalse(result.getCrew().isEmpty());
|
||||
break;
|
||||
}
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,17 +212,16 @@ public class TmdbTVTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
// @Test
|
||||
public void testGetTVExternalIDs() throws MovieDbException {
|
||||
LOG.info("getTVExternalIDs");
|
||||
|
||||
String language = LANGUAGE_DEFAULT;
|
||||
|
||||
for (TestID test : TV_IDS) {
|
||||
String result = instance.getTVExternalIDs(test.getTmdb(), language);
|
||||
ExternalID result = instance.getTVExternalIDs(test.getTmdb(), language);
|
||||
assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbId());
|
||||
}
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,18 +229,35 @@ public class TmdbTVTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
// @Test
|
||||
public void testGetTVImages() throws MovieDbException {
|
||||
LOG.info("getTVImages");
|
||||
|
||||
String language = LANGUAGE_DEFAULT;
|
||||
String[] includeImageLanguage = null;
|
||||
|
||||
boolean foundBackdrop = false;
|
||||
boolean foundPoster = false;
|
||||
boolean foundOther = false;
|
||||
|
||||
for (TestID test : TV_IDS) {
|
||||
String result = instance.getTVImages(test.getTmdb(), language, includeImageLanguage);
|
||||
TmdbResultsList<Artwork> result = instance.getTVImages(test.getTmdb(), language, includeImageLanguage);
|
||||
assertFalse("No artwork", result.isEmpty());
|
||||
for (Artwork artwork : result.getResults()) {
|
||||
if (artwork.getArtworkType() == ArtworkType.BACKDROP) {
|
||||
foundBackdrop = true;
|
||||
continue;
|
||||
} else if (artwork.getArtworkType() == ArtworkType.POSTER) {
|
||||
foundPoster = true;
|
||||
continue;
|
||||
}
|
||||
foundOther = true;
|
||||
}
|
||||
assertTrue("No backdrops", foundBackdrop);
|
||||
assertTrue("No posters", foundPoster);
|
||||
assertFalse("Something else found!", foundOther);
|
||||
}
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,17 +265,16 @@ public class TmdbTVTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
// @Test
|
||||
public void testGetTVKeywords() throws MovieDbException {
|
||||
LOG.info("getTVKeywords");
|
||||
|
||||
String[] appendToResponse = null;
|
||||
|
||||
for (TestID test : TV_IDS) {
|
||||
String result = instance.getTVKeywords(test.getTmdb(), appendToResponse);
|
||||
TmdbResultsList<Keyword> result = instance.getTVKeywords(test.getTmdb(), appendToResponse);
|
||||
assertFalse("No keywords", result.isEmpty());
|
||||
}
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,17 +282,15 @@ public class TmdbTVTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
// @Test
|
||||
public void testPostTVRating() throws MovieDbException {
|
||||
LOG.info("postTVRating");
|
||||
|
||||
int rating = 0;
|
||||
|
||||
for (TestID test : TV_IDS) {
|
||||
String result = instance.postTVRating(test.getTmdb(), rating, getSessionId(), null);
|
||||
Integer rating = new Random().nextInt(10) + 1;
|
||||
StatusCode result = instance.postTVRating(test.getTmdb(), rating, getSessionId(), null);
|
||||
assertEquals("failed to post rating", 12, result.getCode());
|
||||
}
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +298,7 @@ public class TmdbTVTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetTVSimilar() throws MovieDbException {
|
||||
LOG.info("getTVSimilar");
|
||||
|
||||
@@ -271,10 +307,9 @@ public class TmdbTVTest extends AbstractTests {
|
||||
String[] appendToResponse = null;
|
||||
|
||||
for (TestID test : TV_IDS) {
|
||||
String result = instance.getTVSimilar(test.getTmdb(), page, language, appendToResponse);
|
||||
TmdbResultsList<TVInfo> result = instance.getTVSimilar(test.getTmdb(), page, language, appendToResponse);
|
||||
assertFalse("No similar TV shows", result.isEmpty());
|
||||
}
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user