From 3457def9989e10fb3e68fdcc95a87e523d6900b2 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 30 Oct 2013 05:56:12 +0000 Subject: [PATCH] * improved error handling --- .../filebot/cli/CmdlineOperations.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) 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);