mirror of
https://github.com/mitb-archive/filebot
synced 2024-08-13 17:03:45 -04:00
Allow @file.groovy
syntax in Format Editor
and Preset Editor
(e.g. @/path/to/MyFormat.groovy
)
This commit is contained in:
parent
d6062c9423
commit
97aab5eab4
@ -1,11 +1,12 @@
|
|||||||
Next Release (4.8.6)
|
Next Release (4.8.6)
|
||||||
====================
|
====================
|
||||||
* Improved `SelectDialog` with thumbnails and tooltips
|
* Enhanced `Selection Dialog` with thumbnails and tooltips
|
||||||
* Added `{history}` binding for looking up the original file path of `{f}` (e.g. useful for `-exec` post-processing commands)
|
* Added `{history}` binding for looking up the original file path of `{f}` (e.g. useful for `-exec` post-processing commands)
|
||||||
* Evaluate `{closures}` automatically in `String.plus(Closure)` constructs (e.g. `{"[" + {n} + " " + {s00e00} + "]"}`)
|
* Evaluate `{closures}` automatically in `String.plus(Closure)` constructs (e.g. `{"[" + {n} + " " + {s00e00} + "]"}`)
|
||||||
* Ensure that `ActionPopup` is always displayed on top of the Windows Task Bar
|
* Ensure that `ActionPopup` is always displayed on top of the Windows Task Bar
|
||||||
* Improved `-mediainfo -exec` pipeline
|
* Improved `-mediainfo -exec` pipeline
|
||||||
* Added `-no-history` CLI option
|
* Added `-no-history` CLI option
|
||||||
|
* Allow `@file.groovy` syntax in `Format Editor` and `Preset Editor` (e.g. `@/path/to/MyFormat.groovy`)
|
||||||
* Allow `*.groovy` files as argument value for `--format`, `--filter` and `--file-filter` CLI options (e.g. `--format /path/to/MyFormat.groovy`)
|
* Allow `*.groovy` files as argument value for `--format`, `--filter` and `--file-filter` CLI options (e.g. `--format /path/to/MyFormat.groovy`)
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class ExpressionFilter {
|
|||||||
|
|
||||||
public ExpressionFilter(String expression) throws ScriptException {
|
public ExpressionFilter(String expression) throws ScriptException {
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
this.compiledExpression = new SecureCompiledScript(compileScriptlet(expression));
|
this.compiledExpression = new SecureCompiledScript(compileScriptlet(asExpression(expression)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExpression() {
|
public String getExpression() {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package net.filebot.format;
|
package net.filebot.format;
|
||||||
|
|
||||||
import static net.filebot.util.ExceptionUtilities.*;
|
import static net.filebot.util.ExceptionUtilities.*;
|
||||||
|
import static net.filebot.util.FileUtilities.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.text.FieldPosition;
|
import java.text.FieldPosition;
|
||||||
import java.text.Format;
|
import java.text.Format;
|
||||||
@ -39,7 +41,7 @@ public class ExpressionFormat extends Format {
|
|||||||
|
|
||||||
public ExpressionFormat(String expression) throws ScriptException {
|
public ExpressionFormat(String expression) throws ScriptException {
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
this.compilation = secure(compile(expression));
|
this.compilation = secure(compile(asExpression(expression)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExpression() {
|
public String getExpression() {
|
||||||
@ -253,6 +255,23 @@ public class ExpressionFormat extends Format {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static String asExpression(String s) {
|
||||||
|
// try as file path
|
||||||
|
if (s.startsWith("@") && s.endsWith(".groovy")) {
|
||||||
|
File f = new File(s.substring(1));
|
||||||
|
if (f.isFile()) {
|
||||||
|
try {
|
||||||
|
return readTextFile(f);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalArgumentException("Failed to read text file: " + f, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// or default to literal value
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
private static class Variable extends CompiledScript {
|
private static class Variable extends CompiledScript {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
Loading…
Reference in New Issue
Block a user