* log & ignore faulty trailer data

This commit is contained in:
Reinhard Pointner 2014-08-27 18:20:22 +00:00
parent ab2eda7d2c
commit 1580ca56b8
1 changed files with 13 additions and 9 deletions

View File

@ -255,6 +255,7 @@ 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");
try {
for (String section : new String[] { "quicktime", "youtube" }) { for (String section : new String[] { "quicktime", "youtube" }) {
for (JSONObject it : jsonList(trailerResponse.get(section))) { for (JSONObject it : jsonList(trailerResponse.get(section))) {
Map<String, String> sources = new LinkedHashMap<String, String>(); Map<String, String> sources = new LinkedHashMap<String, String>();
@ -268,6 +269,9 @@ public class TMDbClient implements MovieIdentificationService {
trailers.add(new Trailer(section, it.get("name").toString(), sources)); 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);
} }