help with script needed

Any questions? Need some help?
Post Reply
faniedry
Posts: 6
Joined: 30 Jan 2013, 08:37

help with script needed

Post by faniedry » 31 Jan 2013, 12:31

I've grabbed this script below from the forums, and modified to fit my needs.

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
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)
}
}
}
Any help appreciated.

User avatar
rednoah
The Source
Posts: 18538
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: help with script needed

Post by rednoah » 31 Jan 2013, 12:59

1.
You have Java 32 and 64 bit installed. Cmdline is using the right one but your download manager is probably running the 64 bit filebot with 32 bit java.

2.
{pi} is worked out by counting matches in the same batch, not any pattern in the filename. If u want that u can use {fn.match(...)}
:idea: Please read the FAQ and How to Request Help.

faniedry
Posts: 6
Joined: 30 Jan 2013, 08:37

Re: help with script needed

Post by faniedry » 31 Jan 2013, 13:39

I'm running a 32-bit windows.

it doesn't look like i have 2 or more than 1 java installed. Can i even install anything 64-bit on a 32-bit os?

User avatar
rednoah
The Source
Posts: 18538
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: help with script needed

Post by rednoah » 31 Jan 2013, 14:08

Then arch shouldn't be a problem when loading mediainfo (which is required for the {sdhd} bindings). I guess you'll have to experiment what might be different when your download manager is running cmdline programs, that makes it not work.
:idea: Please read the FAQ and How to Request Help.

faniedry
Posts: 6
Joined: 30 Jan 2013, 08:37

[Solved] Re: help with script needed

Post by faniedry » 01 Feb 2013, 20:06

Upgrading Java seems to have sorted out my problem.

faniedry
Posts: 6
Joined: 30 Jan 2013, 08:37

Re: help with script needed

Post by faniedry » 05 Feb 2013, 11:42

Think I finally have it covered. Works as expected now.

Rename for movies:

Code: Select all

rename(file:files, format:'C:/Share/Movies/{sdhd}/{n} ({y})/{n} ({y}) {fn.match(/(?i)cd+[0-9]/).toUpperCase()}{fn.match(/(?i)part +[0-9]of[0-9]/).toLowerCase()}', db:'TheMovieDB')
Rename for series:

Code: Select all

rename(file:files, format:'C:/Share/Series/{sdhd}/{n} - {S00E00} - {t}', db:'TheTVDB')
Thanks for all the quick help.

Post Reply