* don't get tricked so easily by random extra nfo files or hash matches

This commit is contained in:
Reinhard Pointner 2012-07-15 07:42:06 +00:00
parent 3b3de961cd
commit 53f6b531fb
1 changed files with 12 additions and 4 deletions

View File

@ -325,7 +325,7 @@ public class MediaDetection {
// skip further queries if collected matches are already sufficient
if (options.size() > 0 && movieNameMatches.size() > 0) {
options.addAll(movieNameMatches);
return options;
return sortBySimilarity(options, terms);
}
// if matching name+year failed, try matching only by name
@ -368,9 +368,17 @@ public class MediaDetection {
options.addAll(movieNameMatches);
// sort by relevance
List<Movie> optionsByRelevance = new ArrayList<Movie>(options);
sort(optionsByRelevance, new SimilarityComparator(new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric()), stripReleaseInfo(terms, true).toArray()));
return optionsByRelevance;
return sortBySimilarity(options, terms);
}
public static <T> List<T> sortBySimilarity(Collection<T> options, Collection<String> terms) throws IOException {
SimilarityMetric metric = new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric());
List<String> paragon = stripReleaseInfo(terms, true);
List<T> sorted = new ArrayList<T>(options);
sort(sorted, new SimilarityComparator(metric, paragon.toArray()));
return sorted;
}