* support {info.ProductionCountries}
This commit is contained in:
parent
e19d20c1cf
commit
647f25fa30
|
@ -237,6 +237,6 @@ public class OMDbClient implements MovieIdentificationService {
|
||||||
actors.add(new Person(writer, null, "Writer"));
|
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>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,12 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
public Movie getMovieDescriptor(Movie id, Locale locale) throws IOException {
|
public Movie getMovieDescriptor(Movie id, Locale locale) throws IOException {
|
||||||
if (id.getTmdbId() > 0 || id.getImdbId() > 0) {
|
if (id.getTmdbId() > 0 || id.getImdbId() > 0) {
|
||||||
MovieInfo info = getMovieInfo(id, locale, false);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -224,6 +229,15 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal spoken_languages data: " + response);
|
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>();
|
List<String> alternativeTitles = new ArrayList<String>();
|
||||||
try {
|
try {
|
||||||
JSONObject titles = (JSONObject) response.get("alternative_titles");
|
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);
|
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 {
|
public List<Artwork> getArtwork(String id) throws IOException {
|
||||||
|
@ -389,6 +403,7 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
protected String[] alternativeTitles;
|
protected String[] alternativeTitles;
|
||||||
protected String[] genres;
|
protected String[] genres;
|
||||||
protected String[] spokenLanguages;
|
protected String[] spokenLanguages;
|
||||||
|
protected String[] productionCountries;
|
||||||
|
|
||||||
protected Person[] people;
|
protected Person[] people;
|
||||||
protected Trailer[] trailers;
|
protected Trailer[] trailers;
|
||||||
|
@ -397,11 +412,12 @@ public class TMDbClient implements MovieIdentificationService {
|
||||||
// used by serializer
|
// 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.fields = new EnumMap<MovieProperty, String>(fields);
|
||||||
this.alternativeTitles = alternativeTitles.toArray(new String[0]);
|
this.alternativeTitles = alternativeTitles.toArray(new String[0]);
|
||||||
this.genres = genres.toArray(new String[0]);
|
this.genres = genres.toArray(new String[0]);
|
||||||
this.spokenLanguages = spokenLanguages.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.people = people.toArray(new Person[0]);
|
||||||
this.trailers = trailers.toArray(new Trailer[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() {
|
public String getOriginalName() {
|
||||||
return get(MovieProperty.original_title);
|
return get(MovieProperty.original_title);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue