Debian Codegraph @

docs/guides/advanced.rst

raw
1 Advanced Awesomeness
2 ====================
3
4 So you have beets up and running and you've started :doc:`importing your music
5 </guides/tagger>`. There's a lot more that beets can do now that it has
6 cataloged your collection. Here's a few features to get you started.
7
8 Most of these tips involve :doc:`plugins </plugins/index>` and fiddling with
9 beets' :doc:`configuration </reference/config>`. So use your favorite text
10 editor to create a config file before you continue.
11
12 Fetch album art, genres, and lyrics
13 -----------------------------------
14
15 Beets can help you fill in more than just the basic taxonomy metadata that comes
16 from MusicBrainz. Plugins can provide :doc:`album art </plugins/fetchart>`,
17 :doc:`lyrics </plugins/lyrics>`, and :doc:`genres </plugins/lastgenre>` from
18 databases around the Web.
19
20 If you want beets to get any of this data automatically during the import
21 process, just enable any of the three relevant plugins (see
22 :doc:`/plugins/index`). For example, put this line in your :doc:`config file
23 </reference/config>` to enable all three:
24
25 ::
26
27 plugins: fetchart lyrics lastgenre
28
29 Each plugin also has a command you can run to fetch data manually. For example,
30 if you want to get lyrics for all the Beatles tracks in your collection, just
31 type ``beet lyrics beatles`` after enabling the plugin.
32
33 Read more about using each of these plugins:
34
35 - :doc:`/plugins/fetchart` (and its accompanying :doc:`/plugins/embedart`)
36 - :doc:`/plugins/lyrics`
37 - :doc:`/plugins/lastgenre`
38
39 Customize your file and folder names
40 ------------------------------------
41
42 Beets uses an extremely flexible template system to name the folders and files
43 that organize your music in your filesystem. Take a look at
44 :ref:`path-format-config` for the basics: use fields like ``$year`` and
45 ``$title`` to build up a naming scheme. But if you need more flexibility, there
46 are two features you need to know about:
47
48 - :ref:`Template functions <template-functions>` are simple expressions you can
49 use in your path formats to add logic to your names. For example, you can get
50 an artist's first initial using ``%upper{%left{$albumartist,1}}``.
51 - If you need more flexibility, the :doc:`/plugins/inline` lets you write
52 snippets of Python code that generate parts of your filenames. The equivalent
53 code for getting an artist initial with the *inline* plugin looks like
54 ``initial: albumartist[0].upper()``.
55
56 If you already have music in your library and want to update their names
57 according to a new scheme, just run the :ref:`move-cmd` command to rename
58 everything.
59
60 Stream your music to another computer
61 -------------------------------------
62
63 Sometimes it can be really convenient to store your music on one machine and
64 play it on another. For example, I like to keep my music on a server at home,
65 but play it at work (without copying my whole library locally). The
66 :doc:`/plugins/web` makes streaming your music easy---it's sort of like having
67 your own personal Spotify.
68
69 First, enable the ``web`` plugin (see :doc:`/plugins/index`). Run the server by
70 typing ``beet web`` and head to http://localhost:8337 in a browser. You can
71 browse your collection with queries and, if your browser supports it, play music
72 using HTML5 audio.
73
74 Transcode music files for media players
75 ---------------------------------------
76
77 Do you ever find yourself transcoding high-quality rips to a lower-bitrate,
78 lossy format for your phone or music player? Beets can help with that.
79
80 You'll first need to install ffmpeg_. Then, enable beets'
81 :doc:`/plugins/convert`. Set a destination directory in your :doc:`config file
82 </reference/config>` like so:
83
84 ::
85
86 convert:
87 dest: ~/converted_music
88
89 Then, use the command ``beet convert QUERY`` to transcode everything matching
90 the query and drop the resulting files in that directory, named according to
91 your path formats. For example, ``beet convert long winters`` will move over
92 everything by the Long Winters for listening on the go.
93
94 The plugin has many more dials you can fiddle with to get your conversions how
95 you like them. Check out :doc:`its documentation </plugins/convert>`.
96
97 .. _ffmpeg: https://www.ffmpeg.org
98
99 Store any data you like
100 -----------------------
101
102 The beets database keeps track of a long list of :ref:`built-in fields
103 <itemfields>`, but you're not limited to just that list. Say, for example, that
104 you like to categorize your music by the setting where it should be played. You
105 can invent a new ``context`` attribute to store this. Set the field using the
106 :ref:`modify-cmd` command:
107
108 ::
109
110 beet modify context=party artist:'beastie boys'
111
112 By default, beets will show you the changes that are about to be applied and ask
113 if you really want to apply them to all, some or none of the items or albums.
114 You can type y for "yes", n for "no", or s for "select". If you choose the
115 latter, the command will prompt you for each individual matching item or album.
116
117 Then :doc:`query </reference/query>` your music just as you would with any other
118 field:
119
120 ::
121
122 beet ls context:mope
123
124 You can even use these fields in your filenames (see :ref:`path-format-config`).
125
126 And, unlike :ref:`built-in fields <itemfields>`, such fields can be removed:
127
128 ::
129
130 beet modify context! artist:'beastie boys'
131
132 Read more than you ever wanted to know about the *flexible attributes* feature
133 `on the beets blog`_.
134
135 .. _on the beets blog: https://beets.io/blog/flexattr.html
136
137 Choose a path style manually for some music
138 -------------------------------------------
139
140 Sometimes, you need to categorize some songs differently in your file system.
141 For example, you might want to group together all the music you don't really
142 like, but keep around to play for friends and family. This is, of course,
143 impossible to determine automatically using metadata from MusicBrainz.
144
145 Instead, use a flexible attribute (see above) to store a flag on the music you
146 want to categorize, like so:
147
148 ::
149
150 beet modify bad=1 christmas
151
152 Then, you can query on this field in your path formats to sort this music
153 differently. Put something like this in your configuration file:
154
155 ::
156
157 paths:
158 bad:1: Bad/$artist/$title
159
160 Used together, flexible attributes and path format conditions let you sort your
161 music by any criteria you can imagine.
162
163 Automatically add new music to your library
164 -------------------------------------------
165
166 As a command-line tool, beets is perfect for automated operation via a cron job
167 or the like. To use it this way, you might want to use these options in your
168 :doc:`config file </reference/config>`:
169
170 .. code-block:: yaml
171
172 import:
173 incremental: yes
174 quiet: yes
175 log: /path/to/log.txt
176
177 The :ref:`incremental` option will skip importing any directories that have been
178 imported in the past. :ref:`quiet` avoids asking you any questions (since this
179 will be run automatically, no input is possible). You might also want to use the
180 :ref:`quiet_fallback` options to configure what should happen when no
181 near-perfect match is found -- this option depends on your level of paranoia.
182 Finally, :ref:`import_log` will make beets record its decisions so you can come
183 back later and see what you need to handle manually.
184
185 The last step is to set up cron or some other automation system to run ``beet
186 import /path/to/incoming/music``.
187
188 Useful reports
189 --------------
190
191 Since beets has a quite powerful query tool, this list contains some useful and
192 powerful queries to run on your library.
193
194 - See a list of all albums which have files which are 128 bit rate:
195
196 ::
197
198 beet list bitrate:128000
199
200 - See a list of all albums with the tracks listed in order of bit rate:
201
202 ::
203
204 beet ls -f '$bitrate $artist - $title' bitrate+
205
206 - See a list of albums and their formats:
207
208 ::
209
210 beet ls -f '$albumartist $album $format' | sort | uniq
211
212 Note that ``beet ls --album -f '... $format'`` doesn't do what you want,
213 because ``format`` is an item-level field, not an album-level one. If an
214 album's tracks exist in multiple formats, the album will appear in the list
215 once for each format.