diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index bd993508..eb13b07f 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -42,8 +42,12 @@ List.metaClass.mapByExtension = { mapByExtension(delegate) } import static com.sun.jna.Platform.*; def execute(String... args) { + if (!_args.trustScript) { + _log.severe("Execute failed: Script is not trusted"); + return -1 + } + def cmd = args.toList() - if (isWindows()) { cmd = ["cmd", "/c"] + cmd; } diff --git a/website/data/shell/mi.groovy b/website/data/shell/mi.groovy index 142028ec..c6758a7e 100644 --- a/website/data/shell/mi.groovy +++ b/website/data/shell/mi.groovy @@ -1,4 +1,4 @@ -// filebot -script "http://filebot.sourceforge.net/data/shell/mi.groovy" --format "{fn} [{resolution} {af} {vc} {ac}]" +// filebot -script "http://filebot.sourceforge.net/data/shell/mi.groovy" /* * Print media info for all video files using given or default format pattern @@ -6,4 +6,4 @@ args.getFiles() .findAll { it.isVideo() } .sort { a, b -> a.name.compareTo(b.name) } -.each { println getMediaInfo(file:it) } +.each { println getMediaInfo(file:it, format:"{fn} [{resolution} {af} {vc} {ac}]") } diff --git a/website/data/shell/mvrn.groovy b/website/data/shell/mvrn.groovy deleted file mode 100644 index bef745c0..00000000 --- a/website/data/shell/mvrn.groovy +++ /dev/null @@ -1,19 +0,0 @@ -// filebot -script "http://filebot.sourceforge.net/data/shell/mvrn.groovy" --format "{n}/{n} - {'S'+s.pad(2)}E{e.pad(2)} - {t}" --db thetvdb - -// sanity check -require { args.size == 2 && _args.format && _args.db } - -// handle arguments -def source = args[0] -def destination = args[1] + _args.format - -println 'Source Folder: ' + source -println 'Target Format: ' + destination.path - -/* - * Move/Rename videos from source folder into destination folder - */ -source.eachMediaFolder { - println 'Processing ' + it - rename(folder:it, format:destination.path, db:_args.db) -} diff --git a/website/data/shell/sorty.groovy b/website/data/shell/sorty.groovy index 31f10bb8..fc2e78cb 100644 --- a/website/data/shell/sorty.groovy +++ b/website/data/shell/sorty.groovy @@ -1,33 +1,39 @@ // Settings -def source = "X:/source" -def target = "Y:/target" +def episodeDir = "X:/in/TV" +def movieDir = "X:/in/Movies" -def episodeFormat = "{n}{'/Season '+s}/{episode}" -def movieFormat = "{movie}/{movie}" +def episodeFormat = "X:/out/TV/{n}{'/Season '+s}/{episode}" +def movieFormat = "X:/out/Movies/{movie}/{movie}" -def exclude(file) { - file =~ /\p{Punct}chunk/ +def exclude(f) { f =~ /\p{Punct}(chunk|part)/ } + +// run cmdline unrar / unzip (require -trust-script) +[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('zip') }.each { + execute("unzip", it.getAbsolutePath()); +} +[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('rar') }.each { + execute("unrar", "-x", it.getAbsolutePath()); } /* * Fetch subtitles and sort into folders */ -"$source/TV".eachMediaFolder() { dir -> +episodeDir.eachMediaFolder() { dir -> def files = dir.listFiles { !exclude(it) } // fetch subtitles files += getSubtitles(file:files) // sort episodes / subtitles - rename(file:files, db:'TVRage', format:"$target/TV/$episodeFormat") + rename(file:files, db:'TVRage', format:episodeFormat) } -"$source/Movies".eachMediaFolder() { dir -> +movieDir.eachMediaFolder() { dir -> def files = dir.listFiles { !exclude(it) } // fetch subtitles files += getSubtitles(file:files) // sort movies / subtitles - rename(file:files, db:'TheMovieDB', format:"$target/Movies/$movieFormat") + rename(file:files, db:'OpenSubtitles', format:movieFormat) } diff --git a/website/data/shell/src.groovy b/website/data/shell/src.groovy index 02c94737..b81d5bf7 100644 --- a/website/data/shell/src.groovy +++ b/website/data/shell/src.groovy @@ -5,6 +5,6 @@ */ args.eachMediaFolder { getMissingSubtitles(folder:it) - rename(folder:it) - compute(file:it.listFiles().findAll{ it.isVideo() }) + def renamedFiles = rename(folder:it) + compute(file:renamedFiles.findAll{ it.isVideo() }) }