* fix NPE

This commit is contained in:
Reinhard Pointner 2015-02-26 15:53:50 +00:00
parent b2150de37a
commit ea0855e898
1 changed files with 9 additions and 7 deletions

View File

@ -156,6 +156,7 @@ 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);
if (info != null) {
String name = info.getName(); String name = info.getName();
String[] aliasNames = info.getOriginalName() == null || info.getOriginalName().isEmpty() || info.getOriginalName().equals(name) ? new String[0] : new String[] { info.getOriginalName() }; String[] aliasNames = info.getOriginalName() == null || info.getOriginalName().isEmpty() || info.getOriginalName().equals(name) ? new String[0] : new String[] { info.getOriginalName() };
int year = info.getReleased() != null ? info.getReleased().getYear() : id.getYear(); int year = info.getReleased() != null ? info.getReleased().getYear() : id.getYear();
@ -163,6 +164,7 @@ public class TMDbClient implements MovieIdentificationService {
int imdbid = info.getImdbId() != null ? info.getImdbId() : -1; int imdbid = info.getImdbId() != null ? info.getImdbId() : -1;
return new Movie(name, aliasNames, year, imdbid, tmdbid, locale); return new Movie(name, aliasNames, year, imdbid, tmdbid, locale);
} }
}
return null; return null;
} }
@ -179,7 +181,7 @@ public class TMDbClient implements MovieIdentificationService {
return getMovieInfo(String.format("tt%07d", movie.getImdbId()), locale, extendedInfo); return getMovieInfo(String.format("tt%07d", movie.getImdbId()), locale, extendedInfo);
} }
} catch (FileNotFoundException | NullPointerException e) { } catch (FileNotFoundException | NullPointerException e) {
Logger.getLogger(getClass().getName()).log(Level.WARNING, String.format("Movie data not found: %s [%d / %d]", movie, movie.getTmdbId(), movie.getImdbId()), e); Logger.getLogger(getClass().getName()).log(Level.WARNING, String.format("Movie data not found: %s [%d / %d]", movie, movie.getTmdbId(), movie.getImdbId()));
} }
return null; return null;
} }