diff --git a/source/net/sourceforge/filebot/cli/CmdlineOperations.java b/source/net/sourceforge/filebot/cli/CmdlineOperations.java index 9af49b17..d6e52101 100644 --- a/source/net/sourceforge/filebot/cli/CmdlineOperations.java +++ b/source/net/sourceforge/filebot/cli/CmdlineOperations.java @@ -159,16 +159,29 @@ public class CmdlineOperations implements CmdlineInterface { } for (List batch : batchSets) { + Collection seriesNames; + // auto-detect series name if not given - Collection seriesNames = (query == null) ? detectSeriesQuery(batch, locale) : asList(query.split("[|]")); + if (query == null) { + // detect series name by common word sequence + seriesNames = detectSeriesNames(batch, locale); + CLILogger.config("Auto-detected query: " + seriesNames); + } else { + // use --q option + seriesNames = asList(query.split("[|]")); + } if (strict && seriesNames.size() > 1) { throw new Exception("Handling multiple shows requires non-strict matching"); } + if (seriesNames.size() == 0) { + CLILogger.warning("Failed to detect query for files: " + batch); + continue; + } + // fetch episode data Collection episodes = fetchEpisodeSet(db, seriesNames, sortOrder, locale, strict); - if (episodes.size() == 0) { CLILogger.warning("Failed to fetch episode data: " + seriesNames); continue; @@ -821,18 +834,6 @@ public class CmdlineOperations implements CmdlineInterface { return emptyMap(); } - private List detectSeriesQuery(Collection mediaFiles, Locale locale) throws Exception { - // detect series name by common word sequence - List names = detectSeriesNames(mediaFiles, locale); - - if (names.isEmpty()) { - throw new Exception("Failed to auto-detect query"); - } - - CLILogger.config("Auto-detected query: " + names); - return names; - } - private List applyExpressionFilter(Collection input, ExpressionFilter filter) throws Exception { if (filter == null) { return new ArrayList(input);