Binding "genre": undefined

All about user-defined episode / movie / file name format expressions
Post Reply
SnakeBonD
Posts: 12
Joined: 23 Jan 2022, 15:09

Binding "genre": undefined

Post by SnakeBonD »

Hi,
For organize my movies animations I use this code:

Shell: Select all

else if (genre =~ /Animation/)									anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
else if (genres =~ /Animation/)									anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
But some movies dont have "genre" and return this error :

Shell: Select all

"Alex Exemple (2010)" could not be formatted: Expression yields empty value: Binding "genre": undefined
How can I use 'genre' or 'genres' verification if present otherwise we ignore it ?
User avatar
rednoah
The Source
Posts: 24009
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Binding "genre": undefined

Post by rednoah »

e.g.

Format: Select all

{ any{ genres =~ /Animation/ ? 'Animation' : 'Not Animation' }{ 'No Genre' } }
:arrow: Learn how {expressions} work and useful Helper Functions
:idea: Please read the FAQ and How to Request Help.
SnakeBonD
Posts: 12
Joined: 23 Jan 2022, 15:09

Re: Binding "genre": undefined

Post by SnakeBonD »

I use a list of conditions to define folder of ANIMATIONS:

Groovy: Select all

	def anime = null
		if (info.productionCompanies =~ /Toei Animation/)			anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
	else if (info.productionCompanies =~ /Ghibli/)					anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
	else if (info.productionCompanies =~ /Walt Disney Animation/)	anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
	else if (genre =~ /Animation/)									anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
	else if (genres =~ /Animation/)									anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
	else if (info.keywords =~ /live action and animation/)			anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
	else 															anime = 'M:/_MOVIES/'+plex.id+' ['+vf+' '+channels+']'
}
Can I integrate this in a condition ?
I want remove this:

Groovy: Select all

	else if (genre =~ /Animation/)									anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
	else if (genres =~ /Animation/)									anime = 'R:/_MOVIES_ANIMATION/'+plex.id+' ['+vf+' '+channels+']'
and replace by this :

Groovy: Select all

{ any{ genres =~ /Animation/ ? 'R:/_MOVIES_ANIMATION/' : 'M:/_MOVIES/' }{ 'No Genre' } }
User avatar
rednoah
The Source
Posts: 24009
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Binding "genre": undefined

Post by rednoah »

Your code is unnecessarily repetitive... Here's how I'd express the code you pasted above:

Format: Select all

{
	any
	{ if (genres =~ /Animation/ || info.productionCompanies =~ /Toei Animation|Ghibli|Walt Disney Animation/ || info.keywords =~ /live action and animation/) 'R:/_MOVIES_ANIMATION' }
	{ 'M:/_MOVIES' }
}
/
{
	plex.id % { allOf{vf}{channels}.joining(' ', ' [', ']') }
}
:idea: Please read the FAQ and How to Request Help.
SnakeBonD
Posts: 12
Joined: 23 Jan 2022, 15:09

Re: Binding "genre": undefined

Post by SnakeBonD »

Indeed, I still have some difficulty optimizing the code, :oops: but congratulations, you managed to optimize it by 75%! 8-)
It's exactly what I needed.
I tested it on a few films and it works perfectly!

Groovy: Select all

{
	any
	{ if ( genre =~ /Animation/
	|| info.productionCompanies =~ /Toei Animation|Ghibli|Walt Disney Animation|Ghibli|C.O.R.E. Feature Animation|DisneyToon Studios|Walt Disney Animation|Walt Disney Feature Animation|Disney Television Animation|Walt Disney Productions|DreamWorks Animation|Pixar|Rovio Animation|Sony Pictures Animation|Universal Animation Studios/ 
	|| info.keywords =~ /live action and animation/) 'R:/_MOVIES_ANIMATION' }
	{ 'M:/_MOVIES' }
}
/
{
	plex.id % { allOf{vf}{channels}.joining(' ', ' [', ']') }
}
Thank you very much for your help and your time. :P
Post Reply