From 58b5c74a6c322bc65f0ada06662b373ad5d34840 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 10 Jan 2015 20:52:10 +0000 Subject: [PATCH] * remove unused hash-lookup related code --- source/net/filebot/cli/CmdlineOperations.java | 2 +- .../net/filebot/cli/ScriptShellBaseClass.java | 2 +- source/net/filebot/media/MediaDetection.java | 22 +++++++++---------- .../filebot/subtitle/SubtitleUtilities.java | 2 +- .../filebot/ui/rename/MovieHashMatcher.java | 6 ++--- .../ui/subtitle/SubtitleUploadDialog.java | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index ea903262..714454fe 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -431,7 +431,7 @@ public class CmdlineOperations implements CmdlineInterface { // unknown hash, try via imdb id from nfo file if (movie == null) { CLILogger.fine(format("Auto-detect movie from context: [%s]", file)); - Collection options = detectMovie(file, null, service, locale, strict); + Collection options = detectMovie(file, service, locale, strict); // apply filter if defined options = applyExpressionFilter(options, filter); diff --git a/source/net/filebot/cli/ScriptShellBaseClass.java b/source/net/filebot/cli/ScriptShellBaseClass.java index 68528791..a573994d 100644 --- a/source/net/filebot/cli/ScriptShellBaseClass.java +++ b/source/net/filebot/cli/ScriptShellBaseClass.java @@ -243,7 +243,7 @@ public abstract class ScriptShellBaseClass extends Script { // 3. run full-fledged movie detection try { - return MediaDetection.detectMovie(file, null, WebServices.TheMovieDB, Locale.ENGLISH, strict).get(0); + return MediaDetection.detectMovie(file, WebServices.TheMovieDB, Locale.ENGLISH, strict).get(0); } catch (Exception e) { // ignore and fail } diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index cac1e3ee..5bd41556 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -554,7 +554,7 @@ public class MediaDetection { return seriesList; } - public static List detectMovie(File movieFile, MovieIdentificationService hashLookupService, MovieIdentificationService queryLookupService, Locale locale, boolean strict) throws Exception { + public static List detectMovie(File movieFile, MovieIdentificationService service, Locale locale, boolean strict) throws Exception { List options = new ArrayList(); // try xattr metadata if enabled @@ -564,22 +564,22 @@ public class MediaDetection { } // lookup by file hash - if (hashLookupService != null && movieFile.isFile()) { + if (service != null && movieFile.isFile()) { try { - for (Movie movie : hashLookupService.getMovieDescriptors(singleton(movieFile), locale).values()) { + for (Movie movie : service.getMovieDescriptors(singleton(movieFile), locale).values()) { if (movie != null) { options.add(movie); } } - } catch (Exception e) { - Logger.getLogger(MediaDetection.class.getName()).log(Level.WARNING, hashLookupService.getName() + ": " + e.getMessage()); + } catch (UnsupportedOperationException e) { + // ignore logging => hash lookup only supported by OpenSubtitles } } // lookup by id from nfo file - if (queryLookupService != null) { + if (service != null) { for (int imdbid : grepImdbId(movieFile.getPath())) { - Movie movie = queryLookupService.getMovieDescriptor(new Movie(null, 0, imdbid, -1), locale); + Movie movie = service.getMovieDescriptor(new Movie(null, 0, imdbid, -1), locale); if (movie != null) { options.add(movie); } @@ -587,7 +587,7 @@ public class MediaDetection { // try to grep imdb id from nfo files for (int imdbid : grepImdbIdFor(movieFile)) { - Movie movie = queryLookupService.getMovieDescriptor(new Movie(null, 0, imdbid, -1), locale); + Movie movie = service.getMovieDescriptor(new Movie(null, 0, imdbid, -1), locale); if (movie != null) { options.add(movie); } @@ -645,8 +645,8 @@ public class MediaDetection { } // query by file / folder name - if (queryLookupService != null) { - List results = queryMovieByFileName(terms, queryLookupService, locale); + if (service != null) { + List results = queryMovieByFileName(terms, service, locale); // try query without year as it sometimes messes up results if years don't match properly (movie release years vs dvd release year, etc) if (results.isEmpty() && !strict) { @@ -662,7 +662,7 @@ public class MediaDetection { } } if (lastResortQueryList.size() > 0) { - results = queryMovieByFileName(lastResortQueryList, queryLookupService, locale); + results = queryMovieByFileName(lastResortQueryList, service, locale); } } diff --git a/source/net/filebot/subtitle/SubtitleUtilities.java b/source/net/filebot/subtitle/SubtitleUtilities.java index 3729579f..56e128e6 100644 --- a/source/net/filebot/subtitle/SubtitleUtilities.java +++ b/source/net/filebot/subtitle/SubtitleUtilities.java @@ -86,7 +86,7 @@ public final class SubtitleUtilities { // might be a movie, auto-detect movie names if (!isEpisode(f.getPath(), true)) { - for (Movie it : detectMovie(f, null, null, Locale.ENGLISH, strict)) { + for (Movie it : detectMovie(f, null, Locale.ENGLISH, strict)) { queries.add(it.getName()); } } diff --git a/source/net/filebot/ui/rename/MovieHashMatcher.java b/source/net/filebot/ui/rename/MovieHashMatcher.java index 7a91cbad..8ea17393 100644 --- a/source/net/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/filebot/ui/rename/MovieHashMatcher.java @@ -187,7 +187,7 @@ class MovieHashMatcher implements AutoCompleteMatcher { if (year.size() > 0 && parseEpisodeNumber(f, true) == null) { // allow only movie matches where the the movie year matches the year pattern in the filename List matches = new ArrayList(); - for (Movie movie : detectMovie(f, null, service, locale, strict)) { + for (Movie movie : detectMovie(f, service, locale, strict)) { if (year.contains(movie.getYear())) { matches.add(movie); } @@ -196,7 +196,7 @@ class MovieHashMatcher implements AutoCompleteMatcher { } } else { // in non-strict mode just allow all options - detection.put(f, detectMovie(f, null, service, locale, strict)); + detection.put(f, detectMovie(f, service, locale, strict)); } } return detection; @@ -477,7 +477,7 @@ class MovieHashMatcher implements AutoCompleteMatcher { List> matches = new ArrayList>(); if (input != null && input.length() > 0) { - List results = detectMovie(new File(input), null, service, locale, false); + List results = detectMovie(new File(input), service, locale, false); for (Movie it : results) { // make sure to retrieve language-specific movie descriptor matches.add(new Match(null, service.getMovieDescriptor(it, locale))); diff --git a/source/net/filebot/ui/subtitle/SubtitleUploadDialog.java b/source/net/filebot/ui/subtitle/SubtitleUploadDialog.java index bce99487..8a1cfdb5 100644 --- a/source/net/filebot/ui/subtitle/SubtitleUploadDialog.java +++ b/source/net/filebot/ui/subtitle/SubtitleUploadDialog.java @@ -698,7 +698,7 @@ public class SubtitleUploadDialog extends JDialog { } } } else { - Collection identity = MediaDetection.detectMovie(mapping.getVideo(), database, database, Locale.ENGLISH, true); + Collection identity = MediaDetection.detectMovie(mapping.getVideo(), database, Locale.ENGLISH, true); for (Movie it : identity) { if (it.getImdbId() <= 0 && it.getTmdbId() > 0) { it = WebServices.TheMovieDB.getMovieDescriptor(it, Locale.ENGLISH);