HELP - Filebot Groovy Script How To?

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Savvy
Posts: 16
Joined: 07 May 2012, 07:42

HELP - Filebot Groovy Script How To?

Post by Savvy » 07 May 2012, 07:51

Hi All,

I have been using filebot for some time now and have never dived into anything more complex than its renaming function. But now that I’ve come across the scripting functionality I would like to try and add to the community.

I'm not a coder / developer but know a little about most IT areas...I have downloaded some tutorials in the hopes of learning the groovy way :)

Now, my first question is a simple one.. Well for you guys anyways. Where do I place this code? And how do I get Filebot to point at it?
For example:

http://filebot.sourceforge.net/forums/v ... hp?f=4&t=5

The utorrent integration script… if I copy the following into the utorrent ‘run program’ function:

filebot -script "fn:utorrent-postprocess" --output "X:/media" --action copy --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=%D" "-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"

Then where do I paste the groovy code?

Regards :)

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 07 May 2012, 08:56

fn:name scheme is just for predefined the scripts that are online. Just specify a path like in the scripting help. e.g. filebot -script "X:/foobar.groovy"
:idea: Please read the FAQ and How to Request Help.

Savvy
Posts: 16
Joined: 07 May 2012, 07:42

Re: HELP - Filebot Groovy Script How To?

Post by Savvy » 07 May 2012, 23:03

Thanks rednoah,

just to clarify, all those scripts in http://filebot.sourceforge.net/forums/v ... hp?f=4&t=5, filebot will lookup online and run automatically?

As i've been trying to get the µTorrent Integration script to work but all it does is download subs, it doesn't rename the episodes.

Would this mean i must save the script locally and edit it to my requirements before it will actually work?

Sorry again for the noob Q's.

Sav

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 08 May 2012, 00:38

That one should work out of the box. What's the command+parameter you call it with? Online or local script doesn't make a difference.
:idea: Please read the FAQ and How to Request Help.

Savvy
Posts: 16
Joined: 07 May 2012, 07:42

Re: HELP - Filebot Groovy Script How To?

Post by Savvy » 09 May 2012, 21:48

sorry rednoah, not too sure what you mean by that. i've simply just added the following into the run program tool:

filebot -script "fn:utorrent-postprocess" --output "X:/media" --action copy --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=%D" "-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 09 May 2012, 23:15

Guess what happens if FileBot can't move things to X:/media? You need to set --output to somewhere that exists obviously.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 09 May 2012, 23:51

I've never posted on a forum before, so here goes.

I think this program looks really awesome, I've been reading about it for quite some time and finally decided to take the plunge and try it. I thought I'd try it with Utorrent first and see how it goes before I try and unleash it on my collection of videos. I'm on Vista and just checked java, apparently version 6 update 31. I modified the naming schemes for movies and tv to the way I want them from the site. I downloaded a file in Utorrent with the action set to test to see how it would work. Nothing seemed to happen at all. It shows up in the Utorrent logger, but nothing else shows any sign of anything happening. So I figured I'd go for it and try it with move instead, still nothing. I saw your last post and realized the folder I wanted them to move to didn't exist, but I thought it would just create it on its own. Instead I made the folder and tried again, still nothing. Is there a filebot log I can check somewhere? Or make it output to a text file to show what it's trying or something?

I tried calling it by copying this into Utorrent's run this program when a torrent finishes:
filebot -script "C:\Program Files\FileBot\my-utorrent-postprocess.groovy" --output "C:\Users\Scott\Downloads\Done\Video Staging" --action move --conflict skip -non-strict -trust-script -Xxbmc=Apple-TV "-Xut_dir=%D" "-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"

I went with a local file, because I like having more control over my files and naming, just hopefully I didn't mess something up, I don't think so, as I tried to be very careful.

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 10 May 2012, 01:22

Folder are created automatically but of course a drive is not. So in your case it should work.

Just copy the log from utorrent and run that command in the cmdline manually. That way you'll see the output and what's happening.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 10 May 2012, 02:30

So I had to change to the program directory first, before I could get anything to happen. I guess that means I need to add the whole path to filebot for it to run properly?

