mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-25 01:08:52 -05:00
* just pick the first hash match if we can't auto-guess the best possible match (and make CLI behave like the GUI)
This commit is contained in:
parent
3081ec3885
commit
95ac5a4f9a
@ -720,7 +720,7 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
CLILogger.fine("Looking up subtitles by hash via " + service.getName());
|
CLILogger.fine("Looking up subtitles by hash via " + service.getName());
|
||||||
Map<File, SubtitleDescriptor> subtitles = lookupSubtitleByHash(service, language, remainingVideos);
|
Map<File, SubtitleDescriptor> subtitles = lookupSubtitleByHash(service, language, remainingVideos, false);
|
||||||
Map<File, File> downloads = downloadSubtitleBatch(service.getName(), subtitles, outputFormat, outputEncoding, naming);
|
Map<File, File> downloads = downloadSubtitleBatch(service.getName(), subtitles, outputFormat, outputEncoding, naming);
|
||||||
remainingVideos.removeAll(downloads.keySet());
|
remainingVideos.removeAll(downloads.keySet());
|
||||||
subtitleFiles.addAll(downloads.values());
|
subtitleFiles.addAll(downloads.values());
|
||||||
@ -870,12 +870,17 @@ public class CmdlineOperations implements CmdlineInterface {
|
|||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<File, SubtitleDescriptor> lookupSubtitleByHash(VideoHashSubtitleService service, Language language, Collection<File> videoFiles) throws Exception {
|
private Map<File, SubtitleDescriptor> lookupSubtitleByHash(VideoHashSubtitleService service, Language language, Collection<File> videoFiles, boolean strict) throws Exception {
|
||||||
Map<File, SubtitleDescriptor> subtitleByVideo = new TreeMap<File, SubtitleDescriptor>();
|
Map<File, SubtitleDescriptor> subtitleByVideo = new TreeMap<File, SubtitleDescriptor>();
|
||||||
|
|
||||||
for (Entry<File, List<SubtitleDescriptor>> it : service.getSubtitleList(videoFiles.toArray(new File[0]), language.getName()).entrySet()) {
|
for (Entry<File, List<SubtitleDescriptor>> 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)
|
// 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) {
|
if (bestMatch != null) {
|
||||||
CLILogger.finest(format("Matched [%s] to [%s] via hash", it.getKey().getName(), bestMatch.getName()));
|
CLILogger.finest(format("Matched [%s] to [%s] via hash", it.getKey().getName(), bestMatch.getName()));
|
||||||
|
Loading…
Reference in New Issue
Block a user