I would like to rate the albums I listen to in 2021, and I figured I could use a flexible attribute field for this and the types plugin to set said field to int. I want to rate albums from 1 to 5 in .5 increments, so a rating like 0.5, 3.5, etc. Is this possible somehow?
If I try setting a 1.5 rating using beet modify -a album:album albumrating=1.5 beets tells me:
Album
albumrating: 0
Really modify, move and write tags? (Yes/no/select)
If I try beet ls -a -f '$albumartist - (%if{$original_year,$original_year,$year}) - $album%ifdef{albumdisambig, (%title{$albumdisambig}),}%ifdef{albumrating, ($albumrating),}' year:2021 then beets will return the album rating for the albums that has the field defined. For albums without the rating, $albumrating is returned.
That’s odd. So is %ifdef not working at all for that field? It might be worth doing some experimentation with beet ls -f to determine how it’s behaving for that and other fields—and whether it’s affected by the type you set for it.
No, %ifdef doesn’t seem to work on int or float flexattr fields as far as I can tell. If I disable the types plugin then %ifdef works again. I’m not quite sure how I should troubleshoot further unfortunately.
Looks like a straight-up bug to me—reading over the implementation of %ifdef, I can see now how it would be confused about types with a default value. That is, int or float fields will produce a '0' string for unset values through the formatter, which gets interpreted as non-missing. We clearly need better logic for this. Would you mind opening an issue on GitHub?