From 00b08d52d596f1b4a9280ac1efaf3b84f123debf Mon Sep 17 00:00:00 2001 From: Dorian Date: Sat, 6 Feb 2021 15:07:10 +0100 Subject: [PATCH] style following review --- beets/autotag/mb.py | 13 +++++-------- docs/dev/plugins.rst | 10 +++++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index a16cfb3e6..8f2cbeb92 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -260,11 +260,10 @@ def track_info(recording, index=None, medium=None, medium_index=None, if arranger: info.arranger = u', '.join(arranger) - # supplementary tags provided by plugins - extra_trackdatas = plugins.send('extracting_trackdata', info=recording) + # supplementary fields provided by plugins + extra_trackdatas = plugins.send('mb_track_extract', data=recording) for extra_trackdata in extra_trackdatas: - for key in extra_trackdata: - info[key] = extra_trackdata[key] + info.update(extra_trackdata) info.decode() return info @@ -454,11 +453,9 @@ def album_info(release): if config['musicbrainz']['genres'] and genres: info.genre = ';'.join(g['name'] for g in genres) - # supplementary tags provided by plugins - extra_albumdatas = plugins.send('extracting_albumdata', info=release) + extra_albumdatas = plugins.send('mb_album_extract', data=release) for extra_albumdata in extra_albumdatas: - for key in extra_albumdata: - info[key] = extra_albumdata[key] + info.update(extra_albumdata) info.decode() return info diff --git a/docs/dev/plugins.rst b/docs/dev/plugins.rst index 40a1f38a9..4ce2a6bdb 100644 --- a/docs/dev/plugins.rst +++ b/docs/dev/plugins.rst @@ -239,10 +239,14 @@ The events currently available are: :ref:`appending choices to the prompt ` by returning a list of ``PromptChoices``. Parameters: ``task`` and ``session``. -* `extracting_trackdata` and `extracting_albumdata`: called after the metadata - is obtained from MusicBrainz. The parameter is a ``dict`` containing the data - retrieved from MusicBrainz for a track or an album. +* `mb_track_extract`: called after the metadata is obtained from + MusicBrainz. The parameter is a ``dict`` containing the data + retrieved from MusicBrainz for a track. Allows to add additional tags. + Parameter: ``data`` + +* `mb_album_extract`: Like `mb_track_extract`, but for album tags. + Parameter: ``data`` The included ``mpdupdate`` plugin provides an example use case for event listeners.