It actually did something this time, but gave me an error.

"MultipleCompilationErrorsException: startup failed:
Script3.groovy: 1: unexpected char: 0x0 @ line 1, column 4.
??/ / f i l e b o t - s c r i p t " f n : u t o r r e n t - p o s t p r
o c e s s " - - o u t p u t " X : / m e d i a " - - a c t i o n c o p y
- - c o n f l i c t o v e r r i d e - n o n - s t r i c t - t r u s t -
s c r i p t - X x b m c = l o c a l h o s t " - X u t _ d i r = % D " " -
X u t _ f i l e = % F " " - X u t _ l a b e l = % L " " - X u t _ s t a t e
= % S " " - X u t _ k i n d = % K "
^

1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script3.groovy: 1: unexpected char: 0x0 @ line 1, column 4.
??/ / f i l e b o t - s c r i p t " f n : u t o r r e n t - p o s t p r
o c e s s " - - o u t p u t " X : / m e d i a " - - a c t i o n c o p y
- - c o n f l i c t o v e r r i d e - n o n - s t r i c t - t r u s t -
s c r i p t - X x b m c = l o c a l h o s t " - X u t _ d i r = % D " " -
X u t _ f i l e = % F " " - X u t _ l a b e l = % L " " - X u t _ s t a t e
= % S " " - X u t _ k i n d = % K "
^

1 error

at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)"

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 10 May 2012, 03:42

Whole path? Relative/Absolute paths both work. Depends on how utorrent sets the working directory. From cmdline relative paths should all work as expected.

I don't know what you're using to edit your code. But don't use it. It's adding a special byte marker to identify the filetype at the beginning of the file (see ??) that breaks the syntax. You can't see it when you edit the script but it'll choke filebot on the first character which is invalid. FileBot expects scripts to be UTF-8 encoded plain/text files. Just use notepad2 or something to edit the script.

EDIT: Long story short, use a proper editor!
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 10 May 2012, 13:59

Ok, I am muddling my way through here, learning slowly.
I am using Notepad and set it to UTF-8 now and got past that error. Got past 2 more errors already as well, not being able to call the script from the command line because of a space and then having a slash the wrong way in my script.

Now my latest error is from some code I copied and pasted, so I don't know enough to fix it.

C:\Program Files\FileBot>C:\Program Files\FileBot\filebot -script "C:\Program Fi
les\FileBot\my-utorrent-postprocess.groovy" --output "C:\Users\Scott\Downloads\D
one\Video Staging" --action move --conflict skip -non-strict -trust-script -Xxbm
c=Apple-TV "-Xut_dir=%D" "-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_ki
nd=%K"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\FileBot>filebot -script "C:\Program Files\FileBot\my-utorrent-p
ostprocess.groovy" --output "C:\Users\Scott\Downloads\Done\Video Staging" --acti
on move --conflict skip -non-strict -trust-script -Xxbmc=Apple-TV "-Xut_dir=%D"
"-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"
MultipleCompilationErrorsException: startup failed:
Script3.groovy: 23: unexpected char: '\' @ line 23, column 12.
include("C:\Program Files\FileBot\lib\xbmc")
^

1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script3.groovy: 23: unexpected char: '\' @ line 23, column 12.
include("C:\Program Files\FileBot\lib\xbmc")
^

1 error

at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)

C:\Program Files\FileBot>filebot -script "C:\Program Files\FileBot\my-utorrent-p
ostprocess.groovy" --output "C:\Users\Scott\Downloads\Done\Video Staging" --acti
on move --conflict skip -non-strict -trust-script -Xxbmc=Apple-TV "-Xut_dir=%D"
"-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"
MultipleCompilationErrorsException: startup failed:
Script3.groovy: 51: expecting ')', found ' : n =~ /^[Aa] / ? n[2..-1]+' @ line 5
1, column 85.
~ /^[Tt]he / ? n[4..-1]+', The' : n =~ /
^

