From 2bf8270b171518ea86019249a283ae04761a232c Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 30 Nov 2011 05:23:43 +0000 Subject: [PATCH] * refactoring --- .../filebot/cli/ScriptShell.lib.groovy | 4 -- source/net/sourceforge/filebot/media.types | 49 ++++++------------- website/data/shell/sorty.groovy | 24 ++++++--- 3 files changed, 34 insertions(+), 43 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index 7f7e2ead..6cbff0b5 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -62,10 +62,6 @@ def execute(String... args) { } -// Script helper -def require(cond) { if (!cond()) throw new Exception('Require failed') } - - // CLI bindings def rename(args) { args = _defaults(args) _guarded { _cli.rename(_files(args), args.query, args.format, args.db, args.lang, args.strict) } diff --git a/source/net/sourceforge/filebot/media.types b/source/net/sourceforge/filebot/media.types index a58b1a34..726bfd6f 100644 --- a/source/net/sourceforge/filebot/media.types +++ b/source/net/sourceforge/filebot/media.types @@ -2,144 +2,127 @@ - torrent tor - list txt - nfo - - sfv - md5 - sha1 sha - + + + + zip + + + rar + + + gzip + gz + + + tar + - mp3 - mp4 m4a - flac - wma - ogg - - avi - mkv - ogm - mp4 m4v - mov - divx - mpg mpeg ts - wmv - flv - rm rmvb - tivo - wtv - srt - sub - sub - ssa ass - smi sami - sub idx - + diff --git a/website/data/shell/sorty.groovy b/website/data/shell/sorty.groovy index 829a5fce..d7b12269 100644 --- a/website/data/shell/sorty.groovy +++ b/website/data/shell/sorty.groovy @@ -5,18 +5,30 @@ def movieDir = "X:/in/Movies" def episodeFormat = "X:/out/TV/{n}{'/Season '+s}/{episode}" def movieFormat = "X:/out/Movies/{movie}/{movie}" -def exclude(f) { f =~ /\p{Punct}(chunk|part)/ } +def incomplete(f) { f =~ /[.]chunk|[.]part$/ } -// run cmdline unrar (require -trust-script) -[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('rar') }.each { - execute("unrar", "x", "-y", it.getAbsolutePath(), it.getPathWithoutExtension() + "/") +// run cmdline unrar (require -trust-script) on multi-volume rar files (foo.part1.rar, foo.part2.rar, ...) +[episodeDir, movieDir].getFiles().findAll{ it =~ /[.]part01[.]rar$/ }.each { rarP1 -> + // extract name from name.part01.rar + def name = rarP1.getName()[0 .. -12]; + + // find all volumes of the same name + def volumes = rarP1.getParentFile().listFiles{ it.getName().startsWith(name) && it =~ /[.]part\d{2}[.]rar/ } + + // find all incomplete volumes + def incomplete = volumes.findAll{ incomplete(it) } + + // all volumes complete, call unrar on first volume + if (incomplete.isEmpty()) { + execute("unrar", "x", "-y", "-p-", rarP1.getAbsolutePath(), rarP1.getPathWithoutExtension() + "/") + } } /* * Fetch subtitles and sort into folders */ episodeDir.eachMediaFolder() { dir -> - def files = dir.listFiles { !exclude(it) } + def files = dir.listFiles { !incomplete(it) } // fetch subtitles files += getSubtitles(file:files) @@ -26,7 +38,7 @@ episodeDir.eachMediaFolder() { dir -> } movieDir.eachMediaFolder() { dir -> - def files = dir.listFiles { !exclude(it) } + def files = dir.listFiles { !incomplete(it) } // fetch subtitles files += getSubtitles(file:files)