Improved logging
This commit is contained in:
parent
ee11696457
commit
0a8234fdf8
|
@ -91,6 +91,13 @@ public class TMDbClient implements MovieIdentificationService {
|
|||
// e.g. {"id":16320,"title":"冲出宁静号","release_date":"2005-09-30","original_title":"Serenity"}
|
||||
return streamJsonObjects(response, "results").map(it -> {
|
||||
int id = -1, year = -1;
|
||||
try {
|
||||
id = getDecimal(it, "id").intValue();
|
||||
year = matchInteger(getString(it, "release_date")); // release date is often missing
|
||||
} catch (Exception e) {
|
||||
debug.warning(format("Missing data: release_date => %s", it));
|
||||
return null;
|
||||
}
|
||||
|
||||
String title = getString(it, "title");
|
||||
String originalTitle = getString(it, "original_title");
|
||||
|
@ -98,10 +105,6 @@ public class TMDbClient implements MovieIdentificationService {
|
|||
title = originalTitle;
|
||||
}
|
||||
|
||||
try {
|
||||
id = getDecimal(it, "id").intValue();
|
||||
year = matchInteger(getString(it, "release_date")); // release date is often missing
|
||||
|
||||
Set<String> alternativeTitles = new LinkedHashSet<String>();
|
||||
if (originalTitle != null) {
|
||||
alternativeTitles.add(originalTitle);
|
||||
|
@ -122,10 +125,6 @@ public class TMDbClient implements MovieIdentificationService {
|
|||
alternativeTitles.remove(title);
|
||||
|
||||
return new Movie(title, alternativeTitles.toArray(new String[0]), year, -1, id, locale);
|
||||
} catch (Exception e) {
|
||||
debug.warning(format("Bad data: %s", it));
|
||||
return null;
|
||||
}
|
||||
}).filter(Objects::nonNull).collect(toList());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue