This commit is contained in:
Stuart Boston
2015-03-04 19:54:48 +00:00
parent 286b748a34
commit 27dcc56492
6 changed files with 667 additions and 9 deletions
@@ -103,6 +103,12 @@ public class TmdbConfiguration extends AbstractMethod {
}
}
/**
* Get the list of supported timezones for the API methods that support them
*
* @return
* @throws MovieDbException
*/
public Map<String, List<String>> getTimezones() throws MovieDbException {
URL url = new ApiUrl(apiKey, MethodBase.TIMEZONES).subMethod(MethodSub.LIST).buildUrl();
String webpage = httpTools.getRequest(url);
@@ -384,7 +384,7 @@ public class TmdbMovies extends AbstractMethod {
parameters.add(Param.PAGE, page);
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.SIMILAR_MOVIES).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).subMethod(MethodSub.SIMILAR).buildUrl(parameters);
WrapperGenericList<MovieDb> wrapper = processWrapper(getTypeReference(MovieDb.class), url, "similar movies");
return wrapper.getTmdbResultsList();
}
@@ -19,7 +19,14 @@
*/
package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
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.net.URL;
/**
* Class to hold the TV Methods
@@ -37,4 +44,327 @@ public class TmdbTV extends AbstractMethod {
public TmdbTV(String apiKey, HttpTools httpTools) {
super(apiKey, httpTools);
}
/**
* Get the primary information about a TV series by id.
*
* @param tvID
* @param language
* @param appendToResponse
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVInfo(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).buildUrl(parameters);
return null;
}
/**
* 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.
*
* @param tvID
* @param sessionID
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVAccountState(int tvID, String sessionID) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SESSION, sessionID);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.ACCOUNT_STATES).buildUrl(parameters);
return null;
}
/**
* Get the alternative titles for a specific show ID.
*
* @param tvID
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVAlternativeTitles(int tvID) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.ALT_TITLES).buildUrl(parameters);
return null;
}
/**
* Get the changes for a specific TV show id.
*
* @param tvID
* @param startDate
* @param endDate
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVChanges(int tvID, String startDate, String endDate) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.START_DATE, startDate);
parameters.add(Param.END_DATE, endDate);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.CHANGES).buildUrl(parameters);
return null;
}
/**
* Get the content ratings for a specific TV show id.
*
* @param tvID
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String 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;
}
/**
* Get the cast & crew information about a TV series.
*
* @param tvID
* @param language
* @param appendToResponse
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String 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;
}
/**
* Get the external ids that we have stored for a TV series.
*
* @param tvID
* @param language
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String 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;
}
/**
* Get the images (posters and backdrops) for a TV series.
*
* @param tvID
* @param language
* @param includeImageLanguage
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String 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;
}
/**
* Get the plot keywords for a specific TV show id.
*
* @param tvID
* @param appendToResponse
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String 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;
}
/**
* This method lets users rate a TV show.
*
* A valid session id or guest session id is required.
*
* @param tvID
* @param rating
* @param sessionID
* @param guestSessionID
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String postTVRating(int tvID, int rating, String sessionID, String guestSessionID) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SESSION, sessionID);
parameters.add(Param.GUEST_SESSION_ID, guestSessionID);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.RATING).buildUrl(parameters);
return null;
}
/**
* Get the similar TV shows for a specific tv id.
*
* @param tvID
* @param page
* @param language
* @param appendToResponse
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String 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);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.SIMILAR).buildUrl(parameters);
return null;
}
/**
* Get the list of translations that exist for a TV series. These translations cascade down to the episode level.
*
* @param tvID
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVTranslations(int tvID) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.TRANSLATIONS).buildUrl(parameters);
return null;
}
/**
* Get the videos that have been added to a TV series (trailers, opening credits, etc...)
*
* @param tvID
* @param language
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVVideos(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.VIDEOS).buildUrl(parameters);
return null;
}
/**
* Get the latest TV show id.
*
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVLatest() throws MovieDbException {
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.LATEST).buildUrl();
return null;
}
/**
* 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.
*
* @param page
* @param language
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVOnTheAir(Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.ON_THE_AIR).buildUrl(parameters);
return null;
}
/**
* Get the list of TV shows that air today.
*
* Without a specified timezone, this query defaults to EST
*
* @param page
* @param language
* @param timezone
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVAiringToday(Integer page, String language, String timezone) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.TIMEZONE, timezone);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.AIRING_TODAY).buildUrl(parameters);
return null;
}
/**
* 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.
*
* @param page
* @param language
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVTopRated(Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.TOP_RATED).buildUrl(parameters);
return null;
}
/**
* Get the list of popular TV shows. This list refreshes every day.
*
* @param page
* @param language
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVPopular(Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.POPULAR).buildUrl(parameters);
return null;
}
}
@@ -26,11 +26,13 @@ public enum MethodSub {
ACCOUNT_STATES("account_states"),
ADD_ITEM("add_item"),
AIRING_TODAY("airing_today"),
ALT_TITLES("alternative_titles"),
CASTS("casts"),
CHANGES("changes"),
CLEAR("clear"),
COLLECTION("collection"),
CONTENT_RATINGS("content_ratings"),
COMBINED_CREDITS("combined_credits"),
COMPANY("company"),
CREDITS("credits"),
@@ -52,6 +54,7 @@ public enum MethodSub {
MOVIE_LIST("movie/list"),
MULTI("multi"),
NOW_PLAYING("now-playing"),
ON_THE_AIR("on_the_air"),
PERSON("person"),
POPULAR("popular"),
RATED_MOVIES("rated/movies"),
@@ -62,7 +65,7 @@ public enum MethodSub {
REMOVE_ITEM("remove_item"),
REVIEWS("reviews"),
SESSION_NEW("session/new"),
SIMILAR_MOVIES("similar_movies"),
SIMILAR("similar"),
TAGGED_IMAGES("tagged_images"),
TOKEN_NEW("token/new"),
TOKEN_VALIDATE("token/validate_with_login"),
@@ -50,6 +50,7 @@ public enum Param {
SEARCH_TYPE("search_type="),
SESSION("session_id="),
START_DATE("start_date="),
TIMEZONE("timezone="),
TOKEN("request_token="),
USERNAME("username="),
VALUE("value="),
@@ -21,9 +21,12 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import org.junit.AfterClass;
import com.omertron.themoviedbapi.TestID;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.fail;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Test for the TV Method
@@ -33,8 +36,7 @@ import org.junit.BeforeClass;
public class TmdbTVTest extends AbstractTests {
private static TmdbTV instance;
// IDs
private static final int ID_BIG_BANG_THEORY = 1418;
private static final List<TestID> TV_IDS = new ArrayList<TestID>();
public TmdbTVTest() {
}
@@ -43,14 +45,330 @@ public class TmdbTVTest extends AbstractTests {
public static void setUpClass() throws MovieDbException {
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));
}
@AfterClass
public static void tearDownClass() {
/**
* Test of getTVInfo method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVInfo() throws MovieDbException {
LOG.info("getTVInfo");
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : TV_IDS) {
String result = instance.getTVInfo(test.getTmdb(), language, appendToResponse);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
//@Test
public void testGetTv() throws MovieDbException {
/**
* Test of getTVAccountState method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVAccountState() throws MovieDbException {
LOG.info("getTVAccountState");
for (TestID test : TV_IDS) {
String result = instance.getTVAccountState(test.getTmdb(), getSessionId());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVAlternativeTitles method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVAlternativeTitles() throws MovieDbException {
LOG.info("getTVAlternativeTitles");
for (TestID test : TV_IDS) {
String result = instance.getTVAlternativeTitles(test.getTmdb());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVChanges method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVChanges() throws MovieDbException {
LOG.info("getTVChanges");
String startDate = "";
String endDate = "";
for (TestID test : TV_IDS) {
String result = instance.getTVChanges(test.getTmdb(), startDate, endDate);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVContentRatings method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVContentRatings() throws MovieDbException {
LOG.info("getTVContentRatings");
for (TestID test : TV_IDS) {
String result = instance.getTVContentRatings(test.getTmdb());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVCredits method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@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);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVExternalIDs method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@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);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVImages method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVImages() throws MovieDbException {
LOG.info("getTVImages");
String language = LANGUAGE_DEFAULT;
String[] includeImageLanguage = null;
for (TestID test : TV_IDS) {
String result = instance.getTVImages(test.getTmdb(), language, includeImageLanguage);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVKeywords method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVKeywords() throws MovieDbException {
LOG.info("getTVKeywords");
String[] appendToResponse = null;
for (TestID test : TV_IDS) {
String result = instance.getTVKeywords(test.getTmdb(), appendToResponse);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of postTVRating method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@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);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVSimilar method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVSimilar() throws MovieDbException {
LOG.info("getTVSimilar");
Integer page = null;
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : TV_IDS) {
String result = instance.getTVSimilar(test.getTmdb(), page, language, appendToResponse);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVTranslations method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVTranslations() throws MovieDbException {
LOG.info("getTVTranslations");
for (TestID test : TV_IDS) {
String result = instance.getTVTranslations(test.getTmdb());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVVideos method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVVideos() throws MovieDbException {
LOG.info("getTVVideos");
String language = LANGUAGE_DEFAULT;
for (TestID test : TV_IDS) {
String result = instance.getTVVideos(test.getTmdb(), language);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVLatest method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVLatest() throws MovieDbException {
LOG.info("getTVLatest");
for (TestID test : TV_IDS) {
String result = instance.getTVLatest();
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVOnTheAir method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVOnTheAir() throws MovieDbException {
LOG.info("getTVOnTheAir");
Integer page = null;
String language = LANGUAGE_DEFAULT;
for (TestID test : TV_IDS) {
String result = instance.getTVOnTheAir(page, language);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVAiringToday method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVAiringToday() throws MovieDbException {
LOG.info("getTVAiringToday");
Integer page = null;
String language = LANGUAGE_DEFAULT;
String timezone = "";
for (TestID test : TV_IDS) {
String result = instance.getTVAiringToday(page, language, timezone);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVTopRated method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVTopRated() throws MovieDbException {
LOG.info("getTVTopRated");
Integer page = null;
String language = LANGUAGE_DEFAULT;
for (TestID test : TV_IDS) {
String result = instance.getTVTopRated(page, language);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getTVPopular method, of class TmdbTV.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetTVPopular() throws MovieDbException {
LOG.info("getTVPopular");
Integer page = null;
String language = LANGUAGE_DEFAULT;
for (TestID test : TV_IDS) {
String result = instance.getTVPopular(page, language);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}