if genres undefined then...

All about user-defined episode / movie / file name format expressions
Post Reply
peymanch
Posts: 55
Joined: 22 Jan 2017, 12:19

if genres undefined then...

Post by peymanch »

hi
if genres is undefined then use ...
how to?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: if genres undefined then...

Post by rednoah »

e.g.

Code: Select all

any{genres}{'No Genres'}
@see viewtopic.php?f=5&t=1895
:idea: Please read the FAQ and How to Request Help.
peymanch
Posts: 55
Joined: 22 Jan 2017, 12:19

Re: if genres undefined then...

Post by peymanch »

thanks but i want if genres are defined then do nothing! else if genres are undefined write "qwerty"
peymanch
Posts: 55
Joined: 22 Jan 2017, 12:19

Re: if genres undefined then...

Post by peymanch »

peymanch wrote: 21 Mar 2018, 10:43 thanks but i want if genres are defined then do nothing! else if genres are undefined write "qwerty"
Please answer
ChefGregS
Posts: 99
Joined: 30 Mar 2016, 11:14

Re: if genres undefined then...

Post by ChefGregS »

He answered you...did you not see it?

any{genres}{'No Genres'}

simply change No Genres to whatever you want..

any{genres}{'qwerty'}
peymanch
Posts: 55
Joined: 22 Jan 2017, 12:19

Re: if genres undefined then...

Post by peymanch »

ChefGregS wrote: 22 Mar 2018, 09:38 He answered you...did you not see it?

any{genres}{'No Genres'}

simply change No Genres to whatever you want..

any{genres}{'qwerty'}
no dear friend i don't want write genres when genres are defined!!!
only i want write"qwerty" when genres are undefined
for example i have 3 movies
1- Crash-[1080p]-[Crime].mkv
2- Lukochuri-[480p]-[].mkv
3- Blue Jay-[1080p]-[Drama].mkv

i want first and third movies go to "movies" folder no "drama" or "crime" folder!!!
but second movie that hasn't genre go to "qwerty" folder
do you see???
ChefGregS
Posts: 99
Joined: 30 Mar 2016, 11:14

Re: if genres undefined then...

Post by ChefGregS »

I gotcha.... So you are wanting to do a simple if then else statement. If genre is defined ignore it...and if it isn't defined then use xxxxxx folder.

Code: Select all

M:/{vf == /2160p/ ? 'Movies 4K' : vf =~ /1080p|720p/ ? 'Movies HD' : 'Movies'}
That is how I start my code. It verifies the size of the movie (4k, HD, SD) and puts the movies into the correct folder. So for your case, try this (M is my media drive...use whatever yours is instead.):

Code: Select all

M:/{genre == null ? "qwerty" : "Movies"}/
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: if genres undefined then...

Post by rednoah »

You could do this:

Code: Select all

any{genres; "Yes Genres"}{"No Genres"}
:arrow: This code works due to the Unwind-on-Undefined Behaviour. Checking for null won't work, because the {genres} does not yield a null value when undefined, but throws an exception yielding no value at all.

@see viewtopic.php?f=5&t=1895
:idea: Please read the FAQ and How to Request Help.
ChefGregS
Posts: 99
Joined: 30 Mar 2016, 11:14

Re: if genres undefined then...

Post by ChefGregS »

rednoah wrote: 23 Mar 2018, 06:21 You could do this:

Code: Select all

any{genres; "Yes Genres"}{"No Genres"}
:arrow: This code works due to the Unwind-on-Undefined Behaviour. Checking for null won't work, because the {genres} does not yield a null value when undefined, but throws an exception yielding no value at all.

@see viewtopic.php?f=5&t=1895
Ahhh.. I tested it using other fields as I don't have any movies currently that don't have a genre listed. I wasn't aware it wouldn't give a null. And I was so proud of being able to help someone. DOH! LOL
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: if genres undefined then...

Post by kim »

well he was asking for it do nothing if genre found, so this will not do ;)

Code: Select all

any{genres; "Yes Genres"}{"No Genres"}
the only way I can make it "do nothing" it this:

Code: Select all

{ (any{genres; 'Yes Genres'}{'No Genres'}).replace(/Yes Genres/,'') }
but what he really wants (I think) is this:

Code: Select all

{any{genres; genres.take(1)}{'qwerty'}}
or is it this way ?

Code: Select all

{any{genres; 'movies'}{'qwerty'}}/{ny}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: if genres undefined then...

Post by rednoah »

Why not just return an empty String? :lol:

Code: Select all

any{genres; ""}{"No Genres"}
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: if genres undefined then...

Post by kim »

well for a very good reason.... does NOT work ;)

Code: Select all

{any{genres; ""}{'qwerty'}}
ALWAYS output
qwerty
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: if genres undefined then...

Post by rednoah »

I see. I guess "" is also evaluates to Groovy Truth FALSE and so it moves on. :lol:

I guess it'll have to return at least a non-Empty String to work:

Code: Select all

any{genres; ' '}{'querty'}
:idea: Please read the FAQ and How to Request Help.
DavidRTurner
Power User
Posts: 85
Joined: 01 Feb 2014, 16:59

Re: if genres undefined then...

Post by DavidRTurner »

My 2 cents on the issue:

For months now, the check in my code for (no genre exists) has failed and caused an error - and I think this is the original poster's question:

Code: Select all

If a genre exists then
   Show me nothing
Else
   Show me 'qwerty'
Endif
I use:

Code: Select all

{((genres ?: ['GENRE']))}
but I now get

Code: Select all

[Expression yields empty value: Binding "genres": undefined]
I have been unable to find any way around this.

The simplest (theoretical) answer is

Code: Select all

{((genres ? "": ['qwerty']))}   <--- show a blank if a genre exists, else show 'qwerty"
but it doesn't work...
Post Reply