Combining scripts

Running FileBot from the console, Groovy scripting, shell scripts, etc
saitoh183
Posts: 112
Joined: 02 Oct 2012, 16:59

Re: Combining scripts

Post by saitoh183 »

If i add the --extract will it only be used when there is a archive and be ignored when there is none?

Also if i were to use file location to determine if the show is french or english (since the completed download locations are different), i could the use the --lang retroactively?

And what does

Code: Select all

[1..-1]
in

Code: Select all

{plex[1..-1]}
output exactly?

Im still reading through the groovy documentation to figure out how to properly read and interpret the code you gave me.
User avatar
rednoah
The Source
Posts: 23934
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Combining scripts

Post by rednoah »

1.
If you're using the amc script, you don't need to worry about flags like -extract because they will be ignored anyway.


2.
You can call filebot with --lang fr or --lang en depending on the input in your calling script. You cannot change --lang after filebot has been called.


3.
Start FileBot GUI. Then play with some formats. Reading the docs will not help you understand behaviour. It's much easier to try a few things to see what happens.

Try a few variations. See what's different.

Code: Select all

{plex}
{plex[0]}
{plex[1]}
{plex[2]}
{plex[-1]}
{plex[-2]}
{plex[1..2]}
{plex[1..-1]}
We're picking path components here, i.e. {plex[1..-1]} takes 2nd to last path components of the plex path, because you want your own "Movies" folder so we don't want that part of the plex path.

Using {plex} is convenient, but it doesn't give you any way to mess with the standard plex path if you want things to be slightly different (i.e. "French Movies" folder instead of "Movies" folder).

You may copy & paste plex-compatible formats that don't just use {plex} from the examples:
http://www.filebot.net/forums/viewtopic.php?f=5&t=2#p51
:idea: Please read the FAQ and How to Request Help.
saitoh183
Posts: 112
Joined: 02 Oct 2012, 16:59

Re: Combining scripts

Post by saitoh183 »

rednoah wrote:Since --lang fr is passed along with your format, there is no way for the format to change the --lang option retroactively.

You can access localized Episode data in the format though. The rest is just if-then-else like in the previous examples.

French Series Name:

Code: Select all

{localize.FR.seriesName}
French Episode Title:

Code: Select all

{localize.FR.title}
Does this make sense for TV or there is a cleaner way?

Code: Select all

