Remove SubMethod(id, xxx)

master
Stuart Boston 11 years ago
parent 110b77d09a
commit c88fde759c

@ -79,6 +79,17 @@ public class TmdbAccount extends AbstractMethod {
}
}
/*
/account/{id}/lists Get the lists that you have created and marked as a favorite.
/account/{id}/favorite/movies Get the list of favorite movies for an account.
/account/{id}/favorite/tv Get the list of favorite TV series for an account
/account/{id}/favorite Add or remove a movie to an accounts favorite list
/account/{id}/rated/movies Get the list of rated movies (and associated rating) for an account
/account/{id}/rated/tv Get the list of rated TV shows (and associated rating) for an account.
/account/{id}/watchlist/movies Get the list of movies on an accounts watchlist
/account/{id}/watchlist/tv Get the list of TV series on an accounts watchlist
/account/{id}/watchlist Add or remove a movie to an accounts watch list
*/
/**
* Get all lists of a given user
*
@ -90,8 +101,9 @@ public class TmdbAccount extends AbstractMethod {
public List<MovieDbList> getUserLists(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.LISTS).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.LISTS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
@ -112,8 +124,9 @@ public class TmdbAccount extends AbstractMethod {
public List<MovieDb> getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.FAVORITE_MOVIES).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.FAVORITE_MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
@ -134,10 +147,11 @@ public class TmdbAccount extends AbstractMethod {
public List getFavoriteTv(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId,MethodSub.FAVORITE_TV).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.FAVORITE_TV).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Not implemented yet");
}
@ -155,6 +169,7 @@ public class TmdbAccount extends AbstractMethod {
public StatusCode changeFavoriteStatus(String sessionId, int accountId, Integer mediaId, MediaType mediaType, boolean isFavorite) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
String jsonBody = new PostTools()
.add(PostBody.MEDIA_TYPE, mediaType.toString().toLowerCase())
@ -162,7 +177,7 @@ public class TmdbAccount extends AbstractMethod {
.add(PostBody.FAVORITE, isFavorite)
.build();
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.FAVORITE).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.FAVORITE).buildUrl(parameters);
String webpage = httpTools.postRequest(url, jsonBody);
try {
@ -183,8 +198,9 @@ public class TmdbAccount extends AbstractMethod {
public List<MovieDb> getRatedMovies(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.RATED_MOVIES).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.RATED_MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
@ -217,8 +233,9 @@ public class TmdbAccount extends AbstractMethod {
public List<MovieDb> getWatchListMovie(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.WATCHLIST_MOVIES).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.WATCHLIST_MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
@ -239,8 +256,9 @@ public class TmdbAccount extends AbstractMethod {
public List getWatchListTV(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.WATCHLIST_TV).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.WATCHLIST_TV).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
@ -264,6 +282,7 @@ public class TmdbAccount extends AbstractMethod {
public StatusCode modifyWatchList(String sessionId, int accountId, Integer movieId, MediaType mediaType, boolean addToWatchlist) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
String jsonBody = new PostTools()
.add(PostBody.MEDIA_TYPE, mediaType.toString().toLowerCase())
@ -271,7 +290,7 @@ public class TmdbAccount extends AbstractMethod {
.add(PostBody.WATCHLIST, addToWatchlist)
.build();
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(accountId, MethodSub.WATCHLIST).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.WATCHLIST).buildUrl(parameters);
String webpage = httpTools.postRequest(url, jsonBody);
try {

@ -113,9 +113,10 @@ public class TmdbLists extends AbstractMethod {
*/
public boolean isMovieOnList(String listId, Integer movieId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
parameters.add(Param.ID, listId);
parameters.add(Param.MOVIE_ID, movieId);
URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(listId, MethodSub.ITEM_STATUS).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(MethodSub.ITEM_STATUS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
@ -138,12 +139,13 @@ public class TmdbLists extends AbstractMethod {
public StatusCode modifyMovieList(String sessionId, String listId, Integer movieId, MethodSub operation) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, listId);
String jsonBody = new PostTools()
.add(PostBody.MEDIA_ID, movieId)
.build();
URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(listId, operation).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(operation).buildUrl(parameters);
String webpage = httpTools.postRequest(url, jsonBody);
try {

@ -22,14 +22,14 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList;
import com.omertron.themoviedbapi.model.person.Person;
import com.omertron.themoviedbapi.model.ReleaseInfo;
import com.omertron.themoviedbapi.model.StatusCode;
import com.omertron.themoviedbapi.model.Translation;
import com.omertron.themoviedbapi.model.Video;
import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.person.Person;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
@ -77,7 +77,8 @@ 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
@ -109,7 +110,8 @@ 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
@ -138,7 +140,8 @@ 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
@ -193,7 +196,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method should be used when youre wanting to retrieve all of the images for a particular movie.
* This method should be used when youre wanting to retrieve all of the
* images for a particular movie.
*
* @param movieId
* @param language
@ -221,7 +225,8 @@ 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.
*
@ -249,7 +254,8 @@ 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
@ -277,7 +283,8 @@ 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.
*
@ -307,7 +314,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve a list of the available translations for a specific movie.
* This method is used to retrieve a list of the available translations for
* a specific movie.
*
* @param movieId
* @param appendToResponse
@ -333,9 +341,11 @@ 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
*
@ -447,7 +457,8 @@ 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.
*
* TODO: Implement more than 20 movies
*
@ -505,7 +516,8 @@ 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.
*
@ -552,8 +564,9 @@ public class TmdbMovies extends AbstractMethod {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, movieId);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(movieId, MethodSub.RATING).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.RATING).buildUrl(parameters);
String jsonBody = new PostTools()
.add(PostBody.VALUE, rating)

@ -0,0 +1,157 @@
Account
/account Get the basic information for an account. You will need to have a valid session id.
/account/{id}/lists Get the lists that you have created and marked as a favorite.
/account/{id}/favorite/movies Get the list of favorite movies for an account.
/account/{id}/favorite/tv Get the list of favorite TV series for an account
/account/{id}/favorite Add or remove a movie to an accounts favorite list
/account/{id}/rated/movies Get the list of rated movies (and associated rating) for an account
/account/{id}/rated/tv Get the list of rated TV shows (and associated rating) for an account.
/account/{id}/watchlist/movies Get the list of movies on an accounts watchlist
/account/{id}/watchlist/tv Get the list of TV series on an accounts watchlist
/account/{id}/watchlist Add or remove a movie to an accounts watch list
Authentication
/authentication/token/new This method is used to generate a valid request token for user based authentication
/authentication/token/validate_with_login Once you have a valid request token you can use this method to authenticate a user with a TMDb username and password.
/authentication/session/new 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.
/authentication/guest_session/new 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.
Certifications
/certification/movie/list Get the list of supported certifications for movies.
/certification/tv/list Get the list of supported certifications for tv shows
Changes
/movie/changes Get a list of movie ids that have been edited.
/person/changes Get a list of people ids that have been edited.
/tv/changes Get a list of TV show ids that have been edited
Collections
/collection/{id} Get the basic collection information for a specific collection id.
/collection/{id}/images Get all of the images for a particular collection by collection id.
Companies
/company/{id} This method is used to retrieve all of the basic information about a company
/company/{id}/movies Get the list of movies associated with a particular company.
Credits
/credit/{credit_id} Get the detailed information about a particular credit record.
Discover
/discover/movie Discover movies by different types of data like average rating, number of votes, genres and certifications.
/discover/tv Discover TV shows by different types of data like average rating, number of votes, genres, the network they aired on and air dates.
Find
/find/{id} The find method makes it easy to search for objects in our database by an external id.
Genres
/genre/movie/list Get the list of movie genres.
/genre/tv/list Get the list of TV genres.
/genre/{id}/movies Get the list of movies for a particular genre by id.
Guest Sessions
/guest_session/{guest_session_id}/rated_movies Get a list of rated movies for a specific guest session id.
Jobs
/job/list Get a list of valid jobs.
Keyword
/keyword/{id} Get the basic information for a specific keyword id
/keyword/{id}/movies Get the list of movies for a particular keyword by id
Lists
/list/{id} Get a list by id.
/list/{id}/item_status Check to see if a movie ID is already added to a list.
/list This method lets users create a new list. A valid session id is required.
/list/{id}/add_item This method lets users add new movies to a list that they created. A valid session id is required.
/list/{id}/remove_item This method lets users delete movies from a list that they created. A valid session id is required.
/list/{id}/clear Clear all of the items within a list. This is a irreversible action and should be treated with caution. A valid session id is required.
Movies
/movie/{id} Get the basic movie information for a specific movie id.
/movie/{id}/account_states This method lets a TMDb user account get the status of whether or not the movie has been rated or added to their favourite or movie watch list
/movie/{id}/alternative_titles Get the alternative titles for a specific movie id.
/movie/{id}/credits Get the cast and crew information for a specific movie id.
/movie/{id}/images Get the images (posters and backdrops) for a specific movie id.
/movie/{id}/keywords Get the plot keywords for a specific movie id.
/movie/{id}/releases Get the release date and certification information by country for a specific movie id.
/movie/{id}/videos Get the videos (trailers, teasers, clips, etc...) for a specific movie id.
/movie/{id}/translations Get the translations for a specific movie id.
/movie/{id}/similar Get the similar movies for a specific movie id.
/movie/{id}/reviews Get the reviews for a particular movie id.
/movie/{id}/lists Get the lists that the movie belongs to.
/movie/{id}/changes Get the changes for a specific movie id.
/movie/{id}/rating This method lets users rate a movie. A valid session id or guest session id is required.
/movie/latest Get the latest movie id.
/movie/upcoming Get the list of upcoming movies by release date. This list refreshes every day.
/movie/now_playing Get the list of movies playing that have been, or are being released this week. This list refreshes every day.
/movie/popular Get the list of popular movies on The Movie Database. This list refreshes every day.
/movie/top_rated Get the list of top rated movies. By default, this list will only include movies that have 10 or more votes. This list refreshes every day.
Networks
/network/{id} This method is used to retrieve the basic information about a TV network.
People
/person/{id} Get the general person information for a specific id
/person/{id}/movie_credits Get the movie credits for a specific person id.
/person/{id}/tv_credits Get the TV credits for a specific person id.
/person/{id}/combined_credits Get the combined (movie and TV) credits for a specific person id.
/person/{id}/external_ids Get the external ids for a specific person id.
/person/{id}/images Get the images for a specific person id.
/person/{id}/tagged_images Get the images that have been tagged with a specific person id
/person/{id}/changes Get the changes for a specific person id.
/person/popular Get the list of popular people on The Movie Database. This list refreshes every day.
/person/latest Get the latest person id.
Reviews
/review/{id} Get the full details of a review by ID.
Search
/search/company Search for companies by name.
/search/collection Search for collections by name.
/search/keyword Search for keywords by name.
/search/list Search for lists by name and description.
/search/movie Search for movies by title.
/search/multi Search the movie, tv show and person collections with a single query.
/search/person Search for people by name.
/search/tv Search for TV shows by title.
Timezones
/timezones/list Get the list of supported timezones for the API methods that support them.
TV
/tv/{id} Get the primary information about a TV series by id.
/tv/{id}/account_states 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.
/tv/{id}/alternative_titles Get the alternative titles for a specific show ID.
/tv/{id}/changes Get the changes for a specific TV show id.
/tv/{id}/content_ratings Get the content ratings for a specific TV show id.
/tv/{id}/credits Get the cast & crew information about a TV series.
/tv/{id}/external_ids Get the external ids that we have stored for a TV series.
/tv/{id}/images Get the images (posters and backdrops) for a TV series.
/tv/{id}/keywords Get the plot keywords for a specific TV show id.
/tv/{id}/rating This method lets users rate a TV show. A valid session id or guest session id is required.
/tv/{id}/similar Get the similar TV shows for a specific tv id.
/tv/{id}/translations Get the list of translations that exist for a TV series. These translations cascade down to the episode level.
/tv/{id}/videos Get the videos that have been added to a TV series (trailers, opening credits, etc...)
/tv/latest Get the latest TV show id.
/tv/on_the_air 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.
/tv/airing_today Get the list of TV shows that air today. Without a specified timezone, this query defaults to EST
/tv/top_rated Get the list of top rated TV shows. By default, this list will only include TV shows that have 2 or more votes. This list refreshes every day.
/tv/popular Get the list of popular TV shows. This list refreshes every day.
TV Seasons
/tv/{id}/season/{season_number} Get the primary information about a TV season by its season number.
/tv/season/{id}/changes Look up a TV season's changes by season ID.
/tv/{id}/season/{season_number}/credits Get the cast & crew credits for a TV season by season number.
/tv/{id}/season/{season_number}/external_ids Get the external ids that we have stored for a TV season by season number.
/tv/{id}/season/{season_number}/images Get the images (posters) that we have stored for a TV season by season number.
/tv/{id}/season/{season_number}/videos Get the videos that have been added to a TV season (trailers, teasers, etc...)
TV Episodes
/tv/{id}/season/{season_number}/episode/{episode_number} Get the primary information about a TV episode by combination of a season and episode number.
/tv/episode/{id}/changes Look up a TV episode's changes by episode ID
/tv/{id}/season/{season_number}/episode/{episode_number}/account_states This method lets users get the status of whether or not the TV episode has been rated. A valid session id is required.
/tv/{id}/season/{season_number}/episode/{episode_number}/credits Get the TV episode credits by combination of season and episode number.
/tv/{id}/season/{season_number}/episode/{episode_number}/external_ids Get the external ids for a TV episode by comabination of a season and episode number.
/tv/{id}/season/{season_number}/episode/{episode_number}/images Get the images (episode stills) for a TV episode by combination of a season and episode number.
/tv/{id}/season/{season_number}/episode/{episode_number}/rating This method lets users rate a TV episode. A valid session id or guest session id is required.
/tv/{id}/season/{season_number}/episode/{episode_number}/videos Get the videos that have been added to a TV episode (teasers, clips, etc...)

@ -70,32 +70,6 @@ public class ApiUrl {
return this;
}
/**
* Add a sub-method that has an ID at the start
*
* @param someId
* @param submethod
* @return
*/
public ApiUrl setSubMethod(int someId, MethodSub submethod) {
return setSubMethod(String.valueOf(someId), submethod);
}
/**
* Add a sub-method that has an ID at the start
*
* @param someId
* @param submethod
* @return
*/
public ApiUrl setSubMethod(String someId, MethodSub submethod) {
StringBuilder sm = new StringBuilder(someId);
sm.append("/");
sm.append(submethod.getValue());
this.submethod = sm.toString();
return this;
}
/**
* Build the URL with the default parameters
*

@ -38,6 +38,7 @@ public enum Param {
ID("id="),
INCLUDE_ALL_MOVIES("include_all_movies="),
LANGUAGE("language="),
MOVIE_ID("movie_id="),
MOVIE_WATCHLIST("movie_watchlist="),
PAGE("page="),
PASSWORD("password="),

Loading…
Cancel
Save