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
Skipping Specific Genre?
Re: Skipping Specific Genre?
This will do:
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
Code: Select all
{'Animation' in genres ? 'Animation/' : null}
{genres.minus('Animation')[0]}
Line 2: Remove Animation from the list of genres and the pick the first one from the remainder
Re: Skipping Specific Genre?
That's Brilliant, I didn't know there was a genres.minus binding. I'll have fun with that. Thank you.
Re: Skipping Specific Genre?
It's just Groovy, so you can do things like [1,2,3] - 2 == [1, 3].
Re: Skipping Specific Genre?
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?
if I wanted to do the same thing with mutilple genres. would it be best to just use the any{} for that?
Re: Skipping Specific Genre?
Ooo I just thought of a practical use case for my last comment: Animated and Animation
Re: Skipping Specific Genre?
FIgured out the minus Genre part:
Haven't messed with the other part yet.
Unfortunately, most cartoons appear to only Have Animation or Children as genres.
D'oh
Code: Select all
{genres.minus('Animation','animated')[0]}
Unfortunately, most cartoons appear to only Have Animation or Children as genres.
D'oh
Re: Skipping Specific Genre?
In that case, I'd use a more generic and easy-to-maintain solution.
e.g. sort genres using custom sort order:
The map part ['Animation': 1, 'Action': 2] can be read from a CSV file for easy maintenance.

e.g. sort genres using custom sort order:
Code: Select all
{
def genreOrder = ['Animation': 1, 'Action': 2].withDefault{ 100 }
genres.toSorted{ genreOrder[it] }
}

