From e83de902ee73a350e58c2591e3918cb0875c11bd Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 24 Jul 2013 11:53:16 +0000 Subject: [PATCH] * improved user-interaction if manual query input is required for movie search --- .../filebot/ui/rename/MovieHashMatcher.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java index fa6d843c..0aa192d9 100644 --- a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java @@ -276,16 +276,19 @@ class MovieHashMatcher implements AutoCompleteMatcher { String input = inputMemory.get(suggestion); if (input == null || suggestion == null || suggestion.isEmpty()) { File movieFolder = guessMovieFolder(movieFile); - input = showInputDialog("Enter movie name:", suggestion, movieFolder == null ? movieFile.getName() : String.format("%s/%s", movieFolder.getName(), movieFile.getName()), parent); + input = showInputDialog("Enter movie name:", suggestion != null && suggestion.length() > 0 ? suggestion : getName(movieFile), movieFolder == null ? movieFile.getName() : String.format("%s/%s", movieFolder.getName(), movieFile.getName()), parent); inputMemory.put(suggestion, input); } if (input != null) { options = service.searchMovie(input, locale); + if (options.size() > 0) { + return selectMovie(movieFile, input, options, memory, parent); + } } } - return options.isEmpty() ? null : selectMovie(movieFile, options, memory, parent); + return options.isEmpty() ? null : selectMovie(movieFile, null, options, memory, parent); } @@ -304,16 +307,16 @@ class MovieHashMatcher implements AutoCompleteMatcher { } - protected Movie selectMovie(final File movieFile, final Collection options, final Map memory, final Component parent) throws Exception { + protected Movie selectMovie(final File movieFile, final String userQuery, final Collection options, final Map memory, final Component parent) throws Exception { // 1. movie by filename - final String fileQuery = checkedStripReleaseInfo(movieFile); + final String fileQuery = (userQuery != null) ? userQuery : checkedStripReleaseInfo(movieFile); // 2. movie by directory final File movieFolder = guessMovieFolder(movieFile); - final String folderQuery = (movieFolder == null) ? "" : checkedStripReleaseInfo(movieFolder); + final String folderQuery = (userQuery != null || movieFolder == null) ? "" : checkedStripReleaseInfo(movieFolder); // auto-ignore invalid files - if (fileQuery.length() < 2 && folderQuery.length() < 2) { + if (userQuery == null && fileQuery.length() < 2 && folderQuery.length() < 2) { return null; }