Trying to understand filtering

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
Zalcore
Posts: 3
Joined: 07 May 2019, 16:30

Trying to understand filtering

Post by Zalcore » 07 May 2019, 17:14

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

User avatar
rednoah
The Source
Posts: 16123
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Trying to understand filtering

Post by rednoah » 07 May 2019, 18:53

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
:idea: Please read the FAQ and How to Request Help.

Zalcore
Posts: 3
Joined: 07 May 2019, 16:30

Re: Trying to understand filtering

Post by Zalcore » 07 May 2019, 19:41

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? :)

User avatar
rednoah
The Source
Posts: 16123
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Trying to understand filtering

Post by rednoah » 07 May 2019, 20:43

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.
:idea: Please read the FAQ and How to Request Help.

Zalcore
Posts: 3
Joined: 07 May 2019, 16:30

Re: Trying to understand filtering

Post by Zalcore » 08 May 2019, 15:29

Now it's working perfectly. Thanks alot!

Post Reply