1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-16 14:25:02 -05:00
filebot/website/scripts/sorty.groovy

66 lines
1.9 KiB
Groovy
Raw Normal View History

// PERSONALIZED SETTINGS
def episodeDir = "V:/in/TV"
def episodeFormat = "V:/out/TV/{n}{'/Season '+s}/{episode}"
def movieDir = "V:/in/Movies"
def movieFormat = "V:/out/Movies/{movie}/{movie}"
// XBMC ON LOCAL MACHINE
def xbmc = ['localhost'] // (use [] to not notify any XBMC instances about updates)
// ignore chunk, part, par and hidden files
def incomplete(f) { f.name =~ /[.]incomplete|[.]chunk|[.]par$|[.]dat$/ || f.isHidden() }
2011-11-29 04:00:18 -05:00
// extract completed multi-volume rar files
[episodeDir, movieDir].getFolders{ !it.hasFile{ incomplete(it) } && it.hasFile{ it =~ /[.]rar$/ } }.each{ dir ->
// extract all archives found in this folder
def paths = extract(folder:dir)
2011-12-01 22:15:33 -05:00
// delete original archive volumes after successful extraction
if (paths != null && !paths.isEmpty()) {
dir.listFiles{ it =~ /[.]rar$|[.]r[\d]+$/ }*.delete()
2011-11-30 00:23:43 -05:00
}
}
2011-12-01 22:15:33 -05:00
/*
* Fetch subtitles and sort into folders
*/
episodeDir.getFolders{ !it.hasFile{ incomplete(it) } && it.hasFile{ it.isVideo() } }.each{ dir ->
println "Processing $dir"
def files = dir.listFiles{ it.isVideo() }
// fetch subtitles
files += getSubtitles(file:files)
// sort episodes / subtitles
2011-11-29 04:00:18 -05:00
rename(file:files, db:'TVRage', format:episodeFormat)
}
movieDir.getFolders{ !it.hasFile{ incomplete(it) } && it.hasFile{ it.isVideo() } }.each{ dir ->
println "Processing $dir"
def files = dir.listFiles{ it.isVideo() }
// fetch subtitles
files += getSubtitles(file:files)
// sort movies / subtitles
2011-11-29 04:00:18 -05:00
rename(file:files, db:'OpenSubtitles', format:movieFormat)
}
// make XBMC scan for new content
xbmc.each { host ->
telnet(host, 9090) { writer, reader ->
// API call for latest XBMC release
def msg = '{"id":1,"method":"VideoLibrary.Scan","params":[],"jsonrpc":"2.0"}'
// API call for XBMC Dharma-Release or older
// def msg = '{"id":1,"method":"VideoLibrary.ScanForContent","params":[],"jsonrpc":"2.0"}'
writer.println(msg)
}
}