* support {info.ProductionCountries}

This commit is contained in:
Reinhard Pointner 2014-09-20 18:37:42 +00:00
parent e19d20c1cf
commit 647f25fa30
2 changed files with 24 additions and 4 deletions

View File

@ -237,6 +237,6 @@ public class OMDbClient implements MovieIdentificationService {
actors.add(new Person(writer, null, "Writer"));
}
return new MovieInfo(fields, new ArrayList<String>(0), genres, new ArrayList<String>(0), actors, new ArrayList<Trailer>(0));
return new MovieInfo(fields, new ArrayList<String>(), genres, new ArrayList<String>(), new ArrayList<String>(), actors, new ArrayList<Trailer>());
}
}

View File

@ -156,7 +156,12 @@ public class TMDbClient implements MovieIdentificationService {
public Movie getMovieDescriptor(Movie id, Locale locale) throws IOException {
if (id.getTmdbId() > 0 || id.getImdbId() > 0) {
MovieInfo info = getMovieInfo(id, locale, false);
return new Movie(info.getName(), info.getOriginalName() == null || info.getOriginalName().isEmpty() ? new String[0] : new String[] { info.getOriginalName() }, info.getReleased().getYear(), info.getImdbId(), info.getId(), locale);
String name = info.getName();
String[] aliasNames = info.getOriginalName() == null || info.getOriginalName().isEmpty() ? new String[0] : new String[] { info.getOriginalName() };
int year = info.getReleased().getYear();
int tmdbid = info.getId();
int imdbid = info.getImdbId() != null ? info.getImdbId() : -1;
return new Movie(name, aliasNames, year, imdbid, tmdbid, locale);
}
return null;
}
@ -224,6 +229,15 @@ public class TMDbClient implements MovieIdentificationService {
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal spoken_languages data: " + response);
}
List<String> productionCountries = new ArrayList<String>();
try {
for (JSONObject it : jsonList(response.get("production_countries"))) {
productionCountries.add((String) it.get("name"));
}
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal production_countries data: " + response);
}
List<String> alternativeTitles = new ArrayList<String>();
try {
JSONObject titles = (JSONObject) response.get("alternative_titles");
@ -293,7 +307,7 @@ public class TMDbClient implements MovieIdentificationService {
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal trailers data: " + response);
}
return new MovieInfo(fields, alternativeTitles, genres, spokenLanguages, cast, trailers);
return new MovieInfo(fields, alternativeTitles, genres, spokenLanguages, productionCountries, cast, trailers);
}
public List<Artwork> getArtwork(String id) throws IOException {
@ -389,6 +403,7 @@ public class TMDbClient implements MovieIdentificationService {
protected String[] alternativeTitles;
protected String[] genres;
protected String[] spokenLanguages;
protected String[] productionCountries;
protected Person[] people;
protected Trailer[] trailers;
@ -397,11 +412,12 @@ public class TMDbClient implements MovieIdentificationService {
// used by serializer
}
protected MovieInfo(Map<MovieProperty, String> fields, List<String> alternativeTitles, List<String> genres, List<String> spokenLanguages, List<Person> people, List<Trailer> trailers) {
protected MovieInfo(Map<MovieProperty, String> fields, List<String> alternativeTitles, List<String> genres, List<String> spokenLanguages, List<String> productionCountries, List<Person> people, List<Trailer> trailers) {
this.fields = new EnumMap<MovieProperty, String>(fields);
this.alternativeTitles = alternativeTitles.toArray(new String[0]);
this.genres = genres.toArray(new String[0]);
this.spokenLanguages = spokenLanguages.toArray(new String[0]);
this.productionCountries = productionCountries.toArray(new String[0]);
this.people = people.toArray(new Person[0]);
this.trailers = trailers.toArray(new Trailer[0]);
}
@ -430,6 +446,10 @@ public class TMDbClient implements MovieIdentificationService {
}
}
public List<String> getProductionCountries() {
return unmodifiableList(asList(productionCountries));
}
public String getOriginalName() {
return get(MovieProperty.original_title);
}