D:/videos/{file =~ /sickrage_tv/ ? 'French TV' : '/TV'}/{file =~ /sickrage_tv/ ? localize.FR.seriesName : n}/{'Season '+s}/{n} - {sxe} - {file =~ /sickrage_tv/ ? localize.FR.title: t}
Also since im using this in deluge execute plugin, how will the script know to look in the proper completed folder? Will i have to replace some entries in the script with Deluge variables? (http://dev.deluge-torrent.org/wiki/Plugins/Execute)
saitoh183
Posts: 112
Joined: 02 Oct 2012, 16:59

Re: Combining scripts

Post by saitoh183 »

Here is my movie script

Code: Select all

D:/videos/{file =~ /cpsfr/ ? audio.size() > 1 ? 'dual audio movies' : 'French movies' : 'movies'}/{plex[1..-1]}
I could not use the audio.language because some files just dont have that set in french and in english..so it is not a reliable variable. Using the folder location ensures that the file will go to the right place.

Tested with the GUI and it seems to give the proper result
User avatar
rednoah
The Source
Posts: 23934
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Combining scripts

Post by rednoah »

saitoh183 wrote:how will the script know to look in the proper completed folder?
It does not. The amc script will process any file/folder that is passed in via command-line arguments.

@see https://github.com/filebot/plugins/blob ... process.sh
:idea: Please read the FAQ and How to Request Help.
saitoh183
Posts: 112
Joined: 02 Oct 2012, 16:59

Re: Combining scripts

Post by saitoh183 »

rednoah wrote:
how will the script know to look in the proper completed folder?
It does not. The amc script will process any file/folder that is passed in via command-line arguments.

@see https://github.com/filebot/plugins/blob ... process.sh

Thanks

Here is the final version of my script:

Code: Select all

@echo off

set torrentpath=%3

filebot -script  fn:amc --def movieFormat="D:/videos/{file =~ /UFC/ ? 'UFC' : file =~ /cpsfr/ ? audio.size() > 1 ? 'dual audio movies' : 'French movies' : 'movies'}/{plex[1..-1]}" seriesFormat="D:/videos/{file =~ /sickrage_tv/ ? 'French TV' : '/TV'}/{file =~ /sickrage_tv/ ? localize.FR.seriesName : n}/{'Season '+s}/{n} - {sxe} - {file =~ /sickrage_tv/ ? localize.FR.title: t}" --action hardlink -non-strict %torrentpath% --log-file P:/scripts/Filebot.log --def clean=y -no-xattr --log Fine
saitoh183
Posts: 112
Joined: 02 Oct 2012, 16:59

Re: Combining scripts

Post by saitoh183 »

Hi Rednoah,

I seem to be having a small problem with my script. It works well for english TV shows but not so much for French TV shows here is a example of a result pulled from FB GUI history:

Image

The show is District 31 under French TVDB http://thetvdb.com/?tab=series&id=316544&lid=17

So how can i get my script to use TVDB french when it is french show (if possible) if not What would be an alternative?

Note that i dont need this kind of detection for the movie part of the script because i want all the names in english even if they are french movies.

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

Re: Combining scripts

Post by rednoah »

You didn't post the file path as text, so I can't run my own tests.

I reckon that FileBot will use the more popular show when in doubt if there are multiple shows with similar names. Also, shows with 0 ratings will be given low priority. Using --lang fr might make a difference, but not necessarily in this specific case.

You can use the --filter option and take full control over which episode objects will be considered for matching:
viewtopic.php?f=3&t=2127
:idea: Please read the FAQ and How to Request Help.
saitoh183
Posts: 112
Joined: 02 Oct 2012, 16:59

Re: Combining scripts

Post by saitoh183 »

Code: Select all

The District - 1x01 - Entrée en scène.mkv |	District.31.S01E01.WEBRiP.TOUTV.480p.x264.mkv |	D:\videos\FrenchTV\Washington Police\Season 1	| P:\Torrents\Completed\sickrage_tv
But im guessing using the --lang fr would apply everything and not just when " {file =~ /sickrage_tv/ ? 'French TV' " is True and filter isnt possible either because of the same reason..I think in order to get this to work, i would need to wrap this script in some if statements and call the proper FB amc script i want to run.

Could you give me an example of how you would use TVDB in french to rename and move the file example above? Would be greatly appreciated..
saitoh183
Posts: 112
Joined: 02 Oct 2012, 16:59

Re: Combining scripts

Post by saitoh183 »

Well i think i corrected the issue by breaking down the script in a powershell script

Code: Select all

if ($torrentpath -like "sickrage_tv"){

       filebot -script  fn:amc --def seriesFormat="D:/videos/FrenchTV/{n}/{'Season '+s}/{n} - {sxe} - {t}" --action test -non-strict $torrentpath --log-file P:/scripts/Filebot.log --def clean=y -no-xattr --log Fine --db TheTVDB --lang fr

}
ElseIf ( $torrentpath -like "cpsfr" -or $torrentpath -like "UFC"){

    filebot -script  fn:amc --def movieFormat="D:/videos/{file =~ /UFC/ ? 'UFC' : file =~ /cpsfr/ ? audio.size() > 1 ? 'dual audio movies' : 'French movies' : 'movies'}/{plex[1..-1]}" --action test -non-strict $torrentpath --log-file P:/scripts/Filebot.log --def clean=y -no-xattr --log Fine
    
}
Else {

   filebot -script  fn:amc --def seriesFormat="D:/videos/TV/{n}/{'Season '+s}/{n} - {sxe} - {t}" --action test -non-strict $torrentpath --log-file P:/scripts/Filebot.log --def clean=y -no-xattr --log Fine
}
User avatar
rednoah
The Source
Posts: 23934
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Combining scripts

Post by rednoah »

1.
--lang fr does make a difference in this case. If you search for "District 31" in English the correct result isn't even in the results, so filter won't be any help neither. This is probably a temporary issue on the TheTVDB side though, so it might magically work at some point.


2.
Automated Media Center wrote:You can (and should) force Movie/Series/Anime mode by setting --def ut_label accordingly, and you can further define your own --filter rules to fine-tune matching to your exact needs, and avoid mismatches.
If you already know if you're dealing with movies or tv shows, you should pass that in.


PS: the amc script will ignore your --db TheTVDB option; it has no effect
:idea: Please read the FAQ and How to Request Help.
Post Reply