[HELP] Format chain fails

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
GFOLehran
Posts: 3
Joined: 17 Jul 2020, 09:24

[HELP] Format chain fails

Post by GFOLehran »

Hello,

I am trying to make a string to rename my files, this is what I have for now:

Code: Select all

{' '+any{certification}{imdb.certification}.replaceAll(/^\d+$/, 'PG-$0')}/{genre}/{audio.size() > 2 ? 'Multi' : audio.size() > 1 ? 'Dual' : audio.language[0].replace('es', 'Spa') : audio.language[0].replace('spa', 'Spa') : audio.language[0].replace('sp', 'Spa') : audio.language[0].replace('eng', 'Eng') : audio.language[0].replace('en', 'Eng') : audio.language[0].replace('jp', 'Jap') : audio.language[0].replace('ja', 'Jap')} - {text.Language.contains('en') ? 'Eng':""} {text.Language.contains('es') ? 'Spa':""}/{" [$hd]"}{" [$vf]"}{" [$source]"}{" [$vc]"}{" [$ac]"} {n} {"( if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')')"} [{y}] { "[$fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, " ")]"} {"[$group]"}/{'Season '+s}/{n} - {absolute} - {sxe} - {t} [{crc32}]
What it should show is:

Code: Select all

TV-14\Action\Jap - Eng Spa\[HD][1080p][x264][EAC3] Ghost in the Shell Stand Alone Complex [1995]\Season 3\Ghost in the Shell Stand Alone Complex - 53 - 3x01 - SIN CONFLICTOS NO HAY VIDA - Guerra Sostenible [B0B4D609]
But it fails saying:

Code: Select all

SyntaxError: unexpected token:
How can i solve it?

Is it possible to add the alternative name like here: viewtopic.php?t=2#p7320

Is it possible to put the year of appearance of each season?


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

Re: [HELP] Format chain fails

Post by rednoah »

1.
GFOLehran wrote: 17 Jul 2020, 09:41 How can i solve it?
Divide and Conquer. If you have a large unreadable format that doesn't work. Start by splitting it into small readable snippets that can be evaluated independently, so that we can separate snippets that work, from snippets that don't work, so we can focus on the latter.

I see obvious issues with " here, easy to spot thanks to syntax highlighting:
Image


2.
GFOLehran wrote: 17 Jul 2020, 09:41 Is it possible to put the year of appearance of each season?
The {sy} season year binding seems like the obvious choice here:
https://www.filebot.net/naming.html
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: [HELP] Format chain fails

Post by kim »

Always test in GUI ;)

Code: Select all

{certification.replaceAll(/^\d+$/, 'PG-$0')}/
{genre}/
{(audio.size() > 2 
	? 'Multi'
	: audio.size() > 1
		? 'Dual'
		: audio.language[0].replaceFirst(/es|spa|sp/, 'Spa').replaceFirst(/eng|en/, 'Eng').replaceFirst(/jp|ja/, 'Jap')) + ' - '}
{text.Language.contains('en') ? 'Eng':''} 
{text.Language.contains('es') ? 'Spa':''}/
{" [$hd]"}
{" [$vf]"}
{" [$source]"}
{" [$vc]"}
{" [$ac]"}
{' ' + n}
{n != primaryTitle  ? ' (' + primaryTitle + ')' : ''}
{' [' + y + '] '}
{any{ '[' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, ' ') + '] '}{}}
{"[$group]/"}
{'Season '+s}/
{n}
{' - ' + absolute}
{' - ' + sxe}
{' - ' + t}
{' [' + crc32 + ']'}
GFOLehran
Posts: 3
Joined: 17 Jul 2020, 09:24

Re: [HELP] Format chain fails

Post by GFOLehran »

Many thanks both @kim and @rednoah. Now im working to put a little workaround, many files dont have audio language defined, so im tryint to put a default text if this happend.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: [HELP] Format chain fails

Post by kim »

Code: Select all

{(audio.size() > 2 
	? 'Multi'
	: audio.size() > 1
		? 'Dual'
		: any{audio.language[0].replaceFirst(/es|spa|sp/, 'Spa').replaceFirst(/eng|en/, 'Eng').replaceFirst(/jp|ja/, 'Jap')}{'UNKNOWN'}) + ' - '}
GFOLehran
Posts: 3
Joined: 17 Jul 2020, 09:24

Re: [HELP] Format chain fails

Post by GFOLehran »

kim wrote: 19 Jul 2020, 16:13

Code: Select all

{(audio.size() > 2 
	? 'Multi'
	: audio.size() > 1
		? 'Dual'
		: any{audio.language[0].replaceFirst(/es|spa|sp/, 'Spa').replaceFirst(/eng|en/, 'Eng').replaceFirst(/jp|ja/, 'Jap')}{'UNKNOWN'}) + ' - '}
Many thanks, i change UNKNOWN to Jap beause this chain is for anime.

I am seeing that the fansub group is not usually defined, but if it is in the name in first position (usually between [] or ()) I am trying ways but I am not able.

Code: Select all

{any{ '[' + fn.matchAll(/Erai-raws|Puyasubs/)*."some that can define $group"}
{"[$group]/"}/
The same thing happens to with crc32, but in this case it is in the end. Although it is better to calculate it if it is possible
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: [HELP] Format chain fails

Post by kim »

this is wrong

Code: Select all

{any{ '[' + fn.matchAll(/Erai-raws|Puyasubs/)*."some that can define $group"}
{"[$group]/"}/
SyntaxError: missing token: }
remember to test format in the GUI

Code: Select all

{ any{'one'}{'two'} }
so:

Code: Select all

{ any{fn.matchAll(/Erai-raws|Puyasubs/)}{"[$group]"} }
btw Erai-raws and Puyasubs should be on the group list, so no need to "matchAll"
viewtopic.php?f=5&t=4

also the order (matchAll as the backup)

Code: Select all

{ any{"[$group]"}{fn.matchAll(/Erai-raws|Puyasubs/)} }
maybe you can use (if Fansub group not on list)

Code: Select all

{ any{"[$group]/"}{fn.match(/\w+-Fansubs?/)} }
Post Reply