People (partial)

master
Stuart Boston 11 years ago
parent 45b66ef0b1
commit 46a50703d7

@ -41,7 +41,7 @@ import com.omertron.themoviedbapi.methods.TmdbSearch;
import com.omertron.themoviedbapi.methods.TmdbTV;
import com.omertron.themoviedbapi.model2.account.Account;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model.Certification;
import com.omertron.themoviedbapi.model.change.ChangedMedia;
import com.omertron.themoviedbapi.model2.collection.Collection;
@ -57,7 +57,6 @@ import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model2.list.ListItem;
import com.omertron.themoviedbapi.model.MovieList;
import com.omertron.themoviedbapi.model.person.Person;
import com.omertron.themoviedbapi.model.person.PersonCredit;
import com.omertron.themoviedbapi.model.ReleaseInfo;
import com.omertron.themoviedbapi.model2.review.Review;
import com.omertron.themoviedbapi.model2.StatusCode;
@ -1155,79 +1154,10 @@ public class TheMovieDbApi {
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="People">
/**
* This method is used to retrieve all of the basic person information.
*
* It will return the single highest rated profile image.
*
* @param personId
* @param appendToResponse
* @return
* @throws MovieDbException
*/
public Person getPersonInfo(int personId, String... appendToResponse) throws MovieDbException {
return tmdbPeople.getPersonInfo(personId, appendToResponse);
}
/**
* This method is used to retrieve all of the cast & crew information for the person.
*
* It will return the single highest rated poster for each movie record.
*
* @param personId
* @param appendToResponse
* @return
* @throws MovieDbException
*/
public TmdbResultsList<PersonCredit> getPersonCredits(int personId, String... appendToResponse) throws MovieDbException {
return tmdbPeople.getPersonCredits(personId, appendToResponse);
}
null;
/**
* This method is used to retrieve all of the profile images for a person.
*
* @param personId
* @return
* @throws MovieDbException
*/
public TmdbResultsList<Artwork> getPersonImages(int personId) throws MovieDbException {
return tmdbPeople.getPersonImages(personId);
}
/**
* Get the list of popular people on The Movie Database.
*
* This list refreshes every day.
*
* @return
* @throws MovieDbException
*/
public TmdbResultsList<Person> getPersonPopular() throws MovieDbException {
return tmdbPeople.getPersonPopular(0);
}
/**
* Get the list of popular people on The Movie Database.
*
* This list refreshes every day.
*
* @param page
* @return
* @throws MovieDbException
*/
public TmdbResultsList<Person> getPersonPopular(int page) throws MovieDbException {
return tmdbPeople.getPersonPopular(page);
}
/**
* Get the latest person id.
*
* @return
* @throws MovieDbException
*/
public Person getPersonLatest() throws MovieDbException {
return tmdbPeople.getPersonLatest();
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Review">

@ -19,15 +19,46 @@
*/
package com.omertron.themoviedbapi.enumeration;
import org.apache.commons.lang3.StringUtils;
/**
* ArtworkType enum List of the artwork types that are available
*/
public enum ArtworkType {
// Poster artwork
/**
* Poster artwork
*/
POSTER,
// Fanart/backdrop
/**
* Fanart/backdrop
*/
BACKDROP,
// Person image
PROFILE
/**
* Person image
*/
PROFILE,
/**
* Still (Video image)
*/
STILL;
/**
* Convert a string into an Enum type
*
* @param artworkType
* @return
* @throws IllegalArgumentException If type is not recognised
*
*/
public static ArtworkType fromString(String artworkType) {
if (StringUtils.isNotBlank(artworkType)) {
try {
return ArtworkType.valueOf(artworkType.trim().toUpperCase());
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("ArtworkType " + artworkType + " does not exist.", ex);
}
}
throw new IllegalArgumentException("ArtworkType must not be null");
}
}

@ -0,0 +1,30 @@
/*
* 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;
/**
*
* @author Stuart
*/
public enum CreditType {
CAST,
CREW;
}

@ -19,6 +19,8 @@
*/
package com.omertron.themoviedbapi.enumeration;
import org.apache.commons.lang3.StringUtils;
/**
* Media type options
*
@ -33,5 +35,28 @@ public enum MediaType {
/**
* TV Show media type
*/
TV;
TV,
/**
* TV Episode media type
*/
EPISODE;
/**
* Convert a string into an Enum type
*
* @param mediaType
* @return
* @throws IllegalArgumentException If type is not recognised
*
*/
public static MediaType fromString(String mediaType) {
if (StringUtils.isNotBlank(mediaType)) {
try {
return MediaType.valueOf(mediaType.trim().toUpperCase());
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("MediaType " + mediaType + " does not exist.", ex);
}
}
throw new IllegalArgumentException("MediaType must not be null");
}
}

@ -53,7 +53,7 @@ public class AbstractMethod {
protected static final TypeReference<WrapperGenericList<TVBasic>> TR_TV_BASIC = getTypeReference(TVBasic.class);
protected static final TypeReference<WrapperGenericList<UserList>> TR_USER_LIST = getTypeReference(UserList.class);
protected static <T> TypeReference getTypeReference(T Class) {
private static <T> TypeReference getTypeReference(T Class) {
return new TypeReference<WrapperGenericList<T>>() {
};
}

@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model2.collection.CollectionInfo;
import com.omertron.themoviedbapi.results.TmdbResultsList;

@ -21,7 +21,7 @@ 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.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList;
import com.omertron.themoviedbapi.model.ReleaseInfo;

@ -19,12 +19,16 @@
*/
package com.omertron.themoviedbapi.methods;
import com.fasterxml.jackson.core.type.TypeReference;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import static com.omertron.themoviedbapi.methods.AbstractMethod.getTypeReference;
import com.omertron.themoviedbapi.model.person.Person;
import com.omertron.themoviedbapi.model.person.PersonCredit;
import com.omertron.themoviedbapi.model2.artwork.ArtworkMedia;
import com.omertron.themoviedbapi.model2.person.CreditMovieBasic;
import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
import com.omertron.themoviedbapi.model2.person.ExternalID;
import com.omertron.themoviedbapi.model2.person.Person;
import com.omertron.themoviedbapi.model2.person.PersonCredits;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
@ -88,17 +92,21 @@ public class TmdbPeople extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public TmdbResultsList<PersonCredit> getPersonMovieCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
public PersonCredits<CreditMovieBasic> getPersonMovieCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.MOVIE_CREDITS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
WrapperGenericList<PersonCredit> wrapper = processWrapper(getTypeReference(PersonCredit.class), url, "person movie credits");
TmdbResultsList<PersonCredit> results = new TmdbResultsList<PersonCredit>(wrapper.getResults());
results.copyWrapper(wrapper);
return results;
try {
return MAPPER.readValue(webpage, new TypeReference<PersonCredits<CreditMovieBasic>>() {
});
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex);
}
}
/**
@ -114,8 +122,21 @@ public class TmdbPeople extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public TmdbResultsList<Person> getPersonTVCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
return null;
public PersonCredits<CreditTVBasic> getPersonTVCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.TV_CREDITS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, new TypeReference<PersonCredits<CreditTVBasic>>() {
});
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex);
}
}
/**
@ -131,8 +152,21 @@ public class TmdbPeople extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public TmdbResultsList<Person> getPersonCombinedCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
return null;
public PersonCredits<CreditTVBasic> getPersonCombinedCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.COMBINED_CREDITS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, new TypeReference<PersonCredits<CreditTVBasic>>() {
});
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex);
}
}
/**
@ -142,8 +176,18 @@ public class TmdbPeople extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public TmdbResultsList<Person> getPersonExternalIds(int personId) throws MovieDbException {
return null;
public ExternalID getPersonExternalIds(int personId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.EXTERNAL_IDS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, ExternalID.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex);
}
}
/**
@ -179,9 +223,28 @@ public class TmdbPeople extends AbstractMethod {
* @param page
* @param language
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public TmdbResultsList<Person> getPersonTaggedImages(int personId, Integer page, String language) {
return null;
public TmdbResultsList<ArtworkMedia> getPersonTaggedImages(int personId, Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.TAGGED_IMAGES).buildUrl(parameters);
WrapperGenericList<ArtworkMedia> wrapper;
String webpage = httpTools.getRequest(url);
try {
TypeReference tr = new TypeReference<WrapperGenericList<ArtworkMedia>>() {
};
wrapper = MAPPER.readValue(webpage, tr);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get tagged images", url, ex);
}
TmdbResultsList<ArtworkMedia> results = new TmdbResultsList<ArtworkMedia>(wrapper.getResults());
results.copyWrapper(wrapper);
return results;
}
/**
@ -199,9 +262,10 @@ public class TmdbPeople extends AbstractMethod {
* @param startDate
* @param endDate
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public TmdbResultsList<Person> getPersonChanges(int persondId, String startDate, String endDate) {
return null;
public TmdbResultsList<Person> getPersonChanges(int persondId, String startDate, String endDate) throws MovieDbException {
throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Not done");
}
/**
@ -222,9 +286,10 @@ public class TmdbPeople extends AbstractMethod {
try {
WrapperPersonList wrapper = MAPPER.readValue(webpage, WrapperPersonList.class);
TmdbResultsList<Person> results = new TmdbResultsList<Person>(wrapper.getPersonList());
results.copyWrapper(wrapper);
return results;
// TmdbResultsList<Person> results = new TmdbResultsList<Person>(wrapper.getPersonList());
// results.copyWrapper(wrapper);
// return results;
return null;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get popular person", url, ex);
}
@ -246,5 +311,4 @@ public class TmdbPeople extends AbstractMethod {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get latest person", url, ex);
}
}
}

@ -19,6 +19,7 @@
*/
package com.omertron.themoviedbapi.methods;
import com.fasterxml.jackson.core.type.TypeReference;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.enumeration.SearchType;
import com.omertron.themoviedbapi.model2.collection.Collection;
@ -264,4 +265,8 @@ public class TmdbSearch extends AbstractMethod {
return results;
}
private static <T> TypeReference getTypeReference(T Class) {
return new TypeReference<WrapperGenericList<T>>() {
};
}
}

