diff --git a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java index fba2949b..887c2836 100644 --- a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java @@ -17,6 +17,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; @@ -184,9 +185,13 @@ class MovieHashMatcher implements AutoCompleteMatcher { } // search by file name or folder name - for (File it : new File[] { movieFile, movieFile.getParentFile() }) { + Set searchQueries = new LinkedHashSet(2); + searchQueries.add(normalizeMovieName(movieFile)); + searchQueries.add(normalizeMovieName(movieFile.getParentFile())); + + for (String query : searchQueries) { if (autodetect && options.isEmpty()) { - options = service.searchMovie(normalizeMovieName(it), locale); + options = service.searchMovie(query, locale); } } diff --git a/source/net/sourceforge/filebot/web/TMDbClient.java b/source/net/sourceforge/filebot/web/TMDbClient.java index 617f4f66..a5a56f3b 100644 --- a/source/net/sourceforge/filebot/web/TMDbClient.java +++ b/source/net/sourceforge/filebot/web/TMDbClient.java @@ -53,7 +53,7 @@ public class TMDbClient implements MovieIdentificationService { @Override public List searchMovie(String query, Locale locale) throws IOException { try { - return getMovies("Movie.search", query, locale); + return getMovies("Movie.search", encode(query), locale); } catch (SAXException e) { // TMDb output is sometimes malformed xml Logger.getLogger(getClass().getName()).log(Level.WARNING, e.getMessage());