1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-25 01:08:52 -05:00

Fix --db option issues when using -get-subtitles

This commit is contained in:
Reinhard Pointner 2016-07-28 23:22:57 +08:00
parent d42371461e
commit 440a3bf923
2 changed files with 11 additions and 9 deletions

View File

@ -83,7 +83,7 @@ public class ArgumentProcessor {
} }
if (args.getSubtitles) { if (args.getSubtitles) {
files.addAll(cli.getMissingSubtitles(files, WebServices.OpenSubtitles.getName(), args.query, args.lang, args.output, args.encoding, args.format, !args.nonStrict)); files.addAll(cli.getMissingSubtitles(files, args.db, args.query, args.lang, args.output, args.encoding, args.format, !args.nonStrict));
} }
if (args.rename) { if (args.rename) {

View File

@ -38,8 +38,8 @@ import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.regex.Pattern;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -670,13 +670,15 @@ public class CmdlineOperations implements CmdlineInterface {
@Override @Override
public List<File> getSubtitles(Collection<File> files, String db, String query, String languageName, String output, String csn, String format, boolean strict) throws Exception { public List<File> getSubtitles(Collection<File> files, String db, String query, String languageName, String output, String csn, String format, boolean strict) throws Exception {
final Language language = getLanguage(languageName); Language language = getLanguage(languageName);
final Pattern databaseFilter = (db != null) ? Pattern.compile(db, Pattern.CASE_INSENSITIVE) : null; SubtitleNaming naming = getSubtitleNaming(format);
final SubtitleNaming naming = getSubtitleNaming(format);
// use all or only selected subtitle services
Predicate<Datasource> serviceFilter = service -> db == null ? true : db.contains(service.getName()) || db.contains(service.getIdentifier());
// when rewriting subtitles to target format an encoding must be defined, default to UTF-8 // when rewriting subtitles to target format an encoding must be defined, default to UTF-8
final Charset outputEncoding = csn != null ? Charset.forName(csn) : output != null ? UTF_8 : null; Charset outputEncoding = csn != null ? Charset.forName(csn) : output != null ? UTF_8 : null;
final SubtitleFormat outputFormat = (output != null) ? getSubtitleFormatByName(output) : null; SubtitleFormat outputFormat = output != null ? getSubtitleFormatByName(output) : null;
// ignore anything that is not a video // ignore anything that is not a video
files = filter(files, VIDEO_FILES); files = filter(files, VIDEO_FILES);
@ -697,7 +699,7 @@ public class CmdlineOperations implements CmdlineInterface {
// lookup subtitles by hash // lookup subtitles by hash
for (VideoHashSubtitleService service : getVideoHashSubtitleServices(language.getLocale())) { for (VideoHashSubtitleService service : getVideoHashSubtitleServices(language.getLocale())) {
if (remainingVideos.isEmpty() || (databaseFilter != null && !databaseFilter.matcher(service.getName()).matches()) || !requireLogin(service)) { if (remainingVideos.isEmpty() || !serviceFilter.test(service) || !requireLogin(service)) {
continue; continue;
} }
@ -713,7 +715,7 @@ public class CmdlineOperations implements CmdlineInterface {
} }
for (SubtitleProvider service : getSubtitleProviders()) { for (SubtitleProvider service : getSubtitleProviders()) {
if (strict || remainingVideos.isEmpty() || (databaseFilter != null && !databaseFilter.matcher(service.getName()).matches()) || !requireLogin(service)) { if (strict || remainingVideos.isEmpty() || !serviceFilter.test(service) || !requireLogin(service)) {
continue; continue;
} }