diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index 05bbf973..1f197f60 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -586,21 +586,20 @@ public class MediaDetection { } } - // search by file name or folder name (initialize with known options) - Set terms = options.stream().map(Movie::getNameWithYear).collect(toCollection(LinkedHashSet::new)); + // search by file name or folder name (NOTE: can't initialize with known options because misleading NFO files may lead to bad matches) + List names = new ArrayList(2); // 1. term: try to match movie pattern 'name (year)' or use filename as is - terms.add(getName(movieFile)); + names.add(getName(movieFile)); // 2. term: first meaningful parent folder File movieFolder = guessMovieFolder(movieFile); if (movieFolder != null) { - terms.add(getName(movieFolder)); + names.add(getName(movieFolder)); } // reduce movie names - terms = new LinkedHashSet(reduceMovieNamePermutations(terms)); - + Set terms = reduceMovieNamePermutations(names); List movieNameMatches = matchMovieName(terms, true, 0); // skip further queries if collected matches are already sufficient @@ -753,7 +752,7 @@ public class MediaDetection { return null; } - public static List reduceMovieNamePermutations(Collection terms) throws IOException { + public static Set reduceMovieNamePermutations(Collection terms) throws IOException { LinkedList names = new LinkedList(); for (String it : terms) { @@ -769,7 +768,7 @@ public class MediaDetection { } } - return names; + return new LinkedHashSet(names); } public static File guessMovieFolder(File movieFile) throws Exception {