Query album flexible attribute and get a list of tracks?


For flexible attributes set on albums, can I still query them to get a list of tracks?

For instance, I have started adding my personal rating of albums to a flexible attribute called albumrating. It made sense to me to use this field. So I can now get a list of albums with certain ratings using beet ls -a albumrating:2 for instance. I would like to use the same flexible attribute to get a list of tracks to output to a playlist.

Though upon reading this reply it does seem like what I’m wanting to do would require the flexattr albumrating to be set for each track, on reading this note:

What would be the best way to be able to generate playlists based on my albumrating flexattr? To just rate the items instead? :wink:

I believe this PR does what you want?

It’s a great PR and I am (or rather the community is) delinquent on reviewing and merging it. Any help would be greatly appreciated.

It looks like this is what I’m after, yes! Thanks for pointing it out, I was negligent in searching the issues before posting. I wish I could help, I am however entirely code-illiterate. For now I have a few (manual) work-arounds. :slight_smile:

1 Like

I see that this PR was merged - great work to everyone involved! :slight_smile:

Currently, I am installing/updating beets from the Arch Linux AUR. I assume this version should include the merged PR? The version information I see is the following:
aur/beets-git 1.4.9.r1031.ee0467e-1 [+22 ~0.08] [Installed: 1.4.9.r1140.gc4347960-1]

Or should I maybe follow the instructions in the FAQ?

So, the reason I’m asking is that the fallback doesn’t seem to work for me.
beet ls -a album_flexible_attribute:something works, but no results for beet ls album_flexible_attribute:something.

I just tested c4347960 (current master branch as of this writing) and the fallback is working with my library. I don’t use/know Arch, but the version string 1.4.9.r1140.gc4347960-1 does suggest to me that it’s using the same version I tested, since c4347960 is part of it. Still: maybe your beets executable isn’t actually that version? What does beet --version say? It should say 1.5.0. Also check which beet.

The way I have installed beets on my system is:

git clone git://github.com/beetbox/beets
cd beets
pip install -e .

while in a virtual environment. (I use conda, but virtualenv would also work.)

You can also ask python which beets-related paths it’s using:

python -c 'import sys; print([p for p in sys.path if "beets" in p])'

If the paths don’t match your expectations, that would suggest the wrong version of beets is being used.

Thanks for your reply and your help! How is the fallback working for you? It’s possible I’m using it the wrong way. For Album flexible attributes I have albumrating. When querying using beet ls -a year:2020 albumrating:1..5 it’ll list the albums I’m looking for. If I omit -a there is no output, and I would’ve expected the fallback to be listing the tracks for the albums with albumrating:1..5. Am I understanding the intended functionality correctly?

╰─❯ beet version
beets version 1.5.0
Python version 3.9.2
plugins: edit, fetchart, importadded, importfeeds, info, inline, lastimport, mbcollection, mbsync, mpdstats, mpdupdate, originquery, playlist, scrub, smartplaylist, types, zero
╰─❯ which beet
╰─❯ python -c 'import sys; print([p for p in sys.path if "beets" in p])'

@pandatroubles Hmm… just speculation, but perhaps this new feature isn’t interacting well with the types plugin? I assume you have albumrating declared as an int so that the 1..5 works? Does it work for you with string-based flexible attributes? I’ve only tested it with strings on my system.

Another difference I see is that I’m using python 3.8.6. It’s possible 3.9 breaks behavior somehow. You could try with Python 3.8 just to rule that out.

I had no idea what you meant by this, so I was about to set up a virtual machine to test it out. Instead I did manage to set up a virtualenv on my main machine to test this, and it works as intended.

╰─❯ /home/boredpanda/beets-test/beets/beet --version                    
beets version 1.5.0
Python version 3.8.8
plugins: edit, importadded, importfeeds, info, inline, mbcollection, mbsync, mpdupdate, playlist, scrub, smartplaylist, types, zero

And I used your installation method.

git clone git://github.com/beetbox/beets
cd beets
pip install -e .

It actually seems like the version of beet that I’m using, is the wrong one. I’ll try and remove beet from my system and re-install.

1 Like