From 5fc3a901593e682432a3ab9209de0c14e7fc4243 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 9 Apr 2016 20:58:32 +0000 Subject: [PATCH] Make sure to eliminate duplicate queries --- source/net/filebot/media/MediaDetection.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/net/filebot/media/MediaDetection.java b/source/net/filebot/media/MediaDetection.java index 1838606f..0133fc53 100644 --- a/source/net/filebot/media/MediaDetection.java +++ b/source/net/filebot/media/MediaDetection.java @@ -934,11 +934,13 @@ public class MediaDetection { addUniqueQuerySet(exactMatches, normalize, Function.identity(), unique); // remove blacklisted terms and remove duplicates + List extra = stream(guessMatches).flatMap(Collection::stream).filter(t -> { + return !unique.containsKey(normalize.apply(t)); + }).collect(toList()); + Set terms = new LinkedHashSet(); - for (Collection it : guessMatches) { - terms.addAll(stripReleaseInfo(it, true)); - terms.addAll(stripReleaseInfo(it, false)); - } + terms.addAll(stripReleaseInfo(extra, true)); + terms.addAll(stripReleaseInfo(extra, false)); addUniqueQuerySet(stripBlacklistedTerms(terms), normalize, normalize, unique); return new ArrayList(unique.values());