* fix potential NPE (for movies with missing release_data info)

This commit is contained in:
Reinhard Pointner 2014-12-05 09:57:50 +00:00
parent 3fa3128f65
commit 69854e02b4
2 changed files with 4 additions and 2 deletions

View File

@ -1490,9 +1490,11 @@ public class MediaDetection {
Movie movie = (Movie) model; Movie movie = (Movie) model;
if (movie.getYear() > 0 && movie.getTmdbId() > 0) { if (movie.getYear() > 0 && movie.getTmdbId() > 0) {
SimpleDate releaseDate = WebServices.TheMovieDB.getMovieInfo(movie, Locale.ENGLISH, false).getReleased(); SimpleDate releaseDate = WebServices.TheMovieDB.getMovieInfo(movie, Locale.ENGLISH, false).getReleased();
if (releaseDate != null) {
xattr.setCreationDate(releaseDate.getTimeStamp()); xattr.setCreationDate(releaseDate.getTimeStamp());
} }
} }
}
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set creation date: " + e.getMessage()); Logger.getLogger(MediaDetection.class.getClass().getName()).warning("Failed to set creation date: " + e.getMessage());
} }

View File

@ -158,7 +158,7 @@ public class TMDbClient implements MovieIdentificationService {
MovieInfo info = getMovieInfo(id, locale, false); MovieInfo info = getMovieInfo(id, locale, false);
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().getYear(); int year = info.getReleased() != null ? info.getReleased().getYear() : id.getYear();
int tmdbid = info.getId(); int tmdbid = info.getId();
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);