Need a bit of help to update format (for new script version)

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Waldner11
Posts: 8

Need a bit of help to update format (for new script version)

Postby Waldner11 » 18 May 2017, 16:20

Hi,

I was using a custom script since 2015 to copy my files from uTorrent and I decided to update it to the latest version of filebot.

I'm havin' a bit of trouble with the new script seriesFormat. Here's what I was using to copy my files in 2015 and was working :
uTorrent code :

Code: Select all

filebot -script "C:\Script\amc.groovy" --output "\\NASJP\Multimedia" --log-file amc.log --action copy --conflict skip -non-strict --def unsorted=y --def clean=y --def excludeList=amc.txt --def music=n artwork=n "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"


Code: Select all

// series/anime/movie format expressions
def format = [
   tvs:   tryQuietly{ seriesFormat } ?: '''//NASJP/Multimedia_TV/TV Shows/{n}/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{n.upperInitial().space('.').replaceAll(/[,]+/)}.{s00e00}.{t.upperInitial().space('.').replaceAll(/[,]+/)}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{'-'+fn.match(/(?:(?<=[-])\\w+$)|(?:^\\w+(?=[-]))/)}''',
   anime: tryQuietly{ animeFormat  } ?: '''//NASJP/Multimedia_TV/TV Shows/{n}/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{n.upperInitial().space('.').replaceAll(/[,]+/)}.{s00e00}.{t.upperInitial().space('.').replaceAll(/[,]+/)}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{'-'+fn.match(/(?:(?<=[-])\\w+$)|(?:^\\w+(?=[-]))/)}''',
   mov:   tryQuietly{ movieFormat  } ?: '''Movies/{n} ({y})/{n.upperInitial().space('.').replaceAll(/[,]+/)}.{y}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{"-$group"}''',
   music: tryQuietly{ musicFormat  } ?: '''Music/{n}/{album+'/'}{pi.pad(2)+'. '}{artist} - {t}'''
]


I've kept the same line in uTorrent while updating to the latest version of filebot and changing my custom script by the latest version in github:

Here's my tentative in the new 2017 version : (for now you can only focus on the seriesFormat, if you help me figure it out I should be able to do the others)

Code: Select all

// series/anime/movie format expressions
seriesFormat   = tryQuietly{ seriesFormat } ?: '''//NASJP/Multimedia_TV/TV Shows/{n}/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{n.upperInitial().space('.').replaceAll(/[,]+/)}.{s00e00}.{t.upperInitial().space('.').replaceAll(/[,]+/)}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{'-'+fn.match(/(?:(?<=[-])\\w+$)|(?:^\\w+(?=[-]))/)}'''
animeFormat    = any{ '''Multimedia_TV/TV Shows/{n}/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{n.upperInitial().space('.').replaceAll(/[,]+/)}.{s00e00}.{t.upperInitial().space('.').replaceAll(/[,]+/)}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{'-'+fn.match(/(?:(?<=[-])\\w+$)|(?:^\\w+(?=[-]))/)}'''    }{ '{plex}' }
movieFormat    = any{ '''Movies/{n} ({y})/{n.upperInitial().space('.').replaceAll(/[,]+/)}.{y}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{"-$group"}'''    }{ '{plex}' }
musicFormat    = any{ musicFormat    }{ '{plex}' }
unsortedFormat = any{ '''Multimedia/Unsorted''' }{ 'Unsorted/{file.structurePathTail}' }


My issue with this code is it doesn't understand anymore that I want my seriesFormat to be at a different location than the default output I've given it and I can't figure out how to correct it. (I've tried several things with any or tryquietly but nothing worked)

It's copying like this : ( in the code I've copied)
\\NASJP\Multimedia\NASJP\Multimedia_TV\TV Shows\Prison Break\Season 05\Prison.Break.S05E06.Phaeacia.HDTV.x264.mkv

