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

37 lines
963 B
Groovy

// Settings
def episodeDir = "X:/in/TV"
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)/ }
// run cmdline unrar (require -trust-script)
[episodeDir, movieDir].getFiles().findAll{ !exclude(it) && it.hasExtension('rar') }.each {
execute("unrar", "x", "-y", it.getAbsolutePath(), it.getPathWithoutExtension() + "/")
}
/*
* Fetch subtitles and sort into folders
*/
episodeDir.eachMediaFolder() { dir ->
def files = dir.listFiles { !exclude(it) }
// fetch subtitles
files += getSubtitles(file:files)
// sort episodes / subtitles
rename(file:files, db:'TVRage', format:episodeFormat)
}
movieDir.eachMediaFolder() { dir ->
def files = dir.listFiles { !exclude(it) }
// fetch subtitles
files += getSubtitles(file:files)
// sort movies / subtitles
rename(file:files, db:'OpenSubtitles', format:movieFormat)
}