Can you use inline plugin variable in searches?


#1

I’ve created a av_bitrate album field in the inline plugin settings.
Is it possible to use such a variable in searches?

I’m asking this because I would like to find a way how I can search for all albums that have e.g. a lower average MP3 bitrate than 193 so that I can replace them with better quality rips.

So I’m looking for a query with which I can define file type and av_bitrate.
I’ve tried
beet ls -a format:MP3 '$av_bitrate':<193
But that didn’t work

Thanks, Jan


#2

You’ll want to check out the types plugin, which lets you mark your custom fields as numeric (for example) so you can use range queries:
https://beets.readthedocs.io/en/v1.3.17/plugins/types.html

Then check out the syntax for this kind of query:
https://beets.readthedocs.io/en/v1.3.17/reference/query.html#numeric-range-queries

Namely, you’ll want something like av_bitrate:.193.


#3

Thanks a lot, that worked like a charm.

Just reporting back if others seek solutions:
I have av_bitrate calculated per album with the inline plugin.
I do this to be able to parse the av_bitrate in my path like this:

/Albums/Common/The People (2007) (MP3 177)

With the following command I can filter all MP3’s with (in this case) a average bitrate lower than 193 Kbps.

beet ls -a format:MP3 av_bitrate:..193 -f "\$av_bitrate \$path"

I add the -f "\$av_bitrate \$path" to print the av_bitrate and the path in the terminal output. Like this:

128 /Volumes/Tunez/Albums/Aphex Twin/…I Care Because You Do (1995) (MP3 128)
192 /Volumes/Tunez/Albums/Fiona Apple/Extraordinary Machine (2005) (Jon Brion-produced leak 2005) (MP3 192)

One thing that I didn’t succeed in is to print the output like this which would have been nicer:

128 - Aphex Twin - …I Care Because You Do (1995)
192 - Fiona Apple - Extraordinary Machine (2005)

But that might require black belt formatting. Any ideas are welcome.

Thanks, Jan