1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-11 03:45:06 -05:00
filebot/website/data/shell/sorty.groovy

49 lines
1.4 KiB
Groovy
Raw Normal View History

// Settings
2011-11-29 04:00:18 -05:00
def episodeDir = "X:/in/TV"
def movieDir = "X:/in/Movies"
2011-11-29 04:00:18 -05:00
def episodeFormat = "X:/out/TV/{n}{'/Season '+s}/{episode}"
def movieFormat = "X:/out/Movies/{movie}/{movie}"
2011-11-30 00:23:43 -05:00
def incomplete(f) { f =~ /[.]chunk|[.]part$/ }
2011-11-29 04:00:18 -05:00
2011-11-30 00:23:43 -05:00
// 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
*/
2011-11-29 04:00:18 -05:00
episodeDir.eachMediaFolder() { dir ->
2011-11-30 00:23:43 -05:00
def files = dir.listFiles { !incomplete(it) }
// fetch subtitles
files += getSubtitles(file:files)
// sort episodes / subtitles
2011-11-29 04:00:18 -05:00
rename(file:files, db:'TVRage', format:episodeFormat)
}
2011-11-29 04:00:18 -05:00
movieDir.eachMediaFolder() { dir ->
2011-11-30 00:23:43 -05:00
def files = dir.listFiles { !incomplete(it) }
// fetch subtitles
files += getSubtitles(file:files)
// sort movies / subtitles
2011-11-29 04:00:18 -05:00
rename(file:files, db:'OpenSubtitles', format:movieFormat)
}