From e08e4613699a11e9d7dbb870c9fd5a7601c960ef Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 24 Feb 2016 02:47:42 +0000 Subject: [PATCH] Improved default behaviour --- source/net/filebot/cli/CmdlineOperations.java | 2 +- .../net/filebot/cli/ScriptShellBaseClass.java | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/source/net/filebot/cli/CmdlineOperations.java b/source/net/filebot/cli/CmdlineOperations.java index 6b7ef492..35659026 100644 --- a/source/net/filebot/cli/CmdlineOperations.java +++ b/source/net/filebot/cli/CmdlineOperations.java @@ -1102,7 +1102,7 @@ public class CmdlineOperations implements CmdlineInterface { } } - ExpressionFormat formatter = new ExpressionFormat(format != null && format.length() > 0 ? format : "{fn} [{resolution} {af} {vc} {ac}]"); + ExpressionFormat formatter = new ExpressionFormat(format != null && format.length() > 0 ? format : "{fn} [{resolution} {vc} {channels} {ac} {minutes+'m'}]"); List output = new ArrayList(); for (File file : files) { String line = formatter.format(new MediaBindingBean(readMetaInfo(file), file, null)); diff --git a/source/net/filebot/cli/ScriptShellBaseClass.java b/source/net/filebot/cli/ScriptShellBaseClass.java index aec3160b..745c7c10 100644 --- a/source/net/filebot/cli/ScriptShellBaseClass.java +++ b/source/net/filebot/cli/ScriptShellBaseClass.java @@ -17,6 +17,7 @@ import java.io.PrintStream; import java.io.StringWriter; import java.net.Socket; import java.util.ArrayList; +import java.util.Collection; import java.util.Date; import java.util.EnumMap; import java.util.EnumSet; @@ -418,7 +419,15 @@ public abstract class ScriptShellBaseClass extends Script { } } - public String getMediaInfo(Map parameters) throws Exception { + public String getMediaInfo(File file, String format) throws Exception { + return cli.getMediaInfo(singleton(file), format, null).get(0); // explicitly ignore the --filter option + } + + public List getMediaInfo(Collection files, String format) throws Exception { + return cli.getMediaInfo(FileUtilities.asFileList(files), format, null); // explicitly ignore the --filter option + } + + public Object getMediaInfo(Map parameters) throws Exception { List input = getInputFileList(parameters); if (input == null || input.isEmpty()) { return null; @@ -427,8 +436,12 @@ public abstract class ScriptShellBaseClass extends Script { Map option = getDefaultOptions(parameters); synchronized (cli) { try { - List lines = cli.getMediaInfo(singleton(input.get(0)), asString(option.get(Option.format)), null); // explicitly ignore the --filter option if any - return lines.get(0); + List lines = cli.getMediaInfo(input, asString(option.get(Option.format)), asString(option.get(Option.filter))); + if (parameters.containsKey("file") && !(parameters.get("file") instanceof Collection)) { + return lines.get(0); // HACK for script backwards compatibility + } else { + return lines; + } } catch (Exception e) { printException(e, false); return null;