Page 2 of 2

Re: HELP - Filebot Groovy Script How To?

Posted: 11 May 2012, 10:22
by rednoah
The syntax error is in the format expression. Which causes rename() to fail and return null.

Re: HELP - Filebot Groovy Script How To?

Posted: 11 May 2012, 10:32
by rednoah
About calling other XMBC API functions just telnet like I do in the examples. The folders/files you can collect after each rename call.

Something like this (pseudo code):
def changes = []
...
def dest = rename(...)
changes += dest
...
telnet(xmbc) { out ->
changes.mapByFolder().keySet().each{ out.println(update it) }
}

Re: HELP - Filebot Groovy Script How To?

Posted: 11 May 2012, 19:19
by part timer
Well I've looked again and I see every { has a } but maybe there is spacing or some other thing that I don't know about causing it to think they don't all have pairs.

Could you take a look? I realize some of it may seem unnecessary, but this is the format I'm going for. Thanks in advance.

Here are my two formats:

Episode format-

Code: Select all

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')
Movie format-

Code: Select all

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')

Re: HELP - Filebot Groovy Script How To?

Posted: 11 May 2012, 23:47
by rednoah
I'm gonna help you out with the episode format here. It's riddled with mistakes. Did you ever think of testing that expression in the Format Editor in the GUI? Step by step test each {} block and you will get it done easily. Try to do all at once in the script and you will never get it right, I wouldn't be able to.

Here is the fixed format:

Code: Select all

