Works like an absolute dream... when ran manually. When I start the script from my download manager, everything works except for the SD/HD detection.
Any clue as to why that would happen?
Also, my CD1/2 detection is not working. It just ignores and renames without it.
I execute:
filebot -trust-script -script email1.groovy c:\downloads\video
Any help appreciated.myFilename = (args)
myFile = myFilename
emailServer = "mail.server.co.za"
emailFrom = "[email protected]"
emailSeriesTo = "[email protected]"
emailMoviesTo = "[email protected]"
// filebot -script fn:sortivo <folder> --output path/to/folder [-non-strict]
// process only media files
def input = args.getFiles{ it.isVideo() || it.isSubtitle() }
// ignore clutter files
input = input.findAll{ !(it.path =~ /\b(?i:sample|trailer|extras|deleted.scenes|music.video|scrapbook)\b/) }
// print input fileset
input.each{ println "Input: $it" }
/*
* Move/Rename a mix of episodes and movies that are all in the same folder.
*/
def groups = input.groupBy{ f ->
def tvs = detectSeriesName(f)
def mov = (parseEpisodeNumber(f) || parseDate(f)) ? null : detectMovie(f, false) // skip movie detection if we can already tell it's an episode
println "$f.name [series: $tvs, movie: $mov]"
// DECIDE EPISODE VS MOVIE (IF NOT CLEAR)
if (tvs && mov) {
def norm = { s -> s.lower().space(' ') }
def fn = norm(f.nameWithoutExtension)
def sn = norm(tvs)
def mn = norm(mov.name)
if (parseEpisodeNumber(fn, true) || parseDate(fn) || (fn =~ sn && parseEpisodeNumber(fn.after(sn), false)) || fn.after(sn) =~ / - .+/ || f.dir.listFiles{ it.isVideo() && norm(it.name) =~ sn && it.name =~ /\b\d{1,3}\b/}.size() >= 10) {
println "Exclude Movie: $mov"
mov = null
} else if ((detectMovie(f, true) && fn =~ /(19|20)\d{2}/) || (fn =~ mn && !(fn.after(mn) =~ /\b\d{1,3}\b/))) {
println "Exclude Series: $tvs"
tvs = null
}
}
return [tvs:tvs, mov:mov]
}
groups.each{ group, files ->
// EPISODE MODE
if (group.tvs && !group.mov) {
def paths = rename(file:files, format:'C:/Share/Series/{sdhd}/{n} - {S00E00} - {t}', db:'TheTVDB')
paths.each {
def msg = "${it.name} has been added to the library"
execute("sendemail.exe", "-f", emailFrom, "-t", emailSeriesTo, "-s", emailServer, "-u", "TV SERIES: " + msg, "-m", msg)
}
}
// MOVIE MODE
if (group.mov && !group.tvs) {
def paths = rename(file:files, format:'C:/Share/Movies/{sdhd}/{n} ({y})/{n} ({y}){" CD$pi"}', db:'TheMovieDB')
paths.each {
def msg = "${it.name} has been added to the library"
execute("sendemail.exe", "-f", emailFrom, "-t", emailMoviesTo, "-s", emailServer, "-u", "MOVIE: " + msg, "-m", msg)
}
}
}