Just to clarify I have two folders :
\\NASJP\Multimedia (where I have my Movies and Unsorted folders)
And (my tv show folder)
\\NASJP\Multimedia_TV\TV Shows

Any help you could give me would be greatly appreciated. Thanks in advance.

User avatar
rednoah
The Source
Posts: 11290
Location: Taipei
Contact:

Re: Need a bit of help to update format (for new script version)

Postby rednoah » 18 May 2017, 16:42

1.
You don't need to (and shouldn't) fork the amc script just for custom formats. There's command-line options for that.

:idea: Use the @file syntax for reading command-line arguments from external text files.


2.
Use the GUI to prototype and test your formats. Once you've got your format, you can save it to a file and pass it on to the amc script via @files as explained above.

@see http://www.filebot.net/naming.html


3.
As TV format, this should be more or less what you want, but it's more easy on the eyes:

Code: Select all

\\server\share\{
   allOf
      {plex.path.upperInitial().space('.')}
      {vc}
      {source}
      {vf}
      {group}
   .join('.')
}
My (very excellent) support depends on Windows Store and Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

Waldner11
Posts: 8

Re: Need a bit of help to update format (for new script version)

Postby Waldner11 » 18 May 2017, 17:29

I'm more confused now, I've tried this in uTorrent :

Code: Select all

filebot -script fn:amc /input --output /output --def @/NASJP/Multimedia/args.txt --log-file amc.log --action copy --conflict skip -non-strict --def unsorted=y --def clean=y --def excludeList=//NASJP/Multimedia/amc.txt --def music=n artwork=n "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"


But my amc.log is not edited now, so I have no information whatsoever on what went wrong.

I tried to put this in args.txt, I'm really not sure about the \ or / I should be using in it.

Code: Select all

movieFormat=Movies/{ny}/{fn}
seriesFormat=\\NASJP\Multimedia_TV\TV Shows\{n}\{episode.special ? 'Special' : 'Season '+s.pad(2)}\{n.upperInitial().space('.').replaceAll(/[,]+/)}.{s00e00}.{t.upperInitial().space('.').replaceAll(/[,]+/)}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{'-'+fn.match(/(?:(?<=[-])\\w+$)|(?:^\\w+(?=[-]))/)}
animeFormat=Anime/{n}/{fn}


I would just like to point the fact that my expression for path/episode name was working fine and is exactly what I wanted in the previous version.

Edit : Just wanted to say thanks for the help by the way. (i'm just frustrated)

User avatar
rednoah
The Source
Posts: 11290
Location: Taipei
Contact:

Re: Need a bit of help to update format (for new script version)

Postby rednoah » 18 May 2017, 17:35

1.
Open CMD. Run your command. See what it says. Probably just a bad command-line call.

Presumably, in the real command, you have replaced /output with something that makes sense, right? I think you copy & pasted random bits and pieces without thinking things through here. ;)

Code: Select all

/input --output /output

The error output will tell you exactly what's wrong. If you run the command in CMD. Please read the Troubleshooting section of the amc manual.


2.
I'd use the @file syntax for binding value. That way you can't break the command-line call and you'll always get some log output:

Code: Select all

--def seriesFormat=@/path/to/SeriesFormat.groovy

/path/to/SeriesFormat.groovy

Code: Select all

\\server\share\{
   allOf
      {plex.path.upperInitial().space('.')}
      {vc}
      {source}
      {vf}
      {group}
   .join('.')
}



3.
You can use the Format Editor GUI to check and debug your expression to find out which part doesn't work as expected. Looks good to me, but I'm not a computer.
My (very excellent) support depends on Windows Store and Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

Waldner11
Posts: 8

Re: Need a bit of help to update format (for new script version)

Postby Waldner11 » 18 May 2017, 17:54

How am I suppose to know that

Code: Select all

/input --output /output
is a bad command?

It didn't look like a variable to me when I looked at your examples

Edit : I do copy and paste without really understanding what I'm doing. I honestly feel like you're trying to make me do too much. My issue is just that I don't copy in the good folder.

