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

import:
    move:       yes
    copy:       yes
    write:      yes

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

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

Thanks!

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

Hello,
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]
        else:
            return '_none_'

…with the lastgenre configuration:

lastgenre:
    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!

:wink: