Inital commit for release 4.0

Signed-off-by: Stuart Boston <Stuart.Boston@Gmail.com>
master
Stuart Boston 11 years ago
parent 84e59d53eb
commit bbda0eec72

File diff suppressed because it is too large Load Diff

@ -0,0 +1,37 @@
/*
* 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.enumeration;
/**
* Media type options
*
* @author Stuart
*/
public enum MediaType {
/**
* Movie media type
*/
MOVIE,
/**
* TV Show media type
*/
TV;
}

@ -0,0 +1,73 @@
/*
* 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.methods;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.tools.HttpTools;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yamj.api.common.exception.ApiExceptionType;
/**
* Abstract methods
*
* @author Stuart
*/
public class AbstractMethod {
// The API key to be used
protected final String apiKey;
// The HttpTools to use
protected final HttpTools httpTools;
// Jackson JSON configuration
protected static final ObjectMapper MAPPER = new ObjectMapper();
// Logger
protected static final Logger LOG = LoggerFactory.getLogger(TmdbAccount.class);
/**
* Default constructor for the methods
*
* @param apiKey
* @param httpTools
*/
public AbstractMethod(String apiKey, HttpTools httpTools) {
this.apiKey = apiKey;
this.httpTools = httpTools;
}
/**
* Use Jackson to convert Map to JSON string.
*
* @param map
* @return
* @throws MovieDbException
*/
protected static String convertToJson(Map<String, ?> map) throws MovieDbException {
try {
return MAPPER.writeValueAsString(map);
} catch (JsonProcessingException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "JSON conversion failed", "", ex);
}
}
}

@ -0,0 +1,289 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.enumeration.MediaType;
import com.omertron.themoviedbapi.model.Account;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieDbList;
import com.omertron.themoviedbapi.model.StatusCode;
import com.omertron.themoviedbapi.tools.ApiUrl;
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.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperMovie;
import com.omertron.themoviedbapi.wrapper.WrapperMovieDbList;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.yamj.api.common.exception.ApiExceptionType;
/**
* Class to hold the Account Methods
*
* @author stuart.boston
*/
public class TmdbAccount extends AbstractMethod {
private static final String MEDIA_ID = "media_id";
private static final String MEDIA_TYPE = "media_type";
private static final String FAVORITE = "favorite";
private static final String WATCHLIST = "watchlist";
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbAccount(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
/**
* Get the basic information for an account. You will need to have a valid session id.
*
* @param sessionId
* @return
* @throws MovieDbException
*/
public Account getAccount(String sessionId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, Account.class);
} catch (IOException ex) {
LOG.warn("Failed to get Account: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* Get all lists of a given user
*
* @param sessionId
* @param accountId
* @return The lists
* @throws MovieDbException
*/
public List<MovieDbList> getUserLists(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.LISTS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, WrapperMovieDbList.class).getLists();
} catch (IOException ex) {
LOG.warn("Failed to get user list: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* Get the list of favorite movies for an account.
*
* @param sessionId
* @param accountId
* @return
* @throws MovieDbException
*/
public List<MovieDb> getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.FAVORITE_MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, WrapperMovie.class).getMovies();
} catch (IOException ex) {
LOG.warn("Failed to get favorite movies: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* Get the list of favorite TV series for an account.
*
* @param sessionId
* @param accountId
* @return
* @throws MovieDbException
*/
public List getFavoriteTv(String sessionId, int accountId) throws MovieDbException {
throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Not implemented yet");
}
/**
* Add or remove a movie to an accounts favorite list.
*
* @param sessionId
* @param accountId
* @param mediaType
* @param mediaId
* @param isFavorite
* @return
* @throws MovieDbException
*/
public StatusCode changeFavoriteStatus(String sessionId, int accountId, Integer mediaId, MediaType mediaType, boolean isFavorite) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
Map<String, Object> body = new HashMap<String, Object>();
body.put(MEDIA_TYPE, mediaType.toString().toLowerCase());
body.put(MEDIA_ID, mediaId);
body.put(FAVORITE, isFavorite);
String jsonBody = convertToJson(body);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.FAVORITE).buildUrl(parameters);
String webpage = httpTools.postRequest(url, jsonBody);
try {
return MAPPER.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
LOG.warn("Failed to get favorite status: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* Get the list of rated movies (and associated rating) for an account.
*
* @param sessionId
* @param accountId
* @return
* @throws MovieDbException
*/
public List<MovieDb> getRatedMovies(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.RATED_MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, WrapperMovie.class).getMovies();
} catch (IOException ex) {
LOG.warn("Failed to get rated movies: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* Get the list of rated TV shows (and associated rating) for an account.
*
* @param sessionId
* @param accountId
* @return
* @throws MovieDbException
*/
public List getRatedTV(String sessionId, int accountId) throws MovieDbException {
throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Not implemented yet");
}
/**
* Get the list of movies on an accounts watch list.
*
* @param sessionId
* @param accountId
* @return The watch list of the user
* @throws MovieDbException
*/
public List<MovieDb> getWatchListMovie(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.WATCHLIST_MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, WrapperMovie.class).getMovies();
} catch (IOException ex) {
LOG.warn("Failed to get Movie watch list: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* Get the list of movies on an accounts watch list.
*
* @param sessionId
* @param accountId
* @return The watch list of the user
* @throws MovieDbException
*/
public List getWatchListTV(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.WATCHLIST_TV).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, WrapperMovie.class).getMovies();
} catch (IOException ex) {
LOG.warn("Failed to get TV watch list: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* Add or remove a movie to an accounts watch list.
*
* @param sessionId
* @param accountId
* @param movieId
* @param mediaType
* @param addToWatchlist
* @return
* @throws MovieDbException
*/
public StatusCode modifyWatchList(String sessionId, int accountId, Integer movieId, MediaType mediaType, boolean addToWatchlist) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
Map<String, Object> body = new HashMap<String, Object>();
body.put(MEDIA_TYPE, mediaType.toString().toLowerCase());
body.put(MEDIA_ID, movieId);
body.put(WATCHLIST, addToWatchlist);
String jsonBody = convertToJson(body);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.WATCHLIST).buildUrl(parameters);
String webpage = httpTools.postRequest(url, jsonBody);
try {
return MAPPER.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
LOG.warn("Failed to modify watch list: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
}

@ -0,0 +1,166 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.TokenAuthorisation;
import com.omertron.themoviedbapi.model.TokenSession;
import com.omertron.themoviedbapi.tools.ApiUrl;
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.TmdbParameters;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;
/**
* Class to hold the Authentication Methods
*
* @author stuart.boston
*/
public class TmdbAuthentication extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbAuthentication(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
/**
* This method is used to generate a valid request token for user based authentication.
*
* A request token is required in order to request a session id.
*
* You can generate any number of request tokens but they will expire after 60 minutes.
*
* As soon as a valid session id has been created the token will be destroyed.
*
* @return
* @throws MovieDbException
*/
public TokenAuthorisation getAuthorisationToken() throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
URL url = new ApiUrl(apiKey, MethodBase.AUTH).setSubMethod(MethodSub.TOKEN_NEW).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, TokenAuthorisation.class);
} catch (IOException ex) {
LOG.warn("Failed to get Authorisation Token: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, webpage, url, ex);
}
}
/**
* This method is used to generate a session id for user based authentication.
*
* A session id is required in order to use any of the write methods.
*
* @param token
* @return
* @throws MovieDbException
*/
public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
if (!token.getSuccess()) {
LOG.warn("Session token was not successful!");
throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, "Authorisation token was not successful!");
}
parameters.add(Param.TOKEN, token.getRequestToken());
URL url = new ApiUrl(apiKey, MethodBase.AUTH).setSubMethod(MethodSub.SESSION_NEW).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, TokenSession.class);
} catch (IOException ex) {
LOG.warn("Failed to get Session Token: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* This method is used to generate a session id for user based authentication. User must provide their username and password
*
* A session id is required in order to use any of the write methods.
*
* @param token Session token
* @param username User's username
* @param password User's password
* @return
* @throws MovieDbException
*/
public TokenAuthorisation getSessionTokenLogin(TokenAuthorisation token, String username, String password) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
if (!token.getSuccess()) {
LOG.warn("Session token was not successful!");
throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, "Authorisation token was not successful!");
}
parameters.add(Param.TOKEN, token.getRequestToken());
parameters.add(Param.USERNAME, username);
parameters.add(Param.PASSWORD, password);
URL url = new ApiUrl(apiKey, MethodBase.AUTH).setSubMethod(MethodSub.TOKEN_VALIDATE).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, TokenAuthorisation.class);
} catch (IOException ex) {
LOG.warn("Failed to get Session Token: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}
/**
* This method is used to generate a guest session id.
*
* A guest session can be used to rate movies without having a registered TMDb user account.
*
* You should only generate a single guest session per user (or device) as you will be able to attach the ratings to a TMDb user
* account in the future.
*
* There are also IP limits in place so you should always make sure it's the end user doing the guest session actions.
*
* If a guest session is not used for the first time within 24 hours, it will be automatically discarded.
*
* @return
* @throws MovieDbException
*/
public TokenSession getGuestSessionToken() throws MovieDbException {
URL url = new ApiUrl(apiKey, MethodBase.AUTH).setSubMethod(MethodSub.GUEST_SESSION).buildUrl();
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, TokenSession.class);
} catch (IOException ex) {
LOG.warn("Failed to get Guest Session Token: {}", ex.getMessage(), ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, webpage, url, ex);
}
}}

@ -0,0 +1,93 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.results.TmdbResultsMap;
import com.omertron.themoviedbapi.tools.HttpTools;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.omertron.themoviedbapi.model.Certification;
import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
import org.yamj.api.common.exception.ApiExceptionType;
/**
* Class to hold the Certification Methods
*
* @author stuart.boston
*/
public class TmdbCertifications extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbCertifications(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
/**
* Get a list of movies certification.
*
* @return
* @throws MovieDbException
*/
public TmdbResultsMap<String, List<Certification>> getMoviesCertification() throws MovieDbException {
URL url = new ApiUrl(apiKey, MethodBase.CERTIFICATION).setSubMethod(MethodSub.MOVIE_LIST).buildUrl();
String webpage = httpTools.getRequest(url);
try {
JsonNode node = MAPPER.readTree(webpage);
Map<String, List<Certification>> results = MAPPER.readValue(node.elements().next().traverse(), new TypeReference<Map<String, List<Certification>>>() {
});
return new TmdbResultsMap<String, List<Certification>>(results);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie certifications", url, ex);
}
}
/**
* Get a list of tv certification.
*
* @return
* @throws MovieDbException
*/
public TmdbResultsMap<String, List<Certification>> getTvCertification() throws MovieDbException {
URL url = new ApiUrl(apiKey, MethodBase.CERTIFICATION).setSubMethod(MethodSub.TV_LIST).buildUrl();
String webpage = httpTools.getRequest(url);
try {
JsonNode node = MAPPER.readTree(webpage);
Map<String, List<Certification>> results = MAPPER.readValue(node.elements().next().traverse(), new TypeReference<Map<String, List<Certification>>>() {
});
return new TmdbResultsMap<String, List<Certification>>(results);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV certifications", url, ex);
}
}
}

@ -0,0 +1,131 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.ChangedItem;
import com.omertron.themoviedbapi.model.ChangedMedia;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.results.TmdbResultsMap;
import com.omertron.themoviedbapi.tools.ApiUrl;
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.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperMediaChanges;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import org.yamj.api.common.exception.ApiExceptionType;
/**
* Class to hold the Change Methods
*
* @author stuart.boston
*/
public class TmdbChanges extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbChanges(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
/**
* Get the changes for a specific movie id.
*
* Changes are grouped by key, and ordered by date in descending order.
*
* 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 language is present on fields that are translatable.
*
* TODO: DOES NOT WORK AT THE MOMENT. This is due to the "value" item changing type in the ChangeItem
*
* @param movieId
* @param startDate the start date of the changes, optional
* @param endDate the end date of the changes, optional
* @return
* @throws MovieDbException
*/
public TmdbResultsMap<String, List<ChangedItem>> getMovieChanges(int movieId, String startDate, String endDate) throws MovieDbException {
return null;
}
/**
* Get the changes for a specific person id.
*
* Changes are grouped by key, and ordered by date in descending order.
*
* 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 language is present on fields that are translatable.
*
* @param personId
* @param startDate
* @param endDate
* @throws MovieDbException
*/
public void getPersonChanges(int personId, String startDate, String endDate) throws MovieDbException {
LOG.trace("getPersonChanges: id: {}, start: {}, end: {}", personId, startDate, endDate);
throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Not implemented yet", "");
}
/**
* Get a list of Media IDs that have been edited.
*
* You can then use the movie/TV/person changes API to get the actual data that has been changed.
*
* @param method The method base to get
* @param page
* @param startDate the start date of the changes, optional
* @param endDate the end date of the changes, optional
* @return List of changed movie
* @throws MovieDbException
*/
public TmdbResultsList<ChangedMedia> getChangeList(MethodBase method, int page, String startDate, String endDate) throws MovieDbException {
TmdbParameters params = new TmdbParameters();
params.add(Param.PAGE, page);
params.add(Param.START_DATE, startDate);
params.add(Param.END_DATE, endDate);
URL url = new ApiUrl(apiKey, method).setSubMethod(MethodSub.CHANGES).buildUrl(params);
String webpage = httpTools.getRequest(url);
try {
WrapperMediaChanges wrapper = MAPPER.readValue(webpage, WrapperMediaChanges.class);
TmdbResultsList<ChangedMedia> results = new TmdbResultsList<ChangedMedia>(wrapper.getResults());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get changes", url, ex);
}
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Collections Methods
*
* @author stuart.boston
*/
public class TmdbCollections extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbCollections(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Company Methods
*
* @author stuart.boston
*/
public class TmdbCompanies extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbCompanies(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Configuration Methods
*
* @author stuart.boston
*/
public class TmdbConfiguration extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbConfiguration(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Credit Methods
*
* @author stuart.boston
*/
public class TmdbCredits extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbCredits(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Discover Methods
*
* @author stuart.boston
*/
public class TmdbDiscover extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbDiscover(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Find Methods
*
* @author stuart.boston
*/
public class TmdbFind extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbFind(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Genre Methods
*
* @author stuart.boston
*/
public class TmdbGenres extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbGenres(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Job Methods
*
* @author stuart.boston
*/
public class TmdbJobs extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbJobs(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Keyword Methods
*
* @author stuart.boston
*/
public class TmdbKeywords extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbKeywords(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the List Methods
*
* @author stuart.boston
*/
public class TmdbLists extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbLists(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Movie Methods
*
* @author stuart.boston
*/
public class TmdbMovies extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbMovies(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Network Methods
*
* @author stuart.boston
*/
public class TmdbNetworks extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbNetworks(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the People Methods
*
* @author stuart.boston
*/
public class TmdbPeople extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbPeople(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Review Methods
*
* @author stuart.boston
*/
public class TmdbReviews extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbReviews(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the Search Methods
*
* @author stuart.boston
*/
public class TmdbSearch extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbSearch(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -0,0 +1,40 @@
/*
* 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.methods;
import com.omertron.themoviedbapi.tools.HttpTools;
/**
* Class to hold the TV Methods
*
* @author stuart.boston
*/
public class TmdbTV extends AbstractMethod {
/**
* Constructor
*
* @param apiKey
* @param httpTools
*/
public TmdbTV(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
}

@ -31,9 +31,6 @@ public class AbstractIdName extends AbstractJsonMapping {
private static final long serialVersionUID = 2L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("name")

@ -0,0 +1,60 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
@JsonRootName("certification")
public class Certification extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
// Properties
@JsonProperty("certification")
private String certification;
@JsonProperty("meaning")
private String meaning;
@JsonProperty("order")
private int order;
public String getCertification() {
return certification;
}
public void setCertification(String certification) {
this.certification = certification;
}
public String getMeaning() {
return meaning;
}
public void setMeaning(String meaning) {
this.meaning = meaning;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
}

@ -0,0 +1,48 @@
/*
* 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;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ChangedMedia extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private String id;
@JsonProperty("adult")
private boolean adult;
public String getId() {
return id;
}
public boolean isAdult() {
return adult;
}
public void setId(String id) {
this.id = id;
}
public void setAdult(boolean adult) {
this.adult = adult;
}
}

@ -0,0 +1,183 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
/**
* @author stuart.boston
*/
public class Configuration extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("base_url")
private String baseUrl;
@JsonProperty("secure_base_url")
private String secureBaseUrl;
@JsonProperty("poster_sizes")
private List<String> posterSizes;
@JsonProperty("backdrop_sizes")
private List<String> backdropSizes;
@JsonProperty("profile_sizes")
private List<String> profileSizes;
@JsonProperty("logo_sizes")
private List<String> logoSizes;
@JsonProperty("still_sizes")
private List<String> stillSizes;
public List<String> getBackdropSizes() {
return backdropSizes;
}
public String getBaseUrl() {
return baseUrl;
}
public List<String> getPosterSizes() {
return posterSizes;
}
public List<String> getProfileSizes() {
return profileSizes;
}
public List<String> getLogoSizes() {
return logoSizes;
}
public String getSecureBaseUrl() {
return secureBaseUrl;
}
public List<String> getStillSizes() {
return stillSizes;
}
public void setBackdropSizes(List<String> backdropSizes) {
this.backdropSizes = backdropSizes;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
public void setPosterSizes(List<String> posterSizes) {
this.posterSizes = posterSizes;
}
public void setProfileSizes(List<String> profileSizes) {
this.profileSizes = profileSizes;
}
public void setLogoSizes(List<String> logoSizes) {
this.logoSizes = logoSizes;
}
public void setSecureBaseUrl(String secureBaseUrl) {
this.secureBaseUrl = secureBaseUrl;
}
public void setStillSizes(List<String> stillSizes) {
this.stillSizes = stillSizes;
}
/**
* Copy the data from the passed object to this one
*
* @param config
*/
public void clone(Configuration config) {
backdropSizes = config.getBackdropSizes();
baseUrl = config.getBaseUrl();
posterSizes = config.getPosterSizes();
profileSizes = config.getProfileSizes();
logoSizes = config.getLogoSizes();
}
/**
* Check that the poster size is valid
*
* @param posterSize
* @return
*/
public boolean isValidPosterSize(String posterSize) {
if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) {
return false;
}
return posterSizes.contains(posterSize);
}
/**
* Check that the backdrop size is valid
*
* @param backdropSize
* @return
*/
public boolean isValidBackdropSize(String backdropSize) {
if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) {
return false;
}
return backdropSizes.contains(backdropSize);
}
/**
* Check that the profile size is valid
*
* @param profileSize
* @return
*/
public boolean isValidProfileSize(String profileSize) {
if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) {
return false;
}
return profileSizes.contains(profileSize);
}
/**
* Check that the logo size is valid
*
* @param logoSize
* @return
*/
public boolean isValidLogoSize(String logoSize) {
if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) {
return false;
}
return logoSizes.contains(logoSize);
}
/**
* Check to see if the size is valid for any of the images types
*
* @param sizeToCheck
* @return
*/
public boolean isValidSize(String sizeToCheck) {
return isValidPosterSize(sizeToCheck)
|| isValidBackdropSize(sizeToCheck)
|| isValidProfileSize(sizeToCheck)
|| isValidLogoSize(sizeToCheck);
}
}

@ -26,6 +26,7 @@ public enum MethodBase {
ACCOUNT("account"),
AUTH("authentication"),
CERTIFICATION("certification"),
COLLECTION("collection"),
COMPANY("company"),
CONFIGURATION("configuration"),
@ -36,7 +37,8 @@ public enum MethodBase {
LIST("list"),
MOVIE("movie"),
PERSON("person"),
SEARCH("search");
SEARCH("search"),
TV("tv");
private final String value;

@ -42,7 +42,9 @@ public enum MethodSub {
LISTS("lists"),
MOVIE("movie"),
MOVIES("movies"),
MOVIE_WATCHLIST("movie_watchlist"),
WATCHLIST("watchlist"),
WATCHLIST_MOVIES("watchlist/movies"),
WATCHLIST_TV("watchlist/tv"),
NOW_PLAYING("now-playing"),
PERSON("person"),
POPULAR("popular"),
@ -59,7 +61,9 @@ public enum MethodSub {
UPCOMING("upcoming"),
VIDEOS("videos"),
ADD_ITEM("add_item"),
REMOVE_ITEM("remove_item");
REMOVE_ITEM("remove_item"),
MOVIE_LIST("movie/list"),
TV_LIST("tv/list");
private final String value;

@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.TmdbConfiguration;
import com.omertron.themoviedbapi.model.Configuration;
import java.util.Collections;
import java.util.List;
@ -31,15 +31,15 @@ import java.util.List;
public class WrapperConfig extends AbstractWrapper {
@JsonProperty("images")
private TmdbConfiguration tmdbConfiguration;
private Configuration tmdbConfiguration;
@JsonProperty("change_keys")
private List<String> changeKeys = Collections.emptyList();
public TmdbConfiguration getTmdbConfiguration() {
public Configuration getTmdbConfiguration() {
return tmdbConfiguration;
}
public void setTmdbConfiguration(TmdbConfiguration tmdbConfiguration) {
public void setTmdbConfiguration(Configuration tmdbConfiguration) {
this.tmdbConfiguration = tmdbConfiguration;
}

@ -0,0 +1,39 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.ChangedMedia;
public class WrapperMediaChanges extends AbstractWrapperAll {
@JsonProperty("results")
private List<ChangedMedia> results;
public List<ChangedMedia> getResults() {
return results;
}
public void setResults(List<ChangedMedia> results) {
this.results = results;
}
}

@ -151,19 +151,19 @@ public class TestAccounts {
}
// make sure it's empty (because it's just a test account
Assert.assertTrue(tmdb.getWatchList(tokenSession.getSessionId(), account.getId()).isEmpty());
Assert.assertTrue(tmdb.getWatchListMovie(tokenSession.getSessionId(), account.getId()).isEmpty());
// add a movie
tmdb.addToWatchList(tokenSession.getSessionId(), account.getId(), 550);
List<MovieDb> watchList = tmdb.getWatchList(tokenSession.getSessionId(), account.getId());
List<MovieDb> watchList = tmdb.getWatchListMovie(tokenSession.getSessionId(), account.getId());
assertNotNull("Empty watch list returned", watchList);
assertEquals("Watchlist wrong size", 1, watchList.size());
// clean up again
tmdb.removeFromWatchList(tokenSession.getSessionId(), account.getId(), 550);
Assert.assertTrue(tmdb.getWatchList(tokenSession.getSessionId(), account.getId()).isEmpty());
Assert.assertTrue(tmdb.getWatchListMovie(tokenSession.getSessionId(), account.getId()).isEmpty());
}
@Test

@ -22,7 +22,7 @@ package com.omertron.themoviedbapi;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ChangedItem;
import com.omertron.themoviedbapi.model.ChangedMovie;
import com.omertron.themoviedbapi.model.ChangedMedia;
import com.omertron.themoviedbapi.model.Collection;
import com.omertron.themoviedbapi.model.CollectionInfo;
import com.omertron.themoviedbapi.model.Company;
@ -38,7 +38,7 @@ import com.omertron.themoviedbapi.model.Person;
import com.omertron.themoviedbapi.model.PersonCredit;
import com.omertron.themoviedbapi.model.ReleaseInfo;
import com.omertron.themoviedbapi.model.Reviews;
import com.omertron.themoviedbapi.model.TmdbConfiguration;
import com.omertron.themoviedbapi.model.Configuration;
import com.omertron.themoviedbapi.model.TokenAuthorisation;
import com.omertron.themoviedbapi.model.TokenSession;
import com.omertron.themoviedbapi.model.Translation;
@ -138,7 +138,7 @@ public class TheMovieDbApiTest {
public void testConfiguration() {
LOG.info("Test Configuration");
TmdbConfiguration tmdbConfig = tmdb.getConfiguration();
Configuration tmdbConfig = tmdb.getConfiguration();
assertNotNull("Configuration failed", tmdbConfig);
assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl()));
assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0);
@ -750,7 +750,7 @@ public class TheMovieDbApiTest {
int page = 0;
String startDate = "";
String endDate = "";
TmdbResultsList<ChangedMovie> result = tmdb.getMovieChangesList(page, startDate, endDate);
TmdbResultsList<ChangedMedia> result = tmdb.getMovieChangesList(page, startDate, endDate);
assertFalse("No movie changes.", result.getResults().isEmpty());
}

Loading…
Cancel
Save