@@ -151,50 +151,50 @@ registration process in this case::
151
151
152
152
The events currently available are:
153
153
154
- * `pluginload `: called after all the plugins have been loaded after the `` beet ``
155
- command starts
154
+ * `` pluginload `` : called after all the plugins have been loaded after the
155
+ `` beet `` command starts
156
156
157
- * `import `: called after a ``beet import `` command finishes (the ``lib `` keyword
158
- argument is a Library object; ``paths `` is a list of paths (strings) that were
159
- imported)
157
+ * `` import `` : called after a ``beet import `` command finishes (the ``lib ``
158
+ keyword argument is a Library object; ``paths `` is a list of paths (strings)
159
+ that were imported)
160
160
161
- * `album_imported `: called with an ``Album `` object every time the ``import ``
161
+ * `` album_imported ` `: called with an ``Album `` object every time the ``import ``
162
162
command finishes adding an album to the library. Parameters: ``lib ``,
163
163
``album ``
164
164
165
- * `album_removed `: called with an ``Album `` object every time an album is
165
+ * `` album_removed ` `: called with an ``Album `` object every time an album is
166
166
removed from the library (even when its file is not deleted from disk).
167
167
168
- * `item_copied `: called with an ``Item `` object whenever its file is copied.
168
+ * `` item_copied ` `: called with an ``Item `` object whenever its file is copied.
169
169
Parameters: ``item ``, ``source `` path, ``destination `` path
170
170
171
- * `item_imported `: called with an ``Item `` object every time the importer adds a
172
- singleton to the library (not called for full-album imports). Parameters:
173
- ``lib ``, ``item ``
171
+ * `` item_imported `` : called with an ``Item `` object every time the importer
172
+ adds a singleton to the library (not called for full-album imports).
173
+ Parameters: ``lib ``, ``item ``
174
174
175
- * `before_item_moved `: called with an ``Item `` object immediately before its
175
+ * `` before_item_moved ` `: called with an ``Item `` object immediately before its
176
176
file is moved. Parameters: ``item ``, ``source `` path, ``destination `` path
177
177
178
- * `item_moved `: called with an ``Item `` object whenever its file is moved.
178
+ * `` item_moved ` `: called with an ``Item `` object whenever its file is moved.
179
179
Parameters: ``item ``, ``source `` path, ``destination `` path
180
180
181
- * `item_linked `: called with an ``Item `` object whenever a symlink is created
181
+ * `` item_linked ` `: called with an ``Item `` object whenever a symlink is created
182
182
for a file.
183
183
Parameters: ``item ``, ``source `` path, ``destination `` path
184
184
185
- * `item_hardlinked `: called with an ``Item `` object whenever a hardlink is
185
+ * `` item_hardlinked ` `: called with an ``Item `` object whenever a hardlink is
186
186
created for a file.
187
187
Parameters: ``item ``, ``source `` path, ``destination `` path
188
188
189
- * `item_reflinked `: called with an ``Item `` object whenever a reflink is
189
+ * `` item_reflinked ` `: called with an ``Item `` object whenever a reflink is
190
190
created for a file.
191
191
Parameters: ``item ``, ``source `` path, ``destination `` path
192
192
193
- * `item_removed `: called with an ``Item `` object every time an item (singleton
193
+ * `` item_removed ` `: called with an ``Item `` object every time an item (singleton
194
194
or album's part) is removed from the library (even when its file is not
195
195
deleted from disk).
196
196
197
- * `write `: called with an ``Item `` object, a ``path ``, and a ``tags ``
197
+ * `` write ` `: called with an ``Item `` object, a ``path ``, and a ``tags ``
198
198
dictionary just before a file's metadata is written to disk (i.e.,
199
199
just before the file on disk is opened). Event handlers may change
200
200
the ``tags `` dictionary to customize the tags that are written to the
@@ -203,79 +203,80 @@ The events currently available are:
203
203
operation. Beets will catch that exception, print an error message
204
204
and continue.
205
205
206
- * `after_write `: called with an ``Item `` object after a file's metadata is
206
+ * `` after_write ` `: called with an ``Item `` object after a file's metadata is
207
207
written to disk (i.e., just after the file on disk is closed).
208
208
209
- * `import_task_created `: called immediately after an import task is
210
- initialized. Plugins can use this to, for example, change imported files of a
211
- task before anything else happens. It's also possible to replace the task
212
- with another task by returning a list of tasks. This list can contain zero
213
- or more `ImportTask`s. Returning an empty list will stop the task.
214
- Parameters: ``task `` (an `ImportTask `) and ``session `` (an `ImportSession `).
209
+ * ``import_task_created ``: called immediately after an import task is
210
+ initialized. Plugins can use this to, for example, change imported files of
211
+ a task before anything else happens. It's also possible to replace the task
212
+ with another task by returning a list of tasks. This list can contain zero or
213
+ more ``ImportTask ``. Returning an empty list will stop the task.
214
+ Parameters: ``task `` (an ``ImportTask ``) and ``session `` (an
215
+ ``ImportSession ``).
215
216
216
- * `import_task_start `: called when before an import task begins processing.
217
+ * `` import_task_start ` `: called when before an import task begins processing.
217
218
Parameters: ``task `` and ``session ``.
218
219
219
- * `import_task_apply `: called after metadata changes have been applied in an
220
+ * `` import_task_apply ` `: called after metadata changes have been applied in an
220
221
import task. This is called on the same thread as the UI, so use this
221
222
sparingly and only for tasks that can be done quickly. For most plugins, an
222
223
import pipeline stage is a better choice (see :ref: `plugin-stage `).
223
224
Parameters: ``task `` and ``session ``.
224
225
225
- * `import_task_before_choice `: called after candidate search for an import task
226
- before any decision is made about how/if to import or tag. Can be used to
227
- present information about the task or initiate interaction with the user
226
+ * `` import_task_before_choice `` : called after candidate search for an import
227
+ task before any decision is made about how/if to import or tag. Can be used
228
+ to present information about the task or initiate interaction with the user
228
229
before importing occurs. Return an importer action to take a specific action.
229
230
Only one handler may return a non-None result.
230
231
Parameters: ``task `` and ``session ``
231
232
232
- * `import_task_choice `: called after a decision has been made about an import
233
+ * `` import_task_choice ` `: called after a decision has been made about an import
233
234
task. This event can be used to initiate further interaction with the user.
234
235
Use ``task.choice_flag `` to determine or change the action to be
235
236
taken. Parameters: ``task `` and ``session ``.
236
237
237
- * `import_task_files `: called after an import task finishes manipulating the
238
+ * `` import_task_files ` `: called after an import task finishes manipulating the
238
239
filesystem (copying and moving files, writing metadata tags). Parameters:
239
240
``task `` and ``session ``.
240
241
241
- * `library_opened `: called after beets starts up and initializes the main
242
+ * `` library_opened ` `: called after beets starts up and initializes the main
242
243
Library object. Parameter: ``lib ``.
243
244
244
- * `database_change `: a modification has been made to the library database. The
245
+ * `` database_change ` `: a modification has been made to the library database. The
245
246
change might not be committed yet. Parameters: ``lib `` and ``model ``.
246
247
247
- * `cli_exit `: called just before the ``beet `` command-line program exits.
248
+ * `` cli_exit ` `: called just before the ``beet `` command-line program exits.
248
249
Parameter: ``lib ``.
249
250
250
- * `import_begin `: called just before a ``beet import `` session starts up.
251
+ * `` import_begin ` `: called just before a ``beet import `` session starts up.
251
252
Parameter: ``session ``.
252
253
253
- * `trackinfo_received `: called after metadata for a track item has been
254
+ * `` trackinfo_received ` `: called after metadata for a track item has been
254
255
fetched from a data source, such as MusicBrainz. You can modify the tags
255
256
that the rest of the pipeline sees on a ``beet import `` operation or during
256
257
later adjustments, such as ``mbsync ``. Slow handlers of the event can impact
257
258
the operation, since the event is fired for any fetched possible match
258
- `before ` the user (or the autotagger machinery) gets to see the match.
259
+ `` before ` ` the user (or the autotagger machinery) gets to see the match.
259
260
Parameter: ``info ``.
260
261
261
- * `albuminfo_received `: like `trackinfo_received `, the event indicates new
262
+ * `` albuminfo_received `` : like `` trackinfo_received ` `, the event indicates new
262
263
metadata for album items. The parameter is an ``AlbumInfo `` object instead
263
264
of a ``TrackInfo ``.
264
265
Parameter: ``info ``.
265
266
266
- * `before_choose_candidate `: called before the user is prompted for a decision
267
+ * `` before_choose_candidate ` `: called before the user is prompted for a decision
267
268
during a ``beet import `` interactive session. Plugins can use this event for
268
269
:ref: `appending choices to the prompt <append_prompt_choices >` by returning a
269
270
list of ``PromptChoices ``. Parameters: ``task `` and ``session ``.
270
- * `mb_track_extract `: called after the metadata is obtained from MusicBrainz.
271
+ * `` mb_track_extract ` `: called after the metadata is obtained from MusicBrainz.
271
272
The parameter is a ``dict `` containing the tags retrieved from MusicBrainz for
272
273
a track. Plugins must return a new (potentially empty) ``dict `` with
273
274
additional ``field: value `` pairs, which the autotagger will apply to the
274
275
item, as flexible attributes if ``field `` is not a hardcoded field. Fields
275
276
already present on the track are overwritten. Parameter: ``data ``
276
- * `mb_album_extract `: Like `mb_track_extract `, but for album tags. Overwrites
277
- tags set at the track level, if they have the same ``field ``. Parameter:
278
- ``data ``
277
+ * `` mb_album_extract `` : Like `` mb_track_extract `` , but for album tags.
278
+ Overwrites tags set at the track level, if they have the same ``field ``.
279
+ Parameter: ``data ``
279
280
280
281
The included ``mpdupdate `` plugin provides an example use case for event
281
282
listeners.
@@ -328,10 +329,10 @@ Read Configuration Options
328
329
^^^^^^^^^^^^^^^^^^^^^^^^^^
329
330
330
331
Plugins can configure themselves using the ``config.yaml `` file. You can read
331
- configuration values in two ways. The first is to use `self.config ` within
332
+ configuration values in two ways. The first is to use `` self.config ` ` within
332
333
your plugin class. This gives you a view onto the configuration values in a
333
334
section with the same name as your plugin's module. For example, if your plugin
334
- is in ``greatplugin.py ``, then `self.config ` will refer to options under the
335
+ is in ``greatplugin.py ``, then `` self.config ` ` will refer to options under the
335
336
``greatplugin: `` section of the config file.
336
337
337
338
For example, if you have a configuration value called "foo", then users can put
@@ -341,19 +342,19 @@ this in their ``config.yaml``::
341
342
foo: bar
342
343
343
344
To access this value, say ``self.config['foo'].get() `` at any point in your
344
- plugin's code. The `self.config ` object is a *view * as defined by the ` Confuse `_
345
- library.
345
+ plugin's code. The `` self.config `` object is a *view * as defined by the
346
+ ` Confuse `_ library.
346
347
347
348
.. _Confuse : https://confuse.readthedocs.io/en/latest/
348
349
349
350
If you want to access configuration values *outside * of your plugin's section,
350
- import the `config ` object from the `beets ` module. That is, just put ``from
351
+ import the `` config `` object from the `` beets ` ` module. That is, just put ``from
351
352
beets import config `` at the top of your plugin and access values from there.
352
353
353
354
If your plugin provides configuration values for sensitive data (e.g.,
354
355
passwords, API keys, ...), you should add these to the config so they can be
355
356
redacted automatically when users dump their config. This can be done by
356
- setting each value's `redact ` flag, like so::
357
+ setting each value's `` redact ` ` flag, like so::
357
358
358
359
self.config['password'].redact = True
359
360
@@ -541,11 +542,11 @@ should have an integer type::
541
542
def album_types(self):
542
543
return {'rating': types.INTEGER}
543
544
544
- A plugin may define two attributes: `item_types ` and `album_types `.
545
+ A plugin may define two attributes: `` item_types `` and `` album_types ` `.
545
546
Each of those attributes is a dictionary mapping a flexible field name
546
547
to a type instance. You can find the built-in types in the
547
- `beets.dbcore.types ` and `beets.library ` modules or implement your own
548
- type by inheriting from the `Type ` class.
548
+ `` beets.dbcore.types `` and `` beets.library ` ` modules or implement your own
549
+ type by inheriting from the `` Type ` ` class.
549
550
550
551
Specifying types has several advantages:
551
552
0 commit comments