1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script3.groovy: 51: expecting ')', found ' : n =~ /^[Aa] / ? n[2..-1]+' @ line 5
1, column 85.
~ /^[Tt]he / ? n[4..-1]+', The' : n =~ /
^

1 error

at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)



Maybe I should be trying to post the whole script and that would be easier.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 10 May 2012, 14:10

Here is a better look at the part it is having a problem with:

Code: Select all

{(n =~ /^[Tt]he / ? n[4..-1]+', The' : n =~ /^[Aa] / ? n[2..-1]+', A' : n).replace(':',' -').upperInitial().lowerTrail()}
So, now that I skipped ahead and tried to get all my code set up and customized now I am trying to go in baby steps fixing the errors one at a time until it actually runs. Although I am glad I am at least getting errors now, because at least I am somewhat on the right track. Of course, while I'm trying to get these kinks worked out, I'm also thinking ahead a little bit to changes. I'm wondering, wouldn't be easier maybe since my uTorrent label is already getting passed to the script that if the label starts with "TV" then use "Episode mode" and if the label starts with "Movies" or "Couch Potato" use "Movie mode"

Also, I think my version of uTorrent 2.2.1, which I remember downgrading to on purpose, but I don't remember why, doesn't use "-Xut_kind=%K", because the logger never shows a value in it. Is that an important piece of this script? The single or multi.

[2012-05-10 07:43:54] Executing: C:\Program Files\FileBot\filebot -script "C:\Program Files\FileBot\my-utorrent-postprocess.groovy" --output "C:\Users\Scott\Downloads\Done\Video Staging" --action move --conflict skip -non-strict -trust-script -Xxbmc=Apple-TV "-Xut_dir=C:\Users\Scott\Downloads\Done\TV\Wednesday\Modern Family" "-Xut_file=Modern.Family.S03E21.HDTV.x264-LOL.mp4" "-Xut_label=TV\Wednesday\Modern Family" "-Xut_state=10" "-Xut_kind=%K"

I'm also wondering if -Xxbmc=Apple-TV is going to be able to find my xbmc or if I should be putting in the local IP address instead. There is also a username set up with no password, so I don't know if those values need to be added to the script to make that part work. So far the script hasn't been able to get far enough past my errors to find out.

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 10 May 2012, 14:30

