The Moving Parts
Outcome: you can name the five parts of a beets setup and say which one is misbehaving when something surprises you. Most beets confusion is really a question — where does that fact live? — and this chapter answers it part by part.
1. The config file
A small YAML file (chapter 4 shows
the lab's, complete) that names the
two locations below, the import
behaviour, and which plugins are on.
Beets reads ~/.config/beets/config.yaml
by default; beet -c somefile.yaml
uses another, which is how the lab
kept three variants side by side.
Nearly every "beets ignored my
setting" story is a config file being
read from a different place than the
one edited — beet config prints
the merged result and settles it.
2. The library database
One SQLite file (the lab's is
library.db, a few dozen kilobytes
for six tracks; yours will grow to
megabytes, not gigabytes). It holds
a record for every item (track)
and every album, mirroring the
tags, plus beets' own bookkeeping:
where each file lives, when it was
added, and flexible extra fields.
beet ls reads only this file —
which is why the database can
disagree with your files' tags when
something edited them behind beets'
back, and why chapter 6's update
exists. When beets first creates or
upgrades a database it writes backup
copies beside it before migrating —
the lab's transcript t00 caught a
screenful of those messages; they are
a safety feature, not an error.
3. The directory
The folder tree the files live in,
named by the directory setting.
Its layout is not fixed: it is
generated, at import and at beet move
time, from path formats — templates
like the default
$albumartist/$album%aunique{}/$track $title
The %aunique{} piece deserves its
name in lights early: when two album
records would produce the same path,
it keeps them apart by numbering the
folders (First Experiments [1],
First Experiments [2]). Chapter 6
shows it earning its keep. Change
the templates and beet move re-files
the library to match; the templates
are a view of the database, not a
property of the files.
4. The tag layer
Beets reads and writes tags through
a library called MediaFile (built
on Mutagen), which speaks the tag
dialects of MP3 (ID3), FLAC and Ogg
(Vorbis comments), MP4, and many
more, and presents one uniform set of
field names to the rest of beets.
Two consequences matter. First,
beets works the same whatever format
your files are — the lab mixed MP3
and FLAC albums without noticing a
seam. Second, fields have a
shape: some are single-valued, and
in current beets some — genres is
the one this guide trips over — are
lists. beet info shows a file's
fields as the tag layer sees them,
which makes it the referee when the
database and a file disagree
(chapter 5).
5. MusicBrainz and the plugins
MusicBrainz is the external part:
an open, community-edited database
of recordings, reached over the
network by the autotagger (chapter 7)
and by nothing else in the core tool.
Its identifiers — mb_trackid,
mb_albumid — are stored on matched
items, and several features quietly
assume them; the duplicates plugin's
default grouping is one (chapter 8).
Plugins are beets' second half:
optional modules, switched on by
name in the config, that add commands
and import-time behaviour. This guide
exercises five — duplicates,
info, fetchart, embedart, web
— and the catalogue runs to dozens:
chroma (acoustic fingerprinting),
lyrics, replaygain, smart playlists,
and more. A plugin that fails to
load (the lab met this: web needs
the Flask package, which is not part
of beets itself) prints an error at
startup and beets carries on without
it — worth remembering when a command
is suddenly "unknown".
The map, in one breath
Config tells beets where the database and the directory are. The database remembers the tags; the directory holds the files; the tag layer keeps the two in step; MusicBrainz is the outside authority the autotagger consults; plugins are bolt-on skills. When something surprises you, ask which of the five would have to be true for the surprise to happen — chapter 13 is built out of exactly those answers.