Beets: Sort That Music Library

For the longest time and like a total madman, I did the unthinkable – I manually handled the sorting of my audio library. They were dark, dark days. What this article is going to hopefully help with is if this is where you are in your life, there’s a better way and its name is Beets.

Before we proceed, what is Beets? The Beets website summarizes it as so:

The purpose of beets is to get your music collection right once and for all. It catalogs your collection, automatically improving its metadata as it goes using the MusicBrainz database. Then it provides a bouquet of tools for manipulating and accessing your music.

Installation

For me being a Debian user, installation is simple and this will be the same under any Ubuntu fork and the like:

$ sudo apt install beets

It’s worth mentioning that there are a bunch of useful plugins that may themselves have their own separate dependencies. The documentation for a given plugin should mention this.

Configuration

I won’t even attempt to get into the configuration options for Beets as there are potentially many depending on your needs and wants plus any plugins you’re using will mostly have their own sets of configuration options.

As a reference point to get you started, here’s my configuration which is saved to ~/.config/beets/config.yaml:

directory: ~/Music

import:
    write: yes

    move: yes
    copy: no
    delete: no

    autotag: yes
    timid: no

    resume: ask
    incremental: no
    none_rec_action: ask
    log:

    quiet: no
    quiet_fallback: skip
    default_action: apply

    singletons: no
    languages: []
    detail: no
    flat: no

original_date: no
per_disk_numbering: no

clutter: ["Thumbs.db", ".DS_Store", "*.m3u", "*.jpg"]
plugins: [scrub, mbsync]

scrub:
    auto: yes

As you can see I run a pretty simple ship here with my configuration. The plugins I am using scrub unnecessary metadata from files and mbsync is a handy plugin that will update any changes made in ID3 information that may have been changed or updated since something was initially imported.

There are plugins that do awesome things like fetch album art, embed said album art, etc. I have another way of doing this that I covered in a previous article which just makes a little more work for myself, but you’re probably smarter than that and will make use of a Beets plugin to do this.

Populate That Database

Once you have your configuration in place, it’s time to import your music which will create a SQLite database with this command:

$ beet import ~/Music

This command also assumes that like myself you store your music under ~/Music. If you store it somewhere else, the last part of that command should reflect that path accordingly.

Depending on the size of your music collection this can take a while. On top of scanning your music collection and writing to a database, it’s also remotely fetching ID3 information from MusicBrainz and fixing the tags in your actual audio files. For the most part this should be automatic. Occasionally it will stop to ask what you want to do in the event there are multiple options for an album, if the music files themselves are missing ID3 tags altogether, etc.

Alright – So Now What?

If things went as they should’ve, you’ll have a nice clean music collection with proper ID3 tags, embedded album art (if that’s your thing), and a handy database which is simple to interface with through some commands.

As a simple example, here’s some info about my music library at the moment:

john@aegean:~$ beet stats
Tracks: 4998
Total time: 2.1 weeks
Approximate total size: 39.0 GiB
Artists: 273
Albums: 429
Album artists: 155

Whenever you add something new to your library you’ll need to add it with the command we used earlier except specifying what was added. For example:

$ beet import ~/Music/Artist/Album

Bye

Welp, enjoy your beautifully sorted music library that you hopefully no longer maintain manually.