I need some help getting the full potential out of beets

I’ve set up a working version of beets, but there are still some functions that I’m missing or I’m not comfortable with the way they work. It might be that beets is not able to cover those functions the way I want, but I also feel I haven’t really understood the full potential of beets yet. Those are the things I want to achive:

  • I would like to use “genre categories” for organizing my music. This means being able to tag my music with distinct and even multiple genres, but then organizing them into a category (for example tag an album with the genres “Psychedelic Rock” and “Stoner Rock”, but then move that album into the “Rock” folder). Lastgenre only let’s me canonicalize my genres. The bucket plugin seemed interesting, but the way I understood it I can’t define my own buckets (for example put everything from [“Tech House”, “Deep House”, “Drum And Bass”, “Techno”] into the bucket “Electronic”). Is there a way around this?
  • Is there a way to replace fields with another value? I feel like the last.fm genres don’t necessarily follow the wikipedia list of genres, so using the lastgenre plugin will skip the genre “metal” as this is not a distinct genre (or I whitelist it, but then I have a “heavy metal” and a “metal” folder). Is there a way to generally replace the “metal” genre field with “Heavy Metal”?
  • I have lots of albums in a lossless format, but I would like to keep a lossy version, too. Is there a way to automatically rename the lossless albums on importing? I tried using the if condition in my path settings like this: default: $genre/%if{$format=="FLAC", $albumartist - $album (lossless), $albumartist - $album}/$track. $title, however, beets is putting “(lossless)” behind every album now (even behind lossy formats). EDIT: Apparently the if condition only checks for nonempty / nonzero values and doesn’t allow boolean operators. Found a solution by using the inline plugin instead.
  • Is there a way to conveniently convert music on import? I would like to convert everything that is not in the opus format to opus. At best, the convert plugin should convert all formats to opus, but keep all files that are in lossless format (and import them, too), while replacing all other formats (like mp3).

I feel like the inline plugin is quite powerful and might be able to cover my first points. I’m going to take a deeper look into that. Besides that, do you have any tips on how to implement my whishes?

And for the sake of completeness, here’s my full config file:

directoy:       ~/Music
library:        ~/.config/beets/library.db
plugins:        discogs embedart fetchart lastgenre convert

    move:       yes
    copy:       yes
    write:      yes

    default:    $genre/$albumartist - $album/$track. $title
    singleton:  $genre/$artist - $title
    comp:       $genre/$album/$track. $title

    auto:       yes
    canonical:  yes
    whitelist:  ~/.config/beets/whitelist.yaml
    canonical:  ~/.config/beets/genres-tree.yaml
    force:      yes
    auto:       no
    command:    ffmpeg -i $source -acodec libopus -b:a 128k -vbr on -compression_level 10 $dest
    extension:  opus


For categorizing genres, you might try an inline that looks like this:

gencat: |
    return {
      'Stoner Rock': 'Rock',
      'Psychedelic Rock': 'Rock',
    }.get(genre, genre)

That is, look up the names you want to shorten in a map you declare.

For straight-up replacements, you might try the rewrite plugin.

Finally, the convert plugin has an auto option that, I think, does exactly what you want. Give that a try!

1 Like

I am new to beets and I find it great but I have the same need as Horrorente. I’ve been takien a look at the documentation of the inline plugin and I feel a bit lost. It would be great if we could configure the lastgenre plugin to store the full genre in the usual tag %genre% and create/update a new %cartegory% tag with the canonical/whitelisted version of genre. If someone knows of a tutorial more in depth of the inline plugin to understand better how to use it I would deeply appreciate it.

Thanks for all the great work from the devs.

Hi! Have you tried the configuration listing from my previous comment? Did that work?

Did you find a a way to replace fields with another value?
Trying to do the same thing to replace some genres like the one you mention metal with heavy metal, rock with hard rock, pop with latin pop etc…

I’ve been looking at doing exactly this, and indeed had come up with the following using the inline plugin:

top_genre: |
        if genre:
            genres = genre.split(';')
            return genres[-1]
            return '_none_'

…with the lastgenre configuration:

    auto: yes
    canonical: yes
    count: 3
    force: no
    min_weight: 25
    prefer_specific: yes
    source: album
    separator: '; '
    whitelist: yes

…where I was obtaining genres using specificity, and the inline function returns the last (i.e. least) specific genre to be the ‘top’ (level) or ‘parent’ genre.

The problem I ran in to (very quickly) is the sheer inconsistency with which music is ‘tagged’ with genres!

… (because it is open to all potential forms of people’s ‘personal interpretations’, stupidity and/or outright sabotage.)

For example, I had a couple of tracks by Pennywise which ended up tagged with the genres:
Punk Rock; Punk; Electronic
… my only assumption here is that someone (or rather, a lot of people, since last.fm no doubt use some form of aggregation-algorithm or community voting) was thinking along the lines of:
“Well… they play *electric* guitars so the music must be considered to be ‘electronic’, right?!”  :man_facepalming:

So, working now with the principal that (ultimately) only you know how you want to categorise your music (a very beets philosophy) I was planning to use a flex-attibute on items to store an organisational genre tag (‘org_genre’, or whatever) which is then (thankfully) automatically available to the path-formats.

Populating this field may seem like a labour intensive task, but given that beets’ powerful search capabilities are available to the modify command it becomes considerably easier to do en masse

e.g. beet modify genre:rock org_genre="rock"

– note that the query here returns all items whose genre field contains the word ‘rock’, so 'alternatvie rock', 'industrial rock', 'progressive rock’ … etc. etc.

Jut bear in mind that there’s always going to be a lot of ‘gotcha’ situations when tracks have multiple genres, such as 'alternative metal; alternative rock; nu-metal' … so picking/filtering which to tag with which (in this case 'metal' or 'rock') may still be an exercise of patience and persistence!


It might be worth considering using the “grouping” tag for this, which I’ve been doing for quite some years now. This is supported if you use MusicBrainz Picard and have fdemmer’s last.fm.ng plugin enabled.

It would place Rock in the grouping, and either Rock; Progressive Rock or just Progressive Rock in the genre, depending on configuration.

Maybe something like this logic could be introduced into beets’ last.fm plugin? I quite like fdemmer’s plugin, since it allows things like

  • adding extra info from last.fm like grouping, genre, artist country, mood
  • specifying personal whitelists
  • specifying which genre tags should be translated into others
  • specifying casing exceptions (“Aor"→"AOR”)
  • getting decades (“1990s”)

I don’t know if using grouping might have adverse effects with classical music, simply because I have none. But I can tell that using the grouping helps me to have a “basic genre” (kinda bucket/category) and replicating the one genre kept in grouping as the first genre in the multivalue genre field even keeps it compatible with older software that has no grouping field (like when searching for “genre contains …”).

And of course it’d be a great plus if beets would handle this the same way Picard + last.fm.ng does. :slight_smile:

And I like beets’ “genre/subgenre tree” much better than anything else—in combination with said changes it would simply rock, since it could “consolidate” subgenres into their “official” more generic genre.