Comparison between series total episodes and season episodes

All about user-defined episode / movie / file name format expressions
Post Reply
lemon389
Posts: 15
Joined: 24 Sep 2023, 22:25

Comparison between series total episodes and season episodes

Post by lemon389 »

Hello,

I kindly request your support for the following situation I'm facing with FileBot.

Goal: To write the absolute number in an anime series only when required.

Scenario:
I have the total amount of episodes for the series with: {episodelist.size()}
I have the total amount of episodes for the actual season with: {episodelist.findAll{ s == it.s }.e.max()}
Expectation: Compare above data, if the count of episodes it's the same for both, then, absolute numbers are not required, otherwise, I will write absolute numbers.

Problem:
The following sentence is always true, despite the series, I changed the comparison from "!=" to ">" and then I receive an error.
I believe that the root cause is that one (or both?) values are not integer, therefore, they can not be compared, but I was not able to force them as integer to be able to perform such comparison.

Can you please support me?

Groovy: Select all

{{episodelist.size()} != {episodelist.findAll{ s == it.s }.e.max()} ? {absolute} : null}
Error:

Code: Select all

"Expression yields empty value: Cannot compare __script_411ad9ab5f5328afaefd0ef0b7d3ccfb_85$_run_closure1 with value '__script_411ad9ab5f5328afaefd0ef0b7d3ccfb_85$_run_closure1@310986dc' and __script_411ad9ab5f5328afaefd0ef0b7d3ccfb_85$_run_closure2 with value '__script_411ad9ab5f5328afaefd0ef0b7d3ccfb_85$_run_closure2@5898f42e'"
User avatar
rednoah
The Source
Posts: 22805
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Comparison between series total episodes and season episodes

Post by rednoah »

e.g.

Format: Select all

{ episodelist.size() != episodelist.findAll{ s == it.s }.e.max() ? absolute : null }
:arrow: :arrow: Learn how {expressions} work and useful Helper Functions



e.g. maybe you could just do "add absolute numbers to shows that have more than one season" though:

Format: Select all

{ sc > 1 ? absolute : null }
:idea: Please read the FAQ and How to Request Help.
lemon389
Posts: 15
Joined: 24 Sep 2023, 22:25

Re: Comparison between series total episodes and season episodes

Post by lemon389 »

I was overcomplicating things... thanks for your support!
Post Reply