Page 1 of 1

use expressions in manual query (--q )?

Posted: 17 Aug 2020, 19:29
by andy22
Similar to: viewtopic.php?f=6&t=11137&p=46409&hilit=anidb#p46409

I do a pre-pass (via a hasher tool) that actually does a filelookup via AniDB hash and i store the ID's in the temp filename "Seriesname - Ep01 - [AID123456]"

Now filebot could directly do a lookup via this ID, yet the expression is not evaluated for "--q".

Code: Select all

filebot --action TEST --log INFO -rename "Seriesname - Ep01 - [AID123456].mkv" --db AniDB --q "{fn.match(/AID(\d{1,9})/)}"

Code: Select all

Failed to fetch episode data: [{fn.match(/AID(\d{1,9})/)}]
Failed to identify or process any files
So is there a way to make this work or workaround?

Re: use expressions in manual query (--q )?

Posted: 18 Aug 2020, 04:08
by rednoah
The --q option can be used in the following ways:

Code: Select all

--q 123456

Code: Select all

--q "Series Name"

If you want to pass in a specific --q option value for a specific file, then you need to take care of that in a higher level script and then call filebot --q 123456 accordingly for each file.


You can user PowerShell or bash for that but if you're familiar with Groovy then a custom script will be easier:
https://www.filebot.net/script.html

Code: Select all

args
.getFiles{ it.video }
.groupBy{ it.name.match(/AID(\d{1,9})/) }
.each{ aid, fs ->
	rename(file: fs, query: aid)
}

Re: use expressions in manual query (--q )?

Posted: 18 Aug 2020, 09:02
by andy22
ok thanks for the quick reply, guess i need to dig deeper into Groovy.

Re: use expressions in manual query (--q )?

Posted: 20 Aug 2020, 11:02
by rednoah
FileBot r7926 adds support for --q expressions as envisioned in the OP:

Code: Select all

--q "{fn.match(/AID(\d{1,9})/)}"
This will also enable other use cases such a "search by parent folder name"

Code: Select all

--q "{folder.name}"
as well as allow for completely manual / custom script query auto-detection:

Code: Select all

--q /path/to/query.groovy

Re: use expressions in manual query (--q )?

Posted: 20 Aug 2020, 11:44
by andy22
oh cool thanks!

Re: use expressions in manual query (--q )?

Posted: 16 Feb 2022, 11:36
by rednoah