List only the first match of a query

Hi there

I’m curious whether it is possible to limit the results beet returns to the first match or the first few matches?

Of course I can post process with ... | head, but this doesn’t work with beet info and similar.

Thanks for any pointers!

We don’t currently have a way to do that, but this issue tracks the need for such a capability:

Thanks @adrian.

I had the idea that a query plugin could provide this functionality, but a query plugin is probably not enough:

The documentation says that a plugin can add some keyword to the query (to indicate we want only the first record), but from what I can see plugins cannot hook into the output procedure of beets (to actually stop the output after the first record).

Or is there an easy way for plugins to hook into the output?

No, there’s nothing like that currently.

not sure what’s your use case here, but just in case : the random plug-in does it already (see it -n option


1 Like

Thanks a lot @martin! The random plugin comes indeed pretty close to what I’m thinking off! Cool!