if genres undefined then...

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

if genres undefined then...

Post by peymanch » 20 Mar 2018, 15:46

hi
if genres is undefined then use ...
how to?

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

Re: if genres undefined then...

Post by rednoah » 20 Mar 2018, 17:41

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 » 21 Mar 2018, 10:43

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 » 21 Mar 2018, 18:26

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: 67
Joined: 30 Mar 2016, 11:14

Re: if genres undefined then...

Post by ChefGregS » 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'}

peymanch
Posts: 55
Joined: 22 Jan 2017, 12:19

Re: if genres undefined then...

Post by peymanch » 22 Mar 2018, 14:34

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: 67
Joined: 30 Mar 2016, 11:14

Re: if genres undefined then...

Post by ChefGregS » 22 Mar 2018, 21:30

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: 16092
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: if genres undefined then...

Post by rednoah » 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
:idea: Please read the FAQ and How to Request Help.

ChefGregS
Posts: 67
Joined: 30 Mar 2016, 11:14

Re: if genres undefined then...

Post by ChefGregS » 23 Mar 2018, 13:11

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: 755
Joined: 15 May 2014, 16:17

Re: if genres undefined then...

Post by kim » 23 Mar 2018, 18:04

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: 16092
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: if genres undefined then...

Post by rednoah » 23 Mar 2018, 23:01

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: 755
Joined: 15 May 2014, 16:17

Re: if genres undefined then...

Post by kim » 24 Mar 2018, 02:52

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

Code: Select all

{any{genres; ""}{'qwerty'}}
ALWAYS output
qwerty

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

Re: if genres undefined then...

Post by rednoah » 24 Mar 2018, 11:50

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: 75
Joined: 01 Feb 2014, 16:59

Re: if genres undefined then...

Post by DavidRTurner » 31 Mar 2018, 15:51

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