2011-11-29 01:03:41 -05:00
|
|
|
// Settings
|
2011-11-29 04:00:18 -05:00
|
|
|
def episodeDir = "X:/in/TV"
|
|
|
|
def movieDir = "X:/in/Movies"
|
2011-11-29 01:03:41 -05:00
|
|
|
|
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-29 01:03:41 -05:00
|
|
|
|
2011-11-29 04:00:18 -05:00
|
|
|
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());
|
2011-11-29 01:03:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetch subtitles and sort into folders
|
|
|
|
*/
|
2011-11-29 04:00:18 -05:00
|
|
|
episodeDir.eachMediaFolder() { dir ->
|
2011-11-29 01:03:41 -05:00
|
|
|
def files = dir.listFiles { !exclude(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 01:03:41 -05:00
|
|
|
}
|
|
|
|
|
2011-11-29 04:00:18 -05:00
|
|
|
movieDir.eachMediaFolder() { dir ->
|
2011-11-29 01:03:41 -05:00
|
|
|
def files = dir.listFiles { !exclude(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)
|
2011-11-29 01:03:41 -05:00
|
|
|
}
|