1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* fix issue with processing two shows with the same name, e.g. SMASH and Smash

This commit is contained in:
Reinhard Pointner 2013-03-15 13:50:28 +00:00
parent 17aa158a72
commit 1f713a3e5a

View File

@ -863,7 +863,7 @@ public class CmdlineOperations implements CmdlineInterface {
public List<SearchResult> findProbableMatches(final String query, Collection<? extends SearchResult> searchResults, boolean strict) {
// auto-select most probable search result
Map<String, SearchResult> probableMatches = new LinkedHashMap<String, SearchResult>();
List<SearchResult> probableMatches = new ArrayList<SearchResult>();
// use name similarity metric
final SimilarityMetric metric = new NameSimilarityMetric();
@ -872,18 +872,17 @@ public class CmdlineOperations implements CmdlineInterface {
for (SearchResult result : searchResults) {
float f = (query == null) ? 1 : metric.getSimilarity(query, result.getName());
if (f >= (strict && searchResults.size() > 1 ? 0.85 : 0.75) || ((f >= 0.5 || !strict) && result.getName().toLowerCase().startsWith(query.toLowerCase()))) {
if (!probableMatches.containsKey(result.toString().toLowerCase())) {
probableMatches.put(result.toString().toLowerCase(), result);
if (!probableMatches.contains(result)) {
probableMatches.add(result);
}
}
}
// sort results by similarity to query
List<SearchResult> results = new ArrayList<SearchResult>(probableMatches.values());
if (query != null) {
sort(results, new SimilarityComparator(query));
sort(probableMatches, new SimilarityComparator(query));
}
return results;
return probableMatches;
}