TV Shows/{(n =~ /^[Tt]he / ? n[4..-1]+", The" : n =~ /^[Aa] / ? n[2..-1]+", A" : n).replace(":",' -').upperInitial().lowerTrail()}{" [$startdate.year]"}/{(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]"}
And I told you to use '''...''' syntax to avoid escaping problems and just paste a working format unchanged.

Code: Select all

format:'''...'''

Re: HELP - Filebot Groovy Script How To?

Posted: 16 May 2012, 18:58
by Savvy
thanks rednoah, i'll come back when i've learnt a little more.... cheers

Re: HELP - Filebot Groovy Script How To?

Posted: 20 May 2012, 10:07
by part timer
More playing around with this and more error messages.

I finally got this working with tv shows, mainly because they were single torrent files. The version of uTorrent I'm using doesn't support the "-Xut_kind=%K" parameter. Any time I have a torrent with more than one file I get error messages. How could I edit the start of the utorrent script to simply use whatever files are in the directory that is passed through "-Xut_dir=%D" instead of it trying to figure out if it's single or multi? I have tried so many different things, but haven't been able to find one that works.

Thank you so much in advance.

Re: HELP - Filebot Groovy Script How To?

Posted: 20 May 2012, 10:18
by rednoah
Change this from

Code: Select all

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

Code: Select all

input += new File(ut_dir).getFiles() // multi-file torrent
Actually you could just change the call from

Code: Select all

"-Xut_kind=%K"
to

Code: Select all

"-Xut_kind=multi"

Re: HELP - Filebot Groovy Script How To?

Posted: 20 May 2012, 10:52
by part timer
That really seemed simple after hours of trying so many different things.

I'm really bad at coding obviously. So how do I change the xbmc command from what it is now to:
UpdateLibrary(video,) Because I really can't make sense of what you typed as a first response to it. I'm sorry, I wish I could read it and understand it.

Re: HELP - Filebot Groovy Script How To?

Posted: 20 May 2012, 15:52
by rednoah
Can you point me to the API documentation of that UpdateLibrary call? I can't find any docs on that. I think you refer to a function that an xbmc skin can use but that's completely different from the socket api for external programs.

For the JSON-RPC API there is only this function: http://wiki.xbmc.org/index.php?title=JS ... brary.Scan

Re: HELP - Filebot Groovy Script How To?

Posted: 20 May 2012, 16:00
by part timer

Re: HELP - Filebot Groovy Script How To?

Posted: 20 May 2012, 16:27
by rednoah
One way is using doing executebuiltin via the depricated HTTP API that'll be faded out next release. The other is using new stuff that's not even in Eden yet. So I'm not gonna do anything offical for this at this point.

I'm sure you can get it working. Just do some testing with println to get a feeling for the code. For the http api you can use new URL(...).get() to make the call. And all the output paths you get from rename(...) anyway.

Re: HELP - Filebot Groovy Script How To?

Posted: 20 May 2012, 16:42
by rednoah
This should help you get there:

Code: Select all

def files = []
files += rename(folder:args[0])

files*.dir.unique().each{
	def url = new URL("http", "host", "/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video, ${it.path}))")
	println url
	println url.get()
}

Re: HELP - Filebot Groovy Script How To?

Posted: 26 May 2012, 09:38
by Savvy
The Utorrent code is working perfectly Thank you rednoah.

Could you possibly help with another noob Q?
I'm saving the groovy script file to desktop names 'art.groovy', open it in the groovy console and copied in the code:

filebot -script "http://filebot.sf.net/scripts/artwork.tvdb.groovy" -trust-script G:\media\TV Shows

When i execute 'sort.groovy' a cmd window flashes and closes instantly. When checking the script in groovy console i get the following error:


1 compilation error:

expecting EOF, found 'http://filebot.sf.net/scripts/artwork.tvdb.groovy' at line: 1, column: 17


Could you please help?

Thanks

Re: HELP - Filebot Groovy Script How To?

Posted: 26 May 2012, 10:13
by rednoah
What you refer to as "code" is a cmdline call. A call for filebot to run the given script. You seem to be confused between Windows batch script and groovy script. It's like this. Windows cmd runs batch scripts which may run filebot which my run filebot groovy scripts.

For basic usage you don't need to download anything. FileBot can run script given via remote URL like in the example you have given.

Re: HELP - Filebot Groovy Script How To?

Posted: 26 May 2012, 15:38
by Savvy
cool, that makes sense, when i run that command in cmd console it runs fine... So to have a desktop shortcut or setup a scheduled task, all i've done is rename the 'art.groovy' file to 'art.bat' and it works fine. :)

but what about in the scenario where there is no command line, like that of the 'sort download folder' script?

http://filebot.sf.net/scripts/sorty.groovy

Re: HELP - Filebot Groovy Script How To?

Posted: 26 May 2012, 15:56
by rednoah
It's the same. Just didn't add a comment for example usage.

filebot -script "/path/to/script.groovy"

sorty.groovy you probably wanna download and adjust to your needs.

Re: HELP - Filebot Groovy Script How To?

Posted: 26 May 2012, 16:31
by Savvy
all makes sense now... more errors though :(

CMD processes the sorty command renames, downloads subs - but then gets:

at Script2.telnet(Script2.groovy:80)
at Script2.telnet(Script2.groovy)
at Script3$_run_closure7.doCall(Script3.groovy:56)
at Script3.run(Script3.groovy:55)
at net.sourceforge.filebot.cli.ScriptShell$1.run(Unknown Source)
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)

Re: HELP - Filebot Groovy Script How To?

Posted: 26 May 2012, 23:15
by rednoah
You didn't copy the exception message. From the stack trace I can tell its the code for Notifying XBMC. Just delete the telnet call if you don't need it.

Re: HELP - Filebot Groovy Script How To?

Posted: 17 Dec 2018, 04:32
by RBCC
Can I use groovy code in the gui ?

Re: HELP - Filebot Groovy Script How To?

Posted: 17 Dec 2018, 04:36
by RBCC
How do I search through a file and find the string, that is needed in the filename? John

Re: HELP - Filebot Groovy Script How To?

Posted: 17 Dec 2018, 06:46
by RBCC
How do I open a file in groovy,? Code please.

Re: HELP - Filebot Groovy Script How To?

Posted: 17 Dec 2018, 07:23
by rednoah
Yes, you can read files using standard Groovy code within your format code.

FileBot adds additional convenience methods for reading text files into a List<String> or Map<String, String> as follows:

Code: Select all

def list = readLines('/path')

Code: Select all

def map = csv('/path')