* update samples
This commit is contained in:
parent
02cd92d842
commit
5b839d1ca8
|
@ -1,9 +1,8 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.format;
|
package net.sourceforge.filebot.format;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilePermission;
|
import java.io.FilePermission;
|
||||||
|
import java.lang.management.ManagementPermission;
|
||||||
import java.net.SocketPermission;
|
import java.net.SocketPermission;
|
||||||
import java.security.AccessControlContext;
|
import java.security.AccessControlContext;
|
||||||
import java.security.AccessControlException;
|
import java.security.AccessControlException;
|
||||||
|
@ -22,7 +21,6 @@ import javax.script.ScriptException;
|
||||||
|
|
||||||
import net.sourceforge.tuned.ExceptionUtilities;
|
import net.sourceforge.tuned.ExceptionUtilities;
|
||||||
|
|
||||||
|
|
||||||
public class SecureCompiledScript extends CompiledScript {
|
public class SecureCompiledScript extends CompiledScript {
|
||||||
|
|
||||||
public static PermissionCollection getDefaultSandboxPermissions() {
|
public static PermissionCollection getDefaultSandboxPermissions() {
|
||||||
|
@ -35,6 +33,7 @@ public class SecureCompiledScript extends CompiledScript {
|
||||||
permissions.add(new PropertyPermission("*", "read"));
|
permissions.add(new PropertyPermission("*", "read"));
|
||||||
permissions.add(new RuntimePermission("getenv.*"));
|
permissions.add(new RuntimePermission("getenv.*"));
|
||||||
permissions.add(new RuntimePermission("getFileSystemAttributes"));
|
permissions.add(new RuntimePermission("getFileSystemAttributes"));
|
||||||
|
permissions.add(new ManagementPermission("monitor"));
|
||||||
|
|
||||||
// write permissions for temp and cache folders
|
// write permissions for temp and cache folders
|
||||||
try {
|
try {
|
||||||
|
@ -50,18 +49,15 @@ public class SecureCompiledScript extends CompiledScript {
|
||||||
private final CompiledScript compiledScript;
|
private final CompiledScript compiledScript;
|
||||||
private final AccessControlContext sandbox;
|
private final AccessControlContext sandbox;
|
||||||
|
|
||||||
|
|
||||||
public SecureCompiledScript(CompiledScript compiledScript) {
|
public SecureCompiledScript(CompiledScript compiledScript) {
|
||||||
this(compiledScript, new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, getDefaultSandboxPermissions()) }));
|
this(compiledScript, new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, getDefaultSandboxPermissions()) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SecureCompiledScript(CompiledScript compiledScript, AccessControlContext sandbox) {
|
public SecureCompiledScript(CompiledScript compiledScript, AccessControlContext sandbox) {
|
||||||
this.compiledScript = compiledScript;
|
this.compiledScript = compiledScript;
|
||||||
this.sandbox = sandbox;
|
this.sandbox = sandbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object eval(final ScriptContext context) throws ScriptException {
|
public Object eval(final ScriptContext context) throws ScriptException {
|
||||||
try {
|
try {
|
||||||
|
@ -86,7 +82,6 @@ public class SecureCompiledScript extends CompiledScript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScriptEngine getEngine() {
|
public ScriptEngine getEngine() {
|
||||||
return compiledScript.getEngine();
|
return compiledScript.getEngine();
|
||||||
|
|
|
@ -158,9 +158,9 @@
|
||||||
}</code></pre>Fetch subtitles, rename and compute checksums for all media folders in the file hierarchy.</div>
|
}</code></pre>Fetch subtitles, rename and compute checksums for all media folders in the file hierarchy.</div>
|
||||||
|
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<pre><code>[<span class="string">'E:/tvshows'</span>].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'tvrage'</span>) }
|
<pre><code>[<span class="string">'E:/TV Shows'</span> as File].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'TheTVDB'</span>) }
|
||||||
[<span class="string">'E:/anime'</span>].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'anidb'</span>) }
|
[<span class="string">'E:/Anime'</span> as File].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'AniDB'</span>) }
|
||||||
[<span class="string">'E:/movies'</span>].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'opensubtitles'</span>) }
|
[<span class="string">'E:/Movies'</span> as File].<span class="method">eachMediaFolder</span>{ <span class="method">rename</span>(<span class="property">folder</span>:it, <span class="property">db</span>:<span class="string">'TheMovieDB'</span>) }
|
||||||
</code></pre>Run rename on different folder hierarchies using different episode/movie datasources.</div>
|
</code></pre>Run rename on different folder hierarchies using different episode/movie datasources.</div>
|
||||||
|
|
||||||
<div class="description">
|
<div class="description">
|
||||||
|
|
Loading…
Reference in New Issue