@ -94,7 +94,7 @@ 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}/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

@ -19,6 +19,7 @@
*/
package com.omertron.themoviedbapi.model;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model2.review.Review;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import com.omertron.themoviedbapi.model2.collection.Collection;

@ -34,15 +34,10 @@ public class Person extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Static fields for default cast information
*/
private static final String CAST_DEPARTMENT = "acting";
private static final String CAST_JOB = "actor";
private static final String DEFAULT_STRING = "";
/*
* Properties
*/
// Properties
@JsonProperty("id")
private int id = -1;
@JsonProperty("name")

@ -17,11 +17,12 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
package com.omertron.themoviedbapi.model2.artwork;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
@ -54,84 +55,89 @@ public class Artwork extends AbstractJsonMapping {
private String flag;
private ArtworkType artworkType = ArtworkType.POSTER;
public ArtworkType getArtworkType() {
return artworkType;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public float getAspectRatio() {
return aspectRatio;
}
public String getFilePath() {
return filePath;
public void setAspectRatio(float aspectRatio) {
this.aspectRatio = aspectRatio;
}
public int getHeight() {
return height;
public String getFilePath() {
return filePath;
}
public String getLanguage() {
return language;
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public int getWidth() {
return width;
public int getHeight() {
return height;
}
public float getVoteAverage() {
return voteAverage;
public void setHeight(int height) {
this.height = height;
}
public int getVoteCount() {
return voteCount;
public String getLanguage() {
return language;
}
public String getFlag() {
return flag;
public void setLanguage(String language) {
this.language = language;
}
public String getId() {
return id;
public int getWidth() {
return width;
}
public void setArtworkType(ArtworkType artworkType) {
this.artworkType = artworkType;
public void setWidth(int width) {
this.width = width;
}
public void setAspectRatio(float aspectRatio) {
this.aspectRatio = aspectRatio;
public float getVoteAverage() {
return voteAverage;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
public void setVoteAverage(float voteAverage) {
this.voteAverage = voteAverage;
}
public void setHeight(int height) {
this.height = height;
public int getVoteCount() {
return voteCount;
}
public void setLanguage(String language) {
this.language = language;
public void setVoteCount(int voteCount) {
this.voteCount = voteCount;
}
public void setWidth(int width) {
this.width = width;
public String getFlag() {
return flag;
}
public void setVoteAverage(float voteAverage) {
this.voteAverage = voteAverage;
public void setFlag(String flag) {
this.flag = flag;
}
public void setVoteCount(int voteCount) {
this.voteCount = voteCount;
public ArtworkType getArtworkType() {
return artworkType;
}
public void setFlag(String flag) {
this.flag = flag;
public void setArtworkType(ArtworkType artworkType) {
this.artworkType = artworkType;
}
public void setId(String id) {
this.id = id;
@JsonSetter("image_type")
public void setArtworkType(String artworkType){
this.artworkType=ArtworkType.fromString(artworkType);
}
@Override

@ -0,0 +1,74 @@
/*
* 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.model2.artwork;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.omertron.themoviedbapi.enumeration.MediaType;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.model2.tv.TVEpisodeBasic;
/**
*
* @author Stuart
*/
public class ArtworkMedia extends Artwork {
private MediaType mediaType;
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
property = "media_type",
defaultImpl = MediaBasic.class
)
@JsonSubTypes({
@JsonSubTypes.Type(value = MovieBasic.class, name = "movie"),
@JsonSubTypes.Type(value = TVBasic.class, name = "tv"),
@JsonSubTypes.Type(value = TVEpisodeBasic.class, name = "episode")
})
@JsonProperty("media")
private MediaBasic media;
public MediaType getMediaType() {
return mediaType;
}
public void setMediaType(MediaType mediaType) {
this.mediaType = mediaType;
}
@JsonSetter("media_type")
public void setMediaType(String mediaType) {
this.mediaType = MediaType.fromString(mediaType);
}
public MediaBasic getMedia() {
return media;
}
public void setMedia(MediaBasic media) {
this.media = media;
}
}

@ -0,0 +1,126 @@
/*
* 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.model2.person;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.omertron.themoviedbapi.enumeration.CreditType;
import com.omertron.themoviedbapi.enumeration.MediaType;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
/**
* @author stuart.boston
*/
public class CreditBasic extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
private CreditType creditType;
private MediaType mediaType;
@JsonProperty("credit_id")
private String creditId;
@JsonProperty("id")
private int id;
@JsonProperty("poster_path")
private String posterPath;
//cast
@JsonProperty("character")
private String character;
//crew
@JsonProperty("department")
private String department;
@JsonProperty("job")
private String job;
public CreditType getCreditType() {
return creditType;
}
public void setCreditType(CreditType creditType) {
this.creditType = creditType;
}
public MediaType getMediaType() {
return mediaType;
}
@JsonSetter("media_type")
public void setMediaType(String mediaType) {
this.mediaType = MediaType.fromString(mediaType);
}
public void setMediaType(MediaType mediaType) {
this.mediaType = mediaType;
}
public String getCreditId() {
return creditId;
}
public void setCreditId(String creditId) {
this.creditId = creditId;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPosterPath() {
return posterPath;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public String getCharacter() {
return character;
}
public void setCharacter(String character) {
this.character = character;
setCreditType(CreditType.CAST);
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
setCreditType(CreditType.CREW);
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
setCreditType(CreditType.CREW);
}
}

@ -0,0 +1,77 @@
/*
* 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.model2.person;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.enumeration.MediaType;
/**
* @author stuart.boston
*/
public class CreditMovieBasic extends CreditBasic {
private static final long serialVersionUID = 1L;
@JsonProperty("adult")
private boolean adult;
@JsonProperty("original_title")
private String originalTitle;
@JsonProperty("release_date")
private String releaseDate;
@JsonProperty("title")
private String title;
public CreditMovieBasic() {
setMediaType(MediaType.MOVIE);
}
public boolean isAdult() {
return adult;
}
public void setAdult(boolean adult) {
this.adult = adult;
}
public String getOriginalTitle() {
return originalTitle;
}
public void setOriginalTitle(String originalTitle) {
this.originalTitle = originalTitle;
}
public String getReleaseDate() {
return releaseDate;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}

@ -0,0 +1,77 @@
/*
* 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.model2.person;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.enumeration.MediaType;
/**
* @author stuart.boston
*/
public class CreditTVBasic extends CreditBasic {
private static final long serialVersionUID = 1L;
@JsonProperty("episode_count")
private int episodeCount;
@JsonProperty("first_air_date")
private String firstAirDate;
@JsonProperty("name")
private String name;
@JsonProperty("original_name")
private String originalName;
public CreditTVBasic() {
setMediaType(MediaType.TV);
}
public int getEpisodeCount() {
return episodeCount;
}
public void setEpisodeCount(int episodeCount) {
this.episodeCount = episodeCount;
}
public String getFirstAirDate() {
return firstAirDate;
}
public void setFirstAirDate(String firstAirDate) {
this.firstAirDate = firstAirDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOriginalName() {
return originalName;
}
public void setOriginalName(String originalName) {
this.originalName = originalName;
}
}

@ -0,0 +1,82 @@
/*
* 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.model2.person;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
/**
*
* @author Stuart
*/
public class ExternalID extends AbstractJsonMapping {
@JsonProperty("id")
private String id;
@JsonProperty("imdb_id")
private String imdbId;
@JsonProperty("freebase_mid")
private String freebaseMid;
@JsonProperty("freebase_id")
private String freebaseId;
@JsonProperty("tvrage_id")
private String tvrageId;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getImdbId() {
return imdbId;
}
public void setImdbId(String imdbId) {
this.imdbId = imdbId;
}
public String getFreebaseMid() {
return freebaseMid;
}
public void setFreebaseMid(String freebaseMid) {
this.freebaseMid = freebaseMid;
}
public String getFreebaseId() {
return freebaseId;
}
public void setFreebaseId(String freebaseId) {
this.freebaseId = freebaseId;
}
public String getTvrageId() {
return tvrageId;
}
public void setTvrageId(String tvrageId) {
this.tvrageId = tvrageId;
}
}

@ -0,0 +1,133 @@
/*
* 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.model2.person;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* @author stuart.boston
*/
public class Person extends PersonBasic {
private static final long serialVersionUID = 1L;
@JsonProperty("adult")
private boolean adult;
@JsonProperty("also_known_as")
private List<String> alsoKnownAs;
@JsonProperty("biography")
private String biography;
@JsonProperty("birthday")
private String birthday;
@JsonProperty("deathday")
private String deathday;
@JsonProperty("homepage")
private String homepage;
@JsonProperty("imdb_id")
private String imdbId;
@JsonProperty("place_of_birth")
private String placeOfBirth;
@JsonProperty("popularity")
private float popularity;
@JsonProperty("profile_path")
private String profilePath;
public boolean isAdult() {
return adult;
}
public void setAdult(boolean adult) {
this.adult = adult;
}
public List<String> getAlsoKnownAs() {
return alsoKnownAs;
}
public void setAlsoKnownAs(List<String> alsoKnownAs) {
this.alsoKnownAs = alsoKnownAs;
}
public String getBiography() {
return biography;
}
public void setBiography(String biography) {
this.biography = biography;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getDeathday() {
return deathday;
}
public void setDeathday(String deathday) {
this.deathday = deathday;
}
public String getHomepage() {
return homepage;
}
public void setHomepage(String homepage) {
this.homepage = homepage;
}
public String getImdbId() {
return imdbId;
}
public void setImdbId(String imdbId) {
this.imdbId = imdbId;
}
public String getPlaceOfBirth() {
return placeOfBirth;
}
public void setPlaceOfBirth(String placeOfBirth) {
this.placeOfBirth = placeOfBirth;
}
public float getPopularity() {
return popularity;
}
public void setPopularity(float popularity) {
this.popularity = popularity;
}
public String getProfilePath() {
return profilePath;
}
public void setProfilePath(String profilePath) {
this.profilePath = profilePath;
}
}

@ -0,0 +1,63 @@
/*
* 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.model2.person;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import java.util.List;
/**
* @author stuart.boston
*/
public class PersonCredits<T> extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private int id;
@JsonProperty("cast")
private List<T> cast;
@JsonProperty("crew")
private List<T> crew;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<T> getCast() {
return cast;
}
public void setCast(List<T> cast) {
this.cast = cast;
}
public List<T> getCrew() {
return crew;
}
public void setCrew(List<T> crew) {
this.crew = crew;
}
}

@ -19,15 +19,15 @@
*/
package com.omertron.themoviedbapi.model2.tv;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.MediaBasic;
/**
* TV Favorite information
*
* @author stuart.boston
*/
public class TVEpisodeBasic extends AbstractJsonMapping {
public class TVEpisodeBasic extends MediaBasic {
@JsonProperty("air_date")
private String airDate;
@ -41,6 +41,8 @@ public class TVEpisodeBasic extends AbstractJsonMapping {
private String overview;
@JsonProperty("still_path")
private String stillPath;
@JsonProperty("show_id")
private String showId;
public String getAirDate() {
return airDate;
@ -90,4 +92,12 @@ public class TVEpisodeBasic extends AbstractJsonMapping {
this.stillPath = stillPath;
}
public String getShowId() {
return showId;
}
public void setShowId(String showId) {
this.showId = showId;
}
}

@ -33,6 +33,7 @@ public enum MethodSub {
COMBINED_CREDITS("combined_credits"),
COMPANY("company"),
CREDITS("credits"),
EXTERNAL_IDS("external_ids"),
FAVORITE("favorite"),
FAVORITE_MOVIES("favorite/movies"),
FAVORITE_TV("favorite/tv"),
@ -61,6 +62,7 @@ public enum MethodSub {
REVIEWS("reviews"),
SESSION_NEW("session/new"),
SIMILAR_MOVIES("similar_movies"),
TAGGED_IMAGES("tagged_images"),
TOKEN_NEW("token/new"),
TOKEN_VALIDATE("token/validate_with_login"),
TOP_RATED("top-rated"),

@ -57,7 +57,9 @@ public class TmdbParameters {
* @param value The array value to use (will be converted into a comma separated list)
*/
public void add(final Param key, final String[] value) {
parameters.put(key, toList(value));
if (value != null && value.length > 0) {
parameters.put(key, toList(value));
}
}
/**

@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import java.io.Serializable;
import java.util.ArrayList;
@ -96,7 +96,7 @@ public class WrapperImages extends AbstractWrapperAll implements Serializable {
artwork.addAll(backdrops);
}
// Add all the backdrops to the list
// Add all the profiles to the list
if (types.contains(ArtworkType.PROFILE)) {
updateArtworkType(profiles, ArtworkType.PROFILE);
artwork.addAll(profiles);

@ -21,7 +21,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model2.collection.CollectionInfo;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import org.junit.AfterClass;

@ -22,7 +22,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList;

@ -21,14 +21,25 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.person.Person;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model2.artwork.ArtworkMedia;
import com.omertron.themoviedbapi.model2.person.CreditMovieBasic;
import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
import com.omertron.themoviedbapi.model2.person.ExternalID;
import com.omertron.themoviedbapi.model2.person.Person;
import com.omertron.themoviedbapi.model2.person.PersonCredits;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Before;
@ -45,6 +56,7 @@ public class TmdbPeopleTest extends AbstractTests {
private static final int ID_BRUCE_WILLIS = 62;
private static final int ID_SEAN_BEAN = 48;
private static final int ID_DICK_WOLF = 117443;
private static final List<TestID> testIDs = new ArrayList<TestID>();
public TmdbPeopleTest() {
}
@ -53,6 +65,8 @@ public class TmdbPeopleTest extends AbstractTests {
public static void setUpClass() throws MovieDbException {
doConfiguration();
instance = new TmdbPeople(getApiKey(), getHttpTools());
testIDs.add(new TestID("Bruce Willis", "nm0000246", 62));
testIDs.add(new TestID("Will Smith", "nm0000226", 2888));
}
@AfterClass
@ -75,33 +89,150 @@ public class TmdbPeopleTest extends AbstractTests {
// @Test
public void testGetPersonInfo() throws MovieDbException {
LOG.info("getPersonInfo");
Person result = instance.getPersonInfo(ID_BRUCE_WILLIS);
assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS);
assertTrue("Missing bio", StringUtils.isNotBlank(result.getBiography()));
assertTrue("Missing birthday", StringUtils.isNotBlank(result.getBirthday()));
assertTrue("Missing homepage", StringUtils.isNotBlank(result.getHomepage()));
assertTrue("Missing IMDB", StringUtils.isNotBlank(result.getImdbId()));
assertTrue("Missing name", StringUtils.isNotBlank(result.getName()));
assertTrue("Missing birth place", StringUtils.isNotBlank(result.getBirthplace()));
assertTrue("Missing artwork", StringUtils.isNotBlank(result.getProfilePath()));
assertTrue("Missing bio", result.getPopularity() > 0F);
Person result;
for (TestID test : testIDs) {
result = instance.getPersonInfo(test.getTmdb());
assertEquals("Wrong actor returned", test.getTmdb(), result.getId());
assertTrue("Missing bio", StringUtils.isNotBlank(result.getBiography()));
assertTrue("Missing birthday", StringUtils.isNotBlank(result.getBirthday()));
assertTrue("Missing homepage", StringUtils.isNotBlank(result.getHomepage()));
assertEquals("Missing IMDB", test.getImdb(), result.getImdbId());
assertTrue("Missing name", StringUtils.isNotBlank(result.getName()));
assertTrue("Missing birth place", StringUtils.isNotBlank(result.getPlaceOfBirth()));
assertTrue("Missing artwork", StringUtils.isNotBlank(result.getProfilePath()));
assertTrue("Missing bio", result.getPopularity() > 0F);
}
}
/**
* Test of getPersonMovieOldImages method, of class TheMovieDbApi.
* Test of getPersonMovieCredits method, of class TmdbPeople.
*
* @throws MovieDbException
* @throws com.omertron.themoviedbapi.MovieDbException
*/
// @Test
public void testGetPersonMovieCredits() throws MovieDbException {
LOG.info("getPersonMovieCredits");
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : testIDs) {
PersonCredits<CreditMovieBasic> result = instance.getPersonMovieCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
assertFalse("No crew", result.getCrew().isEmpty());
}
}
/**
* Test of getPersonTVCredits method, of class TmdbPeople.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
// @Test
public void testGetPersonTVCredits() throws MovieDbException {
LOG.info("getPersonTVCredits");
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : testIDs) {
PersonCredits<CreditTVBasic> result = instance.getPersonTVCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
assertFalse("No crew", result.getCrew().isEmpty());
}
}
/**
* Test of getPersonCombinedCredits method, of class TmdbPeople.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
// @Test
public void testGetPersonCombinedCredits() throws MovieDbException {
LOG.info("getPersonCombinedCredits");
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : testIDs) {
PersonCredits<CreditTVBasic> result = instance.getPersonCombinedCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
assertFalse("No crew", result.getCrew().isEmpty());
}
fail("Not working");
}
/**
* Test of getPersonExternalIds method, of class TmdbPeople.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
// @Test
public void testGetPersonExternalIds() throws MovieDbException {
LOG.info("getPersonExternalIds");
for (TestID test : testIDs) {
ExternalID result = instance.getPersonExternalIds(test.getTmdb());
assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbId());
}
}
/**
* Test of getPersonImages method, of class TmdbPeople.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
// @Test
public void testGetPersonImages() throws MovieDbException {
LOG.info("getPersonImages");
TmdbResultsList<Artwork> result = instance.getPersonImages(ID_BRUCE_WILLIS);
assertTrue("No cast information", result.getResults().size() > 0);
for (Artwork artwork : result.getResults()) {
assertTrue("Artwork is blank", StringUtils.isNotBlank(artwork.getFilePath()));
for (TestID test : testIDs) {
TmdbResultsList<Artwork> result = instance.getPersonImages(test.getTmdb());
assertFalse("No artwork", result.isEmpty());
assertEquals("Wrong artwork type", ArtworkType.PROFILE, result.getResults().get(0).getArtworkType());
}
}
/**
* Test of getPersonTaggedImages method, of class TmdbPeople.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
// @Test
public void testGetPersonTaggedImages() throws MovieDbException {
LOG.info("getPersonTaggedImages");
Integer page = null;
String language = LANGUAGE_DEFAULT;
for (TestID test : testIDs) {
TmdbResultsList<ArtworkMedia> result = instance.getPersonTaggedImages(test.getTmdb(), page, language);
for (ArtworkMedia am : result.getResults()) {
LOG.info("{}", ToStringBuilder.reflectionToString(am, ToStringStyle.DEFAULT_STYLE));
}
}
}
/**
* Test of getPersonChanges method, of class TmdbPeople.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
//@Test
public void testGetPersonChanges() throws MovieDbException {
LOG.info("getPersonChanges");
int persondId = 0;
String startDate = "";
String endDate = "";
TmdbResultsList<Person> expResult = null;
TmdbResultsList<Person> result = instance.getPersonChanges(persondId, startDate, endDate);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@ -112,9 +243,12 @@ public class TmdbPeopleTest extends AbstractTests {
@Test
public void testGetPersonPopular() throws MovieDbException {
LOG.info("getPersonPopular");
int page = 0;
Integer page = null;
TmdbResultsList<Person> expResult = null;
TmdbResultsList<Person> result = instance.getPersonPopular(page);
assertFalse("No popular people", result.getResults().isEmpty());
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
@ -123,14 +257,14 @@ public class TmdbPeopleTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetPersonLatest() throws MovieDbException {
LOG.info("getPersonLatest");
Person expResult = null;
Person result = instance.getPersonLatest();
assertNotNull("No results found", result);
assertTrue("No results found", StringUtils.isNotBlank(result.getName()));
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}

Loading…
Cancel
Save