Page 1 of 1

Trying to understand filtering

Posted: 07 May 2019, 17:14
by Zalcore
Trying to apply a filter so that torrents with a specific label use the age filter and all torrents with other labels ignore the filtering altogether but I can't seem to get it working.

filebot -list --q Firefly --filter "if (label == /test/) e < 5" --def ut_label=test
returns 4 episodes as expected

filebot -list --q Firefly --filter "if (label == /test/) e < 5" --def ut_label=other
won't return anything. I expected this to just ignore the filter.

I'm very limited in my understanding in these matters and would appreciate any help in getting this working the way I want it too, if possible.
Cheers

Re: Trying to understand filtering

Posted: 07 May 2019, 18:53
by rednoah
You'll want you filter to return true or false depending on your condition:

Code: Select all

label != /test/ || e < 5
This is true if and when (1) label not equals test, or (2) e < 5


As for why your original expression doesn't work, in this case, if label is not test, then the result is neither true nor false, which is considered false:

Code: Select all

if (label == /test/) e < 5
It would work though, if your else-code were to return true:

Code: Select all

label == /test/ ? e < 5 : true

Re: Trying to understand filtering

Posted: 07 May 2019, 19:41
by Zalcore
I see! Thanks alot for the explanation!
I got it working!

Follow up question, right now, if there is no label it won't work. Any way to fix that? :)

Re: Trying to understand filtering

Posted: 07 May 2019, 20:43
by rednoah
In that case, this will do:

Code: Select all

any{label != /test/ || e < 5}{true}
:idea: Explanation: If label is undefined, the filter expression errors out, and that is also is interpreted as false. So we catch these errors and return true instead.

Re: Trying to understand filtering

Posted: 08 May 2019, 15:29
by Zalcore
Now it's working perfectly. Thanks alot!