Skipping Specific Genre?

Support for Windows users
Post Reply
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

Skipping Specific Genre?

Post by DevXen »

Most of my 'Animated' shows are sorted into an [Animation] Folder. But I have enough now, I'd like to orgaize those into Genres. - But the first Genre is usually 'Animation' - How would I go about Detecting if Animation is in the genre list. Using that to put them in an [Animation] Folder. Then Skipping animation then pulling the next Genre (Assuming Animation was the first one) to put into that genre sub-folder? For Exmaple:

[Animation]\Action
[Animation]\Adventure
[Animation]\Comedy
etc.


Thanks,
-Dev
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Skipping Specific Genre?

Post by rednoah »

This will do:

Code: Select all

{'Animation' in genres ? 'Animation/' : null}
{genres.minus('Animation')[0]}
Line 1: Add Animation if Animation is one of the genres
Line 2: Remove Animation from the list of genres and the pick the first one from the remainder
:idea: Please read the FAQ and How to Request Help.
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

Re: Skipping Specific Genre?

Post by DevXen »

That's Brilliant, I didn't know there was a genres.minus binding. I'll have fun with that. Thank you.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Skipping Specific Genre?

Post by rednoah »

It's just Groovy, so you can do things like [1,2,3] - 2 == [1, 3].
:idea: Please read the FAQ and How to Request Help.
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

Re: Skipping Specific Genre?

Post by DevXen »

so on a related question, i'm not needing to do it now. but one day it may come up.
if I wanted to do the same thing with mutilple genres. would it be best to just use the any{} for that?
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

Re: Skipping Specific Genre?

Post by DevXen »

Ooo I just thought of a practical use case for my last comment: Animated and Animation
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

Re: Skipping Specific Genre?

Post by DevXen »

FIgured out the minus Genre part:

Code: Select all

{genres.minus('Animation','animated')[0]}
Haven't messed with the other part yet.

Unfortunately, most cartoons appear to only Have Animation or Children as genres.
D'oh
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Skipping Specific Genre?

Post by rednoah »

In that case, I'd use a more generic and easy-to-maintain solution.

e.g. sort genres using custom sort order:

Code: Select all

{
	def genreOrder = ['Animation': 1, 'Action': 2].withDefault{ 100 }
	genres.toSorted{ genreOrder[it] }
}
:idea: The map part ['Animation': 1, 'Action': 2] can be read from a CSV file for easy maintenance.


Image
:idea: Please read the FAQ and How to Request Help.
Post Reply