* improved movie result auto-selection

This commit is contained in:
Reinhard Pointner 2012-01-02 06:09:00 +00:00
parent 90cc0a06fa
commit 3bf8545bfc
3 changed files with 32 additions and 8 deletions

View File

@ -37,6 +37,7 @@ import net.sourceforge.filebot.MediaTypes;
import net.sourceforge.filebot.WebServices;
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
import net.sourceforge.filebot.similarity.SimilarityComparator;
import net.sourceforge.filebot.similarity.SimilarityMetric;
import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.MovieIdentificationService;
@ -180,9 +181,7 @@ public class MediaDetection {
files.add(getName(movieFile));
files.add(getName(movieFile.getParentFile()));
long t = System.currentTimeMillis();
List<Movie> movieNameMatches = matchMovieName(files, locale, strict);
System.out.println(System.currentTimeMillis() - t);
// skip further queries if collected matches are already sufficient
if (options.size() > 0 && movieNameMatches.size() > 0) {
@ -190,7 +189,7 @@ public class MediaDetection {
return options;
}
// continue gathering more matches if possible
// add local matching after online search
options.addAll(movieNameMatches);
// query by file / folder name
@ -198,7 +197,10 @@ public class MediaDetection {
options.addAll(queryMovieByFileName(files, queryLookupService, locale));
}
return options;
// sort by relevance
List<Movie> optionsByRelevance = new ArrayList<Movie>(options);
sort(optionsByRelevance, new SimilarityComparator(stripReleaseInfo(getName(movieFile))));
return optionsByRelevance;
}

View File

@ -17,6 +17,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -33,6 +34,8 @@ import javax.swing.SwingUtilities;
import net.sourceforge.filebot.Analytics;
import net.sourceforge.filebot.similarity.Match;
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
import net.sourceforge.filebot.similarity.SimilarityMetric;
import net.sourceforge.filebot.ui.SelectDialog;
import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.MovieIdentificationService;
@ -181,6 +184,25 @@ class MovieHashMatcher implements AutoCompleteMatcher {
return options.iterator().next();
}
// auto-select most probable search result
final List<Movie> probableMatches = new LinkedList<Movie>();
// use name similarity metric
final String query = stripReleaseInfo(getName(movieFile));
final SimilarityMetric metric = new NameSimilarityMetric();
// find probable matches using name similarity >= 0.9
for (Movie result : options) {
if (metric.getSimilarity(query, result.getName()) >= 0.9) {
probableMatches.add(result);
}
}
// auto-select first and only probable search result
if (probableMatches.size() == 1) {
return probableMatches.get(0);
}
// show selection dialog on EDT
final RunnableFuture<Movie> showSelectDialog = new FutureTask<Movie>(new Callable<Movie>() {
@ -190,7 +212,7 @@ class MovieHashMatcher implements AutoCompleteMatcher {
SelectDialog<Movie> selectDialog = new SelectDialog<Movie>(parent, options);
selectDialog.setTitle(movieFile.getPath());
selectDialog.getHeaderLabel().setText(String.format("Movies matching '%s':", stripReleaseInfo(getName(movieFile))));
selectDialog.getHeaderLabel().setText(String.format("Movies matching '%s':", query));
selectDialog.getCancelAction().putValue(Action.NAME, "Ignore");
selectDialog.pack();
@ -211,5 +233,4 @@ class MovieHashMatcher implements AutoCompleteMatcher {
// selected value or null
return showSelectDialog.get();
}
}

View File

@ -1,5 +1,3 @@
PROPER
RETAIL
^(TV.)?(Show|Serie|Anime)[s]?$
^Movie[s]?$
^Video[s]?$
@ -10,8 +8,11 @@ ExtraTorrent
Hard.Subbed
mkvonly
MVGroup.org
PROPER
READNFO
REPACK
RETAIL
sample[s]?$
ShareReactor
ShareZONE
UsaBit.com