Page 1 of 1
Look who's back, back again... Match array entry based on minimum runtime?
Posted: 03 May 2026, 07:04
by Wolfie
I'll make this simple, I hope...
Groovy: Select all
array:[
"188" : "Extended",
"151" : 'Special",
]
Is there a way to match it so that it "hits" when the runtime matches or exceeds the number of minutes (on the left)?
I have a 188 minute version that is being detected as 189 minutes.
I'm not opposed to reversing the order if there's a way to regex match the value (right) and then use the key (left).
Re: Look who's back, back again... Match array entry based on minimum runtime?
Posted: 03 May 2026, 12:32
by rednoah
Re: Look who's back, back again... Match array entry based on minimum runtime?
Posted: 04 May 2026, 07:04
by Wolfie
Groovy: Select all
array.findResult{ k, v -> minutes.toString() >= k ? k : null }
This worked. I prefer the key, as the key is... well... the key to what I needed.
Having the key (minutes) allows me to use it beyond that one part, and can easily get the value.
The movie is Superman (1978, not the joke that came out in 2025). The theatrical is 143 minutes (2h23m), special is 151 minutes (2h31m), and extended is 188 minutes (3h08m). But I guess it has enough extra padding that it was registering as 189 minutes. I add the time to the folder name to help separate the different versions, and noticed that it was trying to stuff the extended into a new folder when it should have remained in its existing folder. I recently added the `{imdb-}` tag to the movie names, so needed to start parsing my library again. Also wanted to make sure that an edition would be added (if appropriate), since sometimes it's not in the file itself. I'm rather picky about how the Superman movie is treated, because it's a masterpiece and has influenced how hero movies have been getting made. It's even had a big influence on many of the Marvel movies.

Re: Look who's back, back again... Match array entry based on minimum runtime?
Posted: 04 May 2026, 09:23
by rednoah
You'll probably want to compare the numerical values:

If you compare string values, then "9" is greater than "10", which is probably not what we want here.
Re: Look who's back, back again... Match array entry based on minimum runtime?
Posted: 05 May 2026, 04:36
by Wolfie
Even better. I didn't know how to do it to integer, and yes, definitely better than comparing strings when dealing with numbers.
Thanks.