The format is one String value. It's format:'...' but if you use ' in the script you'll close the String and mess up syntax. Use ''' syntax instead so you can use ' in the String. e.g. format:'''...'''

@see
http://groovy.codehaus.org/Strings+and+GString
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 10 May 2012, 15:04

Ok, so I changed a bunch of ' to " inside the script and I think I got past those errors. Now the newest one is:

C:\Program Files\FileBot>filebot -script "C:\Program Files\FileBot\my-utorrent-p
ostprocess.groovy" --output "C:\Users\Scott\Downloads\Done\Video Staging" --acti
on move --conflict skip -non-strict -trust-script -Xxbmc=Apple-TV "-Xut_dir=%D"
"-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"
MultipleCompilationErrorsException: startup failed:
Script3.groovy: 1: Invalid variable name. Must start with a letter but was: ?
. At [1:1] @ line 1, column 1.
?// filebot -script "fn:utorrent-postprocess" --output "X:/media" --action co
py --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=%D"
"-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"
^

1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script3.groovy: 1: Invalid variable name. Must start with a letter but was: ?
. At [1:1] @ line 1, column 1.
?// filebot -script "fn:utorrent-postprocess" --output "X:/media" --action co
py --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=%D"
"-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"
^

1 error

at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)

It's pointing at the u in "-Xut_file=%F", so maybe that's because that value is blank since I'm calling it from the command line rather than passing the value through uTorrent?

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 10 May 2012, 15:17

It's pointing at the first character '?'. Does the example script start with "?"? I don't think so. Your editor is adding an invalid character at the beginning of the file again. // means the it's a comment, does nothing... you can delete that whole line if you want. I recommend doing a basic Groovy tutorial.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 10 May 2012, 15:20

I downloaded Notepad2 and opened the script in there, went to save as, and it shows UTF-8 and doesn't show any ? before the first //

I don't know where this ? is coming from.

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 10 May 2012, 15:39

Make sure it's UTF-8 and not UTF-8 with Signature.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 10 May 2012, 21:54

I don't see UTF-8 with Signature anywhere, so I'm assuming the UTF-8 I selected is ok. It's the only option I can see. I thought I had it solved when I went to the page setup in Notepad and it showed a header and footer there. Getting rid of those still hasn't solved the problem. Running with the online version of the script seems to run in test mode. I didn't try it with move or copy, because I want to change how it's renaming. When I save the online version again as a local file it seems to work if I don't change anything. When I copy and paste my naming scheme in however and save it, I get the same error popping back up suddenly.

The strange thing to me is that when I was trying before and correcting my ' and " errors it didn't say there was a ? at line 1 column 1, but now it does, that seems odd.

Very frustrating, but I'm sure it will be worked out at some point.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 10 May 2012, 22:36

Ok, so I am doing something wrong with the editor apparently. If I use the online script I can get it to run in test mode. If I save the online script locally it will run in test mode.

But if I open that saved untouched script in Notepad2, and try file, save as, then change the encoding to UTF-8 and save it, then it no longer works. It gives the error that there is a ? in front of it.

So, how can I edit a script?

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 11 May 2012, 00:31

I use notepad2 and it never adds a signature. Use another editor. Signatures is not the norm, only a couple of editors on windows do that.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 11 May 2012, 05:48

I used another editor to get rid of my problem ?'s. I think it was a bit of overkill and took something like 600MB of space downloading netbeans, which required a java jdk, but whatever, it works.

I reran the script in test and seemed like it would work, so I ran it with action move. It spit out a whole ton of info in the command prompt window and then it disappeared. My file didn't get moved though. So the NEXT question is how do I make the command prompt window not disappear so I can actually see what is going on?

Thank you so much for your patience with a noob.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 11 May 2012, 06:35

I would also like to change a line in the xbmc script, but I'm not sure how.

I would like to change

Code: Select all

VideoLibrary.Scan
to

Code: Select all

UpdateLibrary(video,[path to the folder with the video that was just moved and renamed])
Of course I can copy and paste one over the other, but I don't know what value to use in the script or if it's already passing through to that script from the other script or not, so that [path to the folder] becomes whatever the directory it is that the video file just got moved to.

The reason I want to change this is because this way XBMC should just scan that one directory for new content instead of all of my thousands of directories I have in my XBMC library.

Thanks so much again.

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

Re: HELP - Filebot Groovy Script How To?

Post by rednoah » 11 May 2012, 07:19

Start a cmd console and then enter a command. The console doesn't close after each command.
:idea: Please read the FAQ and How to Request Help.

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 11 May 2012, 07:31

Yet another error bypassed:

The socket error was fixed by searching the forums, and finding someone asking about proxys. I don't have a proxy server, but using that information from this posting worked for me to get one step closer to this working

http://filebot.sourceforge.net/forums/v ... reset#p588

Man these baby steps take a long time for me.

Code: Select all

C:\Program Files\FileBot>filebot -script "C:\Program Files\FileBot\my-utorrent-p
ostprocess.groovy" --output "C:\Users\Scott\Downloads\Done\Video Staging" --acti
on move --conflict skip -non-strict -trust-script -Xxbmc=192.168.0.193 "-Xut_dir
=C:\Users\Scott\Downloads\Done\TV\Wednesday\Mxx" "-Xut_file=Mxx.mp4" "-Xut_label=TV\Wednesday\Mxx" "-Xut_stat
e=11" "-Xut_kind=%K"
Parameter: ut_label = TV\Wednesday\Mxx
Parameter: ut_kind = %K
Parameter: ut_dir = C:\Users\Scott\Downloads\Done\TV\Wednesday\Mxx
Parameter: xbmc = 192.168.0.193
Parameter: ut_state = 11
Parameter: ut_file = Mxx.mp4
Input: C:\Users\Scott\Downloads\Done\TV\Wednesday\Mxx\Mxx.mp4
SocketException: Connection reset
java.net.SocketException: Connection reset
        at net.sourceforge.tuned.ByteBufferOutputStream.transferFrom(Unknown Sou
rce)
        at net.sourceforge.tuned.ByteBufferOutputStream.transferFully(Unknown So
urce)
        at net.sourceforge.tuned.ByteBufferOutputStream.transferFully(Unknown So
urce)
        at net.sourceforge.filebot.web.WebRequest.fetch(Unknown Source)
        at net.sourceforge.filebot.web.WebRequest.fetchIfModified(Unknown Source
)
        at net.sourceforge.filebot.web.CachedResource.fetchData(Unknown Source)
        at net.sourceforge.filebot.web.CachedResource.get(Unknown Source)
        at net.sourceforge.filebot.media.ReleaseInfo.getMovieList(Unknown Source
)
        at net.sourceforge.filebot.media.MediaDetection.matchMovieName(Unknown S
ource)
        at net.sourceforge.filebot.media.MediaDetection.detectMovie(Unknown Sour
ce)
        at net.sourceforge.filebot.media.MediaDetection$detectMovie.call(Unknown
 Source)
        at Script2.detectMovie(Script2.groovy:173)
        at Script2.detectMovie(Script2.groovy)
        at Script3$_run_closure4.doCall(Script3.groovy:30)
        at Script3.run(Script3.groovy:28)
        at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
        at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
        at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

        at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)

part timer
Posts: 181
Joined: 09 May 2012, 23:35

Re: HELP - Filebot Groovy Script How To?

Post by part timer » 11 May 2012, 09:21

Now I've searched my latest problem and found some documentation from Groovy online but it's over my head.

It says I'm missing } and I've been up and down the code and can't find it yet. I really don't think it is missing any { or }. The other error worries me more though Null Object Pattern.

Error:

Code: Select all

C:\Program Files\FileBot>filebot -script "C:\Program Files\FileBot\my-utorrent-p
ostprocess.groovy" --output "C:\Users\Scott\Downloads\Done\Video Staging" --acti
on move --conflict skip -non-strict -trust-script -Xxbmc=192.168.0.193 "-Xut_dir
=C:\Users\Scott\Downloads\Done\TV\Wednesday\Modern Family" "-Xut_file=Modern.Fam
ily.S03E21.HDTV.x264-LOL.mp4" "-Xut_label=TV\Wednesday\Modern Family" "-Xut_stat
e=11" "-Xut_kind=%K"
Parameter: ut_label = TV\Wednesday\Modern Family
Parameter: ut_kind = %K
Parameter: ut_dir = C:\Users\Scott\Downloads\Done\TV\Wednesday\Modern Family
Parameter: xbmc = 192.168.0.193
Parameter: ut_state = 11
Parameter: ut_file = Modern.Family.S03E21.HDTV.x264-LOL.mp4
Input: C:\Users\Scott\Downloads\Done\TV\Wednesday\Modern Family\Modern.Family.S0
3E21.HDTV.x264-LOL.mp4
Modern.Family.S03E21.HDTV.x264-LOL.mp4 [series: Modern Family, movie: "Modern Fa
mily" Virgin Territory (2012)]
Exclude Movie: "Modern Family" Virgin Territory (2012)
No missing subtitles
ScriptException: SyntaxError: missing token: }
NullPointerException: Cannot invoke method mapByFolder() on null object
java.lang.NullPointerException: Cannot invoke method mapByFolder() on null objec
t
        at Script3$_run_closure5.doCall(Script3.groovy:53)
        at Script3.run(Script3.groovy:44)
        at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
        at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
        at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

        at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)
Script that I've been trying get limping along:

Code: Select all

// filebot -script "fn:utorrent-postprocess" --output "X:/media" --action copy --conflict override -non-strict -trust-script -Xxbmc=localhost "-Xut_dir=%D" "-Xut_file=%F" "-Xut_label=%L" "-Xut_state=%S" "-Xut_kind=%K"
def input = []

// print input parameters
_args.parameters.each{ k, v -> println "Parameter: $k = $v" }

if (ut_kind == "multi") {
	input += new File(ut_dir).getFiles() // multi-file torrent
} else {
	input += new File(ut_dir, ut_file) // single-file torrent
}

// extract archives if necessary
input += extract(file:input, output:".", conflict:"override")

// process only media files
input = input.findAll{ it.isVideo() || it.isSubtitle() }

// print input fileset
input.each{ println "Input: $it" }

// xbmc artwork/nfo utility
include("C:/Program Files/FileBot/lib/xbmc.groovy")

// group episodes/movies and rename according to XBMC standards
def groups = input.groupBy{
	def tvs = detectSeriesName(it)
	def mov = detectMovie(it, false)
	println "$it.name [series: $tvs, movie: $mov]"
	
	// DECIDE EPISODE VS MOVIE (IF NOT CLEAR)
	if (tvs && mov) {
		if (it.name =~ "(?i:$tvs - .+)" || parseEpisodeNumber(it.name) || parseDate(it.name)) {
			println "Exclude Movie: $mov"
			mov = null
		} else if (detectMovie(it, true)) {
			println "Exclude Series: $tvs"
			tvs = null
		}
	}
	return [tvs:tvs, mov:mov]
}

groups.each{ group, files ->
	// fetch subtitles
	def subs = getMissingSubtitles(file:files, output:"srt", encoding:"utf-8")
	if (subs) files += subs
	
	// EPISODE MODE
	if (group.tvs && !group.mov) {
		def dest = rename(file:files, format:'TV Shows/{(n =~ /^[Tt]he / ? n[4..-1]+", The" : n =~ /^[Aa] / ? n[2..-1]+", A" : n).replace(":",' -').upperInitial().lowerTrail()}{" [startdate.format("yyyy")]"}/{(n =~ /^[Tt]he / ? n[4..-1]+", The" : n =~ /^[Aa] / ? n[2..-1]+", A" : n).replace(":",' -').upperInitial().lowerTrail()} {episode.special ? "Specials" : "Season "+s}/{episode.special ? "s00e"+special.pad(2) : s00e00} {t.upperInitial().lowerTrail().replacePart(", Part $1")}/{episode.special ? "s00e"+special.pad(2) : s00e00} {t.upperInitial().lowerTrail().replacePart(", Part $1")}{"  [$airdate.year]"}{"  [$vf]"}{"  [$vc]"}{"  [$ac]"}{"  [$group]"}', db:'TheTVDB')
		
		dest.mapByFolder().keySet().each{ dir ->
			println "Fetching artwork for $dir from TheTVDB"
			def query = group.tvs
			def sxe = dest.findResult{ parseEpisodeNumber(it) }
			def options = TheTVDB.search(query)
			if (options.isEmpty()) {
				println "TV Series not found: $query"
				return
			}
			options = options.sortBySimilarity(query, { it.name })
			fetchSeriesArtworkAndNfo(dir.dir, dir, options[0], sxe && sxe.season > 0 ? sxe.season : 1)
		}
        }
	
	// MOVIE MODE
	if (group.mov && !group.tvs) {
		def dest = rename(file:files, format:'Movies/{(n =~ /^[Tt]he / ? n[4..-1]+", The" : n =~ /^[Aa] / ? n[2..-1]+", A" : n).replace(":",' -')}{"  [$y]"}{"  [Rated $certification]"}{"  [Voted $rating]"}/{(n =~ /^[Tt]he / ? n[4..-1]+", The" : n =~ /^[Aa] / ? n[2..-1]+", A" : n).replace(":",' -')}{"  [$vf]"}{"  [$sdhd]"}{"  [$source]"}{"  [$vc]"}{"  [$ac]"}{"  [$group]"}{"  [CD$pi]"}', db:'TheMovieDB')
		
		dest.mapByFolder().keySet().each{ dir ->
			println "Fetching artwork for $dir from TheMovieDB"
			fetchMovieArtworkAndNfo(dir, group.mov)
                }
        }
}



// make XBMC scan for new content
xbmc.split(/[\s,|]+/).each{
	println "Notify XBMC: $it"
	invokeScanVideoLibrary(it)
}

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests