I'm quite new to this.
Have been looking through samples and tried to "parse" scripts such as "http://pastebin.com/0RDGp146" and the like.
I have a quite simple need but for the life of me i cannot change the script to do it.
I'd really appreciate some help:)
Basically, i would like to keep the original name of the file being unpacked (or better yet, have it be the name of the archive - but these are normally the same) This because IF theres no hash match on opensubtitles, I can then easily find the right subtitle manually (in Kodi/XBMC).
I get downloads using flexget, sorted as
/TV/series name/Season S01/name of rar.rar
Basically, I just need the unpacking of the rar archive in that same dir (Like I would get by
Code: Select all
filebot -extract "path_to_archive" --output ""
With the code below, I keep having one of two issues:
1) I have to move the file and therefore need to give it a name (which incidentally i can't make identical to the original name) or
2) i get the archive with the right name, but in a subfolder to the folder it should be in.
Any help on either working with the code below or something else I'd appreciate very much:)
Code: Select all
// PERSONALIZED SETTINGS
def episodeDir = '''/share/Disk 4/TV_OLD''' as File
def episodeFormat = '''/share/Disk 4/NEW_TV'''
def movieDir = '''/share/Disk 2/Film''' as File
def movieFormat = '''{n} ({y})/{n} ({y}){" CD$pi"}'''
// XBMC ON LOCAL MACHINE
//def xbmc = ’10.0.0.38’ // (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$/ }
// 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)
// delete original archive volumes after successful extraction
if (paths != null && !paths.isEmpty()) {
dir.listFiles{ it =~ /[.]rar$|[.]r[\d]+$/ }*.delete()
}
}
/*
* 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
rename(file:files, db:'TheTVDB', 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
rename(file:files, db:'TheMovieDB', 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)
}
}