* update samples

This commit is contained in:
Reinhard Pointner 2013-10-17 07:11:32 +00:00
parent 02cd92d842
commit 5b839d1ca8
2 changed files with 18 additions and 23 deletions

View File

@ -1,9 +1,8 @@
package net.sourceforge.filebot.format;
import java.io.File;
import java.io.FilePermission;
import java.lang.management.ManagementPermission;
import java.net.SocketPermission;
import java.security.AccessControlContext;
import java.security.AccessControlException;
@ -22,7 +21,6 @@ import javax.script.ScriptException;
import net.sourceforge.tuned.ExceptionUtilities;
public class SecureCompiledScript extends CompiledScript {
public static PermissionCollection getDefaultSandboxPermissions() {
@ -35,6 +33,7 @@ public class SecureCompiledScript extends CompiledScript {
permissions.add(new PropertyPermission("*", "read"));
permissions.add(new RuntimePermission("getenv.*"));
permissions.add(new RuntimePermission("getFileSystemAttributes"));
permissions.add(new ManagementPermission("monitor"));
// write permissions for temp and cache folders
try {
@ -50,18 +49,15 @@ public class SecureCompiledScript extends CompiledScript {
private final CompiledScript compiledScript;
private final AccessControlContext sandbox;
public SecureCompiledScript(CompiledScript compiledScript) {
this(compiledScript, new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, getDefaultSandboxPermissions()) }));
}
public SecureCompiledScript(CompiledScript compiledScript, AccessControlContext sandbox) {
this.compiledScript = compiledScript;
this.sandbox = sandbox;
}
@Override
public Object eval(final ScriptContext context) throws ScriptException {
try {
@ -86,7 +82,6 @@ public class SecureCompiledScript extends CompiledScript {
}
}
@Override
public ScriptEngine getEngine() {
return compiledScript.getEngine();

View File

@ -158,9 +158,9 @@
}</code></pre>Fetch subtitles, rename and compute checksums for all media folders in the file hierarchy.</div>
<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>) }
[<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:/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>) }
<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> 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> 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>
<div class="description">