Page 1 of 1
					
				Binding "genre": undefined
				Posted: 06 Jan 2025, 11:49
				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 ?
 
			 
			
					
				Re: Binding "genre": undefined
				Posted: 06 Jan 2025, 12:34
				by rednoah
				
			 
			
					
				Re: Binding "genre": undefined
				Posted: 06 Jan 2025, 13:05
				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' } }
 
			 
			
					
				Re: Binding "genre": undefined
				Posted: 06 Jan 2025, 13:21
				by rednoah
				Your code is unnecessarily repetitive... Here's how I'd express the code you pasted above:
 
			 
			
					
				Re: Binding "genre": undefined
				Posted: 06 Jan 2025, 15:23
				by SnakeBonD
				Indeed, I still have some difficulty optimizing the code,  

  but congratulations, you managed to optimize it by 75%!  
 
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.  
