mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-16 06:15:02 -05:00
* ignore empty query
This commit is contained in:
parent
f1f56a5fd1
commit
c22d867453
@ -3,6 +3,7 @@ package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.sourceforge.filebot.web.OpenSubtitlesHasher.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigInteger;
|
||||
@ -106,16 +107,18 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
|
||||
List<Query> queryList = new ArrayList<Query>(files.length);
|
||||
|
||||
for (File file : files) {
|
||||
String movieHash = OpenSubtitlesHasher.computeHash(file);
|
||||
|
||||
// add query
|
||||
if (file.length() > HASH_CHUNK_SIZE) {
|
||||
String movieHash = computeHash(file);
|
||||
queryList.add(Query.forHash(movieHash, file.length(), languageFilter));
|
||||
hashMap.put(movieHash, file);
|
||||
}
|
||||
|
||||
// prepare result map
|
||||
hashMap.put(movieHash, file);
|
||||
resultMap.put(file, new LinkedList<SubtitleDescriptor>());
|
||||
}
|
||||
|
||||
if (queryList.size() > 0) {
|
||||
// require login
|
||||
login();
|
||||
|
||||
@ -127,6 +130,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
|
||||
// add subtitle
|
||||
resultMap.get(file).add(subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
@ -180,12 +184,12 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
|
||||
Map<String, Integer> indexMap = new HashMap<String, Integer>(movieFiles.length);
|
||||
|
||||
for (int i = 0; i < movieFiles.length; i++) {
|
||||
String hash = OpenSubtitlesHasher.computeHash(movieFiles[i]);
|
||||
|
||||
// remember original index
|
||||
indexMap.put(hash, i);
|
||||
if (movieFiles[i].length() > HASH_CHUNK_SIZE) {
|
||||
indexMap.put(computeHash(movieFiles[i]), i); // remember original index
|
||||
}
|
||||
}
|
||||
|
||||
if (indexMap.size() > 0) {
|
||||
// require login
|
||||
login();
|
||||
|
||||
@ -194,6 +198,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
|
||||
int index = indexMap.get(entry.getKey());
|
||||
result[index] = entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public final class OpenSubtitlesHasher {
|
||||
/**
|
||||
* Size of the chunks that will be hashed in bytes (64 KB)
|
||||
*/
|
||||
private static final int HASH_CHUNK_SIZE = 64 * 1024;
|
||||
public static final int HASH_CHUNK_SIZE = 64 * 1024;
|
||||
|
||||
|
||||
public static String computeHash(File file) throws IOException {
|
||||
|
Loading…
Reference in New Issue
Block a user