From 53f6b531fb339e72fa61144589bcb8e7c9126174 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 15 Jul 2012 07:42:06 +0000 Subject: [PATCH] * don't get tricked so easily by random extra nfo files or hash matches --- .../filebot/media/MediaDetection.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 67c034b7..6c77ef02 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -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 optionsByRelevance = new ArrayList(options); - sort(optionsByRelevance, new SimilarityComparator(new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric()), stripReleaseInfo(terms, true).toArray())); - return optionsByRelevance; + return sortBySimilarity(options, terms); + } + + + public static List sortBySimilarity(Collection options, Collection terms) throws IOException { + SimilarityMetric metric = new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric()); + List paragon = stripReleaseInfo(terms, true); + + List sorted = new ArrayList(options); + sort(sorted, new SimilarityComparator(metric, paragon.toArray())); + return sorted; }