diff --git a/source/net/sourceforge/filebot/cli/CmdlineOperations.java b/source/net/sourceforge/filebot/cli/CmdlineOperations.java index 00180cf7..b05283db 100644 --- a/source/net/sourceforge/filebot/cli/CmdlineOperations.java +++ b/source/net/sourceforge/filebot/cli/CmdlineOperations.java @@ -297,7 +297,7 @@ public class CmdlineOperations implements CmdlineInterface { // unknown hash, try via imdb id from nfo file if (movie == null) { - Collection results = detectMovie(movieFiles[i], service, locale, strict); + Collection results = detectMovie(movieFiles[i], null, service, locale, strict); movie = (Movie) selectSearchResult(query, results, strict).get(0); if (movie != null) { diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index 64f0a58c..921b203d 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -148,7 +148,12 @@ def parseDate(path) { def detectSeriesName(files) { def names = MediaDetection.detectSeriesNames(files.findAll { it.isVideo() || it.isSubtitle() }) - return names == null || names.isEmpty() ? null : names[0] + return names == null || names.isEmpty() ? null : names.toList()[0] +} + +def detectMovie(movieFile, strict = false) { + def movies = MediaDetection.detectMovie(movieFile, OpenSubtitles, TheMovieDB, Locale.ENGLISH, strict) + return movies == null || movies.isEmpty() ? null : movies.toList()[0] } def similarity(o1, o2) { diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 19a582b3..ea289553 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -145,19 +145,29 @@ public class MediaDetection { } - public static Collection detectMovie(File movieFile, MovieIdentificationService service, Locale locale, boolean strict) throws Exception { + public static Collection detectMovie(File movieFile, MovieIdentificationService hashLookupService, MovieIdentificationService queryLookupService, Locale locale, boolean strict) throws Exception { Set options = new LinkedHashSet(); - // try to grep imdb id from nfo files - for (int imdbid : grepImdbIdFor(movieFile)) { - Movie movie = service.getMovieDescriptor(imdbid, locale); - - if (movie != null) { - options.add(movie); + if (hashLookupService != null) { + for (Movie movie : hashLookupService.getMovieDescriptors(new File[] { movieFile }, locale)) { + if (movie != null) { + options.add(movie); + } } } - if (!strict && options.isEmpty()) { + if (queryLookupService != null) { + // try to grep imdb id from nfo files + for (int imdbid : grepImdbIdFor(movieFile)) { + Movie movie = queryLookupService.getMovieDescriptor(imdbid, locale); + + if (movie != null) { + options.add(movie); + } + } + } + + if (queryLookupService != null && !strict && options.isEmpty()) { // search by file name or folder name Collection searchQueries = new LinkedHashSet(); searchQueries.add(getName(movieFile)); @@ -169,7 +179,7 @@ public class MediaDetection { final SimilarityMetric metric = new NameSimilarityMetric(); final Map probabilityMap = new LinkedHashMap(); for (String query : searchQueries) { - for (Movie movie : service.searchMovie(query, locale)) { + for (Movie movie : queryLookupService.searchMovie(query, locale)) { probabilityMap.put(movie, metric.getSimilarity(query, movie)); } } diff --git a/source/net/sourceforge/filebot/media/ReleaseInfo.java b/source/net/sourceforge/filebot/media/ReleaseInfo.java index 45920fb5..c9a40a73 100644 --- a/source/net/sourceforge/filebot/media/ReleaseInfo.java +++ b/source/net/sourceforge/filebot/media/ReleaseInfo.java @@ -133,7 +133,7 @@ public class ReleaseInfo { // fetch release group names online and try to update the data every other day protected final PatternResource releaseGroupResource = new PatternResource(getBundle(getClass().getName()).getString("url.release-groups")); - protected final PatternResource blacklistResource = new PatternResource(getBundle(getClass().getName()).getString("url.term-blacklist")); + protected final PatternResource blacklistResource = new PatternResource(getBundle(getClass().getName()).getString("url.query-blacklist")); protected static class PatternResource extends CachedResource { diff --git a/source/net/sourceforge/filebot/media/ReleaseInfo.properties b/source/net/sourceforge/filebot/media/ReleaseInfo.properties index 2a5f211e..b4ea3df9 100644 --- a/source/net/sourceforge/filebot/media/ReleaseInfo.properties +++ b/source/net/sourceforge/filebot/media/ReleaseInfo.properties @@ -8,4 +8,4 @@ pattern.video.format: DivX|Xvid|AVC|x264|h264|3ivx|mpeg|mpeg4|mp3|aac|ac3|2ch|6c url.release-groups: http://filebot.sourceforge.net/data/release-groups.txt # blacklisted terms that will be ignored -url.term-blacklist: http://filebot.sourceforge.net/data/term-blacklist.txt +url.term-blacklist: http://filebot.sourceforge.net/data/query-blacklist.txt diff --git a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java index 908296b9..bee8372f 100644 --- a/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/MovieHashMatcher.java @@ -153,7 +153,7 @@ class MovieHashMatcher implements AutoCompleteMatcher { } // auto-detect movie from nfo or folder / file name - options.addAll(detectMovie(movieFile, service, locale, false)); + options.addAll(detectMovie(movieFile, null, service, locale, false)); // allow manual user input if (options.isEmpty() || !autodetect) { diff --git a/website/data/term-blacklist.txt b/website/data/query-blacklist.txt similarity index 100% rename from website/data/term-blacklist.txt rename to website/data/query-blacklist.txt