Updated TV

This commit is contained in:
Stuart Boston
2015-03-04 21:55:57 +00:00
parent 27dcc56492
commit c8e71db71f
8 changed files with 338 additions and 57 deletions
@@ -190,7 +190,7 @@ public class TmdbMovies extends AbstractMethod {
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie alternative titles", url, ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get alternative titles", url, ex);
}
}
@@ -20,13 +20,22 @@
package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
import static com.omertron.themoviedbapi.methods.AbstractMethod.MAPPER;
import com.omertron.themoviedbapi.model.media.MediaState;
import com.omertron.themoviedbapi.model.movie.AlternativeTitle;
import com.omertron.themoviedbapi.model.tv.TVInfo;
import com.omertron.themoviedbapi.results.TmdbResultsList;
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.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.wrapper.WrapperChanges;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;
/**
* Class to hold the TV Methods
@@ -54,14 +63,20 @@ public class TmdbTV extends AbstractMethod {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVInfo(int tvID, String language, String... appendToResponse) throws MovieDbException {
public TVInfo 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;
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, TVInfo.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV Info", url, ex);
}
}
/**
@@ -75,13 +90,19 @@ public class TmdbTV extends AbstractMethod {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVAccountState(int tvID, String sessionID) throws MovieDbException {
public MediaState 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;
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, MediaState.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get account state", url, ex);
}
}
/**
@@ -91,12 +112,20 @@ public class TmdbTV extends AbstractMethod {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVAlternativeTitles(int tvID) throws MovieDbException {
public TmdbResultsList<AlternativeTitle> 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;
String webpage = httpTools.getRequest(url);
try {
WrapperAlternativeTitles wrapper = MAPPER.readValue(webpage, WrapperAlternativeTitles.class);
TmdbResultsList<AlternativeTitle> results = new TmdbResultsList<AlternativeTitle>(wrapper.getTitles());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get alternative titles", url, ex);
}
}
/**
@@ -108,14 +137,20 @@ public class TmdbTV extends AbstractMethod {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public String getTVChanges(int tvID, String startDate, String endDate) throws MovieDbException {
public WrapperChanges 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;
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, WrapperChanges.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie changes", url, ex);
}
}
/**
@@ -47,8 +47,6 @@ public class Person extends PersonBasic {
private String placeOfBirth;
@JsonProperty("popularity")
private float popularity;
@JsonProperty("profile_path")
private String profilePath;
public boolean isAdult() {
return adult;
@@ -122,12 +120,4 @@ public class Person extends PersonBasic {
this.popularity = popularity;
}
public String getProfilePath() {
return profilePath;
}
public void setProfilePath(String profilePath) {
this.profilePath = profilePath;
}
}
@@ -19,6 +19,7 @@
*/
package com.omertron.themoviedbapi.model.person;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AbstractIdName;
/**
@@ -27,4 +28,14 @@ import com.omertron.themoviedbapi.model.AbstractIdName;
public class PersonBasic extends AbstractIdName {
private static final long serialVersionUID = 1L;
@JsonProperty("profile_path")
private String profilePath;
public String getProfilePath() {
return profilePath;
}
public void setProfilePath(String profilePath) {
this.profilePath = profilePath;
}
}
@@ -0,0 +1,196 @@
/*
* 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.tv;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Genre;
import com.omertron.themoviedbapi.model.movie.ProductionCompany;
import com.omertron.themoviedbapi.model.network.Network;
import com.omertron.themoviedbapi.model.person.PersonBasic;
import java.util.List;
/**
*
* @author Stuart
*/
public class TVInfo extends TVBasic {
@JsonProperty("created_by")
private List<PersonBasic> createdBy;
@JsonProperty("episode_run_time")
private List<Integer> episodeRunTime;
@JsonProperty("genres")
private List<Genre> genres;
@JsonProperty("homepage")
private String homepage;
@JsonProperty("in_production")
private boolean inProduction;
@JsonProperty("languages")
private List<String> languages;
@JsonProperty("last_air_date")
private String lastAirDate;
@JsonProperty("networks")
private List<Network> networks;
@JsonProperty("number_of_episodes")
private int numberOfEpisodes;
@JsonProperty("number_of_seasons")
private int numberOfSeasons;
@JsonProperty("original_language")
private String originalLanguage;
@JsonProperty("overview")
private String overview;
@JsonProperty("production_companies")
private List<ProductionCompany> productionCompanies;
@JsonProperty("seasons")
private List<TVSeasonBasic> seasons;
@JsonProperty("status")
private String status;
@JsonProperty("type")
private String type;
public List<PersonBasic> getCreatedBy() {
return createdBy;
}
public void setCreatedBy(List<PersonBasic> createdBy) {
this.createdBy = createdBy;
}
public List<Integer> getEpisodeRunTime() {
return episodeRunTime;
}
public void setEpisodeRunTime(List<Integer> episodeRunTime) {
this.episodeRunTime = episodeRunTime;
}
public List<Genre> getGenres() {
return genres;
}
public void setGenres(List<Genre> genres) {
this.genres = genres;
}
public String getHomepage() {
return homepage;
}
public void setHomepage(String homepage) {
this.homepage = homepage;
}
public boolean isInProduction() {
return inProduction;
}
public void setInProduction(boolean inProduction) {
this.inProduction = inProduction;
}
public List<String> getLanguages() {
return languages;
}
public void setLanguages(List<String> languages) {
this.languages = languages;
}
public String getLastAirDate() {
return lastAirDate;
}
public void setLastAirDate(String lastAirDate) {
this.lastAirDate = lastAirDate;
}
public List<Network> getNetworks() {
return networks;
}
public void setNetworks(List<Network> networks) {
this.networks = networks;
}
public int getNumberOfEpisodes() {
return numberOfEpisodes;
}
public void setNumberOfEpisodes(int numberOfEpisodes) {
this.numberOfEpisodes = numberOfEpisodes;
}
public int getNumberOfSeasons() {
return numberOfSeasons;
}
public void setNumberOfSeasons(int numberOfSeasons) {
this.numberOfSeasons = numberOfSeasons;
}
public String getOriginalLanguage() {
return originalLanguage;
}
public void setOriginalLanguage(String originalLanguage) {
this.originalLanguage = originalLanguage;
}
public String getOverview() {
return overview;
}
public void setOverview(String overview) {
this.overview = overview;
}
public List<ProductionCompany> getProductionCompanies() {
return productionCompanies;
}
public void setProductionCompanies(List<ProductionCompany> productionCompanies) {
this.productionCompanies = productionCompanies;
}
public List<TVSeasonBasic> getSeasons() {
return seasons;
}
public void setSeasons(List<TVSeasonBasic> seasons) {
this.seasons = seasons;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
@@ -29,12 +29,24 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*/
public class TVSeasonBasic extends AbstractJsonMapping {
@JsonProperty("id")
private int id = -1;
@JsonProperty("air_date")
private String airDate;
@JsonProperty("poster_path")
private String posterPath;
@JsonProperty("season_number")
private int seasonNumber;
@JsonProperty("episode_count")
private int episodeCount = -1;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAirDate() {
return airDate;
@@ -59,4 +71,13 @@ public class TVSeasonBasic extends AbstractJsonMapping {
public void setSeasonNumber(int seasonNumber) {
this.seasonNumber = seasonNumber;
}
public int getEpisodeCount() {
return episodeCount;
}
public void setEpisodeCount(int episodeCount) {
this.episodeCount = episodeCount;
}
}