diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index b3e42338..4c4839b2 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -297,12 +297,13 @@ public class MediaDetection { } // use lenient sub sequence matching only as fallback - if (matches.size() > 0) { - names.addAll(matches); - } else { - names.addAll(matchSeriesByName(folders, 3)); - names.addAll(matchSeriesByName(filenames, 3)); + if (matches.isEmpty()) { + matches.addAll(matchSeriesByName(folders, 3)); + matches.addAll(matchSeriesByName(filenames, 3)); } + + // pass along only valid terms + names.addAll(stripBlacklistedTerms(matches)); } catch (Exception e) { Logger.getLogger(MediaDetection.class.getClass().getName()).log(Level.WARNING, "Failed to match folder structure: " + e.getMessage(), e); } @@ -692,6 +693,18 @@ public class MediaDetection { } + public static List stripBlacklistedTerms(Collection names) throws IOException { + Pattern blacklist = releaseInfo.getBlacklistPattern(); + List acceptables = new ArrayList(names.size()); + for (String it : names) { + if (blacklist.matcher(it).replaceAll("").trim().length() > 0) { + acceptables.add(it); + } + } + return acceptables; + } + + public static Set grepImdbIdFor(File file) throws Exception { Set collection = new LinkedHashSet(); List nfoFiles = new ArrayList();