diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index eb9263bc..4fc6d93c 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -720,7 +720,7 @@ public class CmdlineOperations implements CmdlineInterface { try { CLILogger.fine("Looking up subtitles by hash via " + service.getName()); - Map subtitles = lookupSubtitleByHash(service, language, remainingVideos); + Map subtitles = lookupSubtitleByHash(service, language, remainingVideos, false); Map downloads = downloadSubtitleBatch(service.getName(), subtitles, outputFormat, outputEncoding, naming); remainingVideos.removeAll(downloads.keySet()); subtitleFiles.addAll(downloads.values()); @@ -870,12 +870,17 @@ public class CmdlineOperations implements CmdlineInterface { return destination; } - private Map lookupSubtitleByHash(VideoHashSubtitleService service, Language language, Collection videoFiles) throws Exception { + private Map lookupSubtitleByHash(VideoHashSubtitleService service, Language language, Collection videoFiles, boolean strict) throws Exception { Map subtitleByVideo = new TreeMap(); for (Entry> it : service.getSubtitleList(videoFiles.toArray(new File[0]), language.getName()).entrySet()) { // guess best hash match (default order is open bad due to invalid hash links) - SubtitleDescriptor bestMatch = getBestMatch(it.getKey(), it.getValue(), false); + SubtitleDescriptor bestMatch = getBestMatch(it.getKey(), it.getValue(), strict); + + // if we can't guess the best one, just pick the first one, since all hash matches should good (ideally) + if (bestMatch == null && !strict && it.getValue().size() > 0) { + bestMatch = it.getValue().get(0); + } if (bestMatch != null) { CLILogger.finest(format("Matched [%s] to [%s] via hash", it.getKey().getName(), bestMatch.getName()));