* log & ignore faulty trailer data
This commit is contained in:
parent
ab2eda7d2c
commit
1580ca56b8
@ -255,18 +255,22 @@ public class TMDbClient implements MovieIdentificationService {
|
|||||||
|
|
||||||
List<Trailer> trailers = new ArrayList<Trailer>();
|
List<Trailer> trailers = new ArrayList<Trailer>();
|
||||||
JSONObject trailerResponse = (JSONObject) response.get("trailers");
|
JSONObject trailerResponse = (JSONObject) response.get("trailers");
|
||||||
for (String section : new String[] { "quicktime", "youtube" }) {
|
try {
|
||||||
for (JSONObject it : jsonList(trailerResponse.get(section))) {
|
for (String section : new String[] { "quicktime", "youtube" }) {
|
||||||
Map<String, String> sources = new LinkedHashMap<String, String>();
|
for (JSONObject it : jsonList(trailerResponse.get(section))) {
|
||||||
if (it.containsKey("sources")) {
|
Map<String, String> sources = new LinkedHashMap<String, String>();
|
||||||
for (JSONObject s : jsonList(it.get("sources"))) {
|
if (it.containsKey("sources")) {
|
||||||
sources.put(s.get("size").toString(), s.get("source").toString());
|
for (JSONObject s : jsonList(it.get("sources"))) {
|
||||||
|
sources.put(s.get("size").toString(), s.get("source").toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sources.put(it.get("size").toString(), it.get("source").toString());
|
||||||
}
|
}
|
||||||
} else {
|
trailers.add(new Trailer(section, it.get("name").toString(), sources));
|
||||||
sources.put(it.get("size").toString(), it.get("source").toString());
|
|
||||||
}
|
}
|
||||||
trailers.add(new Trailer(section, it.get("name").toString(), sources));
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Illegal trailer data: " + trailerResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MovieInfo(fields, alternativeTitles, genres, spokenLanguages, cast, trailers);
|
return new MovieInfo(fields, alternativeTitles, genres, spokenLanguages, cast, trailers);
|
||||||
|
Loading…
Reference in New Issue
Block a user