From 55491a137d70e69bdd9c208eb06c90b22b85f37f Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 26 Feb 2016 13:14:17 +0000 Subject: [PATCH] Presume that OpenSubtitles hash matches are being polluted by BSPlayer and never just trust hash matches @see https://www.filebot.net/forums/viewtopic.php?f=6&t=3452#p19190 --- source/net/filebot/cli/CmdlineOperations.java | 5 ----- source/net/filebot/subtitle/SubtitleUtilities.java | 3 ++- source/net/filebot/web/OpenSubtitlesClient.java | 11 ++++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index 1df2d458..1e3f739c 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -875,11 +875,6 @@ public class CmdlineOperations implements CmdlineInterface { // guess best hash match (default order is open bad due to invalid hash links) 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())); subtitleByVideo.put(it.getKey(), bestMatch); diff --git a/source/net/filebot/subtitle/SubtitleUtilities.java b/source/net/filebot/subtitle/SubtitleUtilities.java index 219319a0..09d31571 100644 --- a/source/net/filebot/subtitle/SubtitleUtilities.java +++ b/source/net/filebot/subtitle/SubtitleUtilities.java @@ -159,8 +159,9 @@ public final class SubtitleUtilities { } // allow early abort - if (Thread.interrupted()) + if (Thread.interrupted()) { throw new InterruptedException(); + } // files by possible subtitles matches for (File file : files) { diff --git a/source/net/filebot/web/OpenSubtitlesClient.java b/source/net/filebot/web/OpenSubtitlesClient.java index 3a982901..f4d075b8 100644 --- a/source/net/filebot/web/OpenSubtitlesClient.java +++ b/source/net/filebot/web/OpenSubtitlesClient.java @@ -214,12 +214,13 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS List hashQueryList = new ArrayList(files.length); for (File file : files) { - // add hash query - if (file.length() > HASH_CHUNK_SIZE) { - String movieHash = computeHash(file); - Query query = Query.forHash(movieHash, file.length(), languageFilter); + Query query = file.length() > HASH_CHUNK_SIZE ? Query.forHash(computeHash(file), file.length(), languageFilter) : null; - // check hash + // DEBUG + // query = Query.forHash("b4a91d8384a92269", 1178926184, languageFilter); + + // add hash query + if (query != null) { List cachedResults = getCache().getSubtitleDescriptorList(query); if (cachedResults == null) { hashQueryList.add(query);