User avatar
rednoah
The Source
Posts: 11290
Location: Taipei
Contact:

Re: Need a bit of help to update format (for new script version)

Postby rednoah » 18 May 2017, 18:48

Not using CMD means you're blind. Maybe you'll get lucky and it just works, but if it doesn't then you have no chance of finding out why, because you won't see the error output that tells you what's going on. That's usually when you need to learn some basics.


Here's what I'd do:

1.
Copy the example, change X:/Media to a valid folder, and then make sure it works:

Code: Select all

filebot -script fn:amc --output "X:/Media" --action copy --conflict skip -non-strict --log-file amc.log --def unsorted=y music=y artwork=y "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"


2.
Set your custom seriesFormat, and then make sure that it still works:

Code: Select all

filebot -script fn:amc --output "X:/Media" --action copy --conflict skip -non-strict --log-file amc.log --def seriesFormat="@/path/to/SeriesFormat.groovy" unsorted=y music=y artwork=y "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"


3.
Repeat for each change you want to make, and make sure it still works after each and every change so you know exactly when and where you broke the command.
My (very excellent) support depends on Windows Store and Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

Waldner11
Posts: 8

Re: Need a bit of help to update format (for new script version)

Postby Waldner11 » 18 May 2017, 21:55

Ok, I manage to make it work.Here's what I've done. (for those that may need help like me, it's not very pretty but it works)

uTorrent code :

Code: Select all

filebot -script fn:amc --output "\\NASJP\Multimedia" --log-file amc.log --action copy --conflict skip -non-strict --def unsorted=y --def clean=y --def excludeList=amc.txt --def seriesFormat=@\\NASJP\Multimedia\SeriesFormat.groovy --def movieFormat=@\\NASJP\Multimedia\MoviesFormat.groovy --def unsortedFormat=@\\NASJP\Multimedia\UnsortedFormat.groovy --def music=n artwork=n "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"


And in the groovy files :

Code: Select all

Movies/{n} ({y})/{n.upperInitial().space('.').replaceAll(/[,]+/)}.{y}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{"-$group"}

Sample result : \\NASJP\Multimedia\Movies\Movie Name (1951)\Movie.Name.1951.1080p.BluRay.x264-YIFY.mp4

Code: Select all

\\NASJP\Multimedia_TV\TV Shows/{n}/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{n.upperInitial().space('.').replaceAll(/[,]+/)}.{s00e00}.{t.upperInitial().space('.').replaceAll(/[,]+/)}{'.'+vf.match(/720[pP]|1080[pP]/)}{".$source"}{".$vc"}{'-'+fn.match(/(?:(?<=[-])\\w+$)|(?:^\\w+(?=[-]))/)}

Sample result : \\NASJP\Multimedia_TV\TV Shows\TV Show Name\Season 02\TV.Show.Name.S02E09.The.Title.1080p.WEBRip.x264-NTb.mkv

Code: Select all

Unsorted/{fn}.{ext}

Sample result : \\NASJP\Multimedia\Unsorted\FileName.ext

A couple of remarks of what I thought was a bit weird :
- Removing the @\\NASJP\Multimedia\ in the uTorrent code does not make it work (I assume there's a way to make it work but not sure how)
- in the groovy file, for the second block you need to have the "\" for it to copy in the proper/specific folder

Thank you for your help. (If some people want to propose a simpler solution with only one groovy file and others things like that I'd be very interested to see it :) )

User avatar
rednoah
The Source
Posts: 11290
Location: Taipei
Contact:

Re: Need a bit of help to update format (for new script version)

Postby rednoah » 19 May 2017, 17:23

If you pass in --def [email protected] then MoviesFormat.groovy is relative to the current working directory like any other file argument. In this case, it'll probably be to the working directory of utorrent.

Using absolute paths is always a good idea, since you won't need to understand how relative paths work behind the scenes.
My (very excellent) support depends on Windows Store and Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:


Return to “Scripting and Automation”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest