-
Notifications
You must be signed in to change notification settings - Fork 0
/
beets.html
390 lines (317 loc) · 9.94 KB
/
beets.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link
rel="stylesheet"
href="/styles.1b8b925727a47aa0b397d2326344c60a14f98d348ccd63b9047f3a72456552ad.css"
type="text/css"
/>
<link
rel="icon"
href="/favicon.1d9d66e8e0f6f92db8c49e54f947c1f74da9a1a71ab0a0749fb43679df437515.svg"
type="image/svg+xml"
/>
<title>Tagging and managing music with beets</title>
<meta name="description" content=
"Organize and manage music on OpenBSD. Use beets, a command-line
program written in Python. Update metadata, view stats, and query
your collection."
/>
<meta name="color-scheme" content="light dark"/>
<link rel="canonical" href="https://www.anthes.is/beets.html"/>
<link rel="alternate" type="application/atom+xml" href="/rss.xml"/>
</head>
<body>
<header>
<nav class="navbar">
<ul>
<li><a href="/" hreflang="en">Home</a></li>
<li><a href="/contact.html" hreflang="en">Contact</a></li>
<li><a href="/src.html" hreflang="en">Source code</a></li>
</ul>
</nav>
</header>
<main>
<h1 id="managing-music-with-beets">Tagging and managing music with beets</h1>
<p>
Last updated: <time datetime="2023-03-19">March 19th, 2023</time>
</p>
<article>
<section>
<h2 id="importance-of-metadata">Why is metadata
important?</h2>
<p>
Tagged music files come with a lot of benefits. To name
just a few:
</p>
<ul>
<li>
<p>
You know what to expect from your music without
relying on mile-long filenames or navigating through
a forest of directories.
</p>
</li>
<li>
<p>
You can easily find what you’re looking for by
querying the metadata.
</p>
</li>
<li>
<p>
ReplayGain normalizes loudness so that your hand can
rest somewhere other than the volume knob.
</p>
</li>
</ul>
</section>
<section>
<h2 id="beets-music-manager">Beets as a music manager</h2>
<p>
If you’re new to tagging music or want to change your
workflow, maybe you can
<a href="https://beets.io/">use beets to manage your library</a>.
Allowing it to fetch and apply metadata from
<a href="https://musicbrainz.org/">MusicBrainz</a>
makes getting those perks I mentioned before a lot easier.
</p>
<p>
To make things easier, you may like to keep
<a href="https://beets.readthedocs.io" rel="nofollow">
the documentation for beets</a>
in a separate tab while you read this. This blog
post is more of an overview; the docs are more
exhaustive.
</p>
</section>
<section>
<h2 id="installation">How to install beets</h2>
<p>
Beets is probably available for installation with whatever
package manager your operating system uses. Here’s how
to install it on
<a href="https://www.openbsd.org">OpenBSD</a>.
</p>
<pre># <kbd>pkg_add beets</kbd></pre>
</section>
<section>
<h2 id="configuration">How to configure beets</h2>
<p>
By default, beets places imported music in
<code>~/Music</code>. If you need to change that, add the
desired path to the <code>config.yaml</code> file like so:
</p>
<pre><code>directory: /path/to/music/library</code></pre>
<p>
Chances are that you can go straight to importing
music without any further modifications. Otherwise,
the documentation on configuration can help you if
you run into any issues.
</p>
</section>
<section>
<h2 id="importing-music">How to import music</h2>
<p>
To be useful, beets needs a library to work with. That means
you need to import some music. Fortunately, this is very
easy to do.
</p>
<pre>$ <kbd>beet import /path/to/album</kbd></pre>
<p>
If the similarity score is high enough, beets tags the music
automatically and moves on. Otherwise, it’ll ask for
additional details.
</p>
</section>
<section>
<h2 id="querying-music">How to query music</h2>
<p>
To sift through some of your music, use <kbd>beet ls</kbd>.
</p>
<p>
It’s often best to narrow down your query with the
available metadata fields. This includes things like
<code>genre</code>,
<code>artist</code>,
<code>album</code>,
<code>year</code>,
<code>country</code>,
and so on.
</p>
<p>
Here’s an example where I query by genre (note that
you need to use the lastgenre plugin for this to
work. <a href="#plugins-genre" rel="nofollow">I
mention that plugin later on</a>).
</p>
<pre>$ <kbd>beet ls genre:'Progressive Rock'</kbd></pre>
<p>
As a side note, listing available metadata fields is done
with <kbd>beet fields</kbd>.
</p>
</section>
<section>
<h2 id="plugins">What plugins does beets have?</h2>
<p>
There are many high quality plugins for beets that extend
its functionality.
I’ll only demonstrate a fraction of
what’s possible here, so make sure to read
through the documentation on plugins afterward.
</p>
<section>
<h3 id="plugins-album-art">Album art with fetchart</h3>
<p>
If you use a minimal music player like I do,
then this may not matter as much to you.
However, with more full-featured media
applications, missing artwork can stick out like
a sore thumb.
</p>
<p>
Thankfully, there’s an easy fix for this. Add this
to your <code>config.yaml</code>:
</p>
<pre><code>plugins: fetchart</code></pre>
<p>
Then, update the library.
</p>
<pre>$ <kbd>beet fetchart</kbd></pre>
</section>
<section>
<h3 id="plugins-genre">Genre metadata with lastgenre</h3>
<p>
Out of the box, beets actually doesn’t deal with
genres at all because MusicBrainz doesn’t have
that information. Many people consider sorting by genre
an important feature to have.
</p>
<p>
To add genre information to your collection by pulling
from <a href="https://www.last.fm/" rel="nofollow">Last.fm</a>,
put this inside your <code>config.yaml</code>:
</p>
<pre><code>plugins: lastgenre</code></pre>
<p>
Then, update the library.
</p>
<pre>$ <kbd>beet lastgenre</kbd></pre>
</section>
</section>
<section>
<h2 id="cue-sheets">Cue sheets and how to use them</h2>
<p>
Beets needs a separate file for each track to tag music, yet
sometimes there’s only one FLAC file for the entire
album (it can also be something other than FLAC, but for
this example I’ll assume it’s a FLAC file).
</p>
<p>
The nice thing is that as long as you have a cue
sheet—a text file that describes the album’s
track layout with timestamps—that
single FLAC file can be split into separate files by track
(“cue splitting”).
</p>
<p>
Here’s how I split a file like this into multiple
files given a cue sheet.
</p>
<ol>
<li>
<p>
Install <code>shntool</code> for cue splitting, and
<code>cuetools</code> to tag the resulting files.
</p>
<pre># <kbd>pkg_add shntool cuetools</kbd></pre>
</li>
<li>
<p>
Navigate to the album in question.
</p>
<pre>$ <kbd>cd /path/to/album</kbd></pre>
</li>
<li>
<p>
Split the FLAC file.
</p>
<p>
<code>-f</code> points to the cue sheet.
<code>-o</code> is the encoder, which defaults to WAV.
</p>
<p>
By default, the output format looks like
<code>split-track01.flac</code>. Beets will rename the
files according to the metadata anyway, so the name
doesn’t matter much.
</p>
<pre>$ <kbd>shnsplit -f example.cue -o flac example.flac</kbd></pre>
</li>
<li>
<p>
Rename the FLAC file so that it ends in
<code>.bak</code>.
</p>
<p>
This is needed for the next step so that the original
FLAC file won’t be targeted by
<code>cuetag</code>.
</p>
<pre>$ <kbd>mv example.flac{,.bak}</kbd></pre>
</li>
<li>
<p>
Tag the split files with the original metadata.
</p>
<p>
<code>./*.flac</code> targets all FLAC files in the
current directory. See
<a
href="https://github.com/koalaman/shellcheck/wiki/SC2035"
rel="nofollow">
shellcheck’s wiki entry for SC2035</a>
for an explanation of why I use <code>./*.flac</code>
instead of <code>*.flac</code>.
</p>
<pre>$ <kbd>cuetag example.cue ./*.flac</kbd></pre>
</li>
<li>
<p>
If satisfied, delete the original FLAC file.
</p>
<pre>$ <kbd>rm example.flac.bak</kbd></pre>
</li>
<li>
<p>
Now that everything is split into tracks, you can import the
music.
<pre>$ <kbd>beet import .</kbd></pre>
</li>
</ol>
</section>
<section>
<h3 id="scripting-cue-splitting">Scripting cue splitting</h3>
<p>
Given that this is a bit tedious,
<a
href="/src/dotfiles/file/.local/bin/splitflac.html"
rel="nofollow">
I wrote a small shell script</a>
to take care of splitting FLAC files for me.
<code>splitflac</code> is used like so:
</p>
<pre>$ <kbd>splitflac example.cue example.flac</kbd></pre>
<p>
By default, <code>splitflac</code> doesn’t delete the
original FLAC file. To do so on a successful split, pass
<code>-d</code>.
</p>
<pre>$ <kbd>splitflac -d example.cue example.flac</kbd></pre>
</section>
</article>
</main>
</body>
</html>