From d0f32dd0f713798561d9466497484c906dc6e3a6 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 20 Jul 2012 04:04:55 +0000 Subject: [PATCH] * make movie detection resilient against unavailable local movie index --- .../filebot/media/MediaDetection.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index aa72faae..5e7b9fe9 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -332,7 +332,7 @@ public class MediaDetection { // 1. term: try to match movie pattern 'name (year)' or use filename as is terms.add(reduceMovieName(getName(movieFile))); - // 2. term: first meaningful parent folder + // 2. term: first meaningful parent folder File movieFolder = guessMovieFolder(movieFile); if (movieFolder != null) { terms.add(reduceMovieName(getName(movieFolder))); @@ -433,12 +433,19 @@ public class MediaDetection { private static synchronized List> getMovieIndex() throws IOException { if (movieIndex == null) { - Movie[] movies = releaseInfo.getMovieList(); - movieIndex = new ArrayList>(movies.length); - for (Movie movie : movies) { - movieIndex.add(new SimpleEntry(normalizePunctuation(movie.getName()).toLowerCase(), movie)); + try { + Movie[] movies = releaseInfo.getMovieList(); + movieIndex = new ArrayList>(movies.length); + for (Movie movie : movies) { + movieIndex.add(new SimpleEntry(normalizePunctuation(movie.getName()).toLowerCase(), movie)); + } + } catch (Exception e) { + // can't load movie index, just try again next time + Logger.getLogger(MediaDetection.class.getClass().getName()).log(Level.SEVERE, "Failed to load movie index: " + e.getMessage(), e); + return emptyList(); } } + return movieIndex; }