mirror of
https://github.com/beetbox/beets.git
synced 2026-02-13 10:51:59 +01:00
Merge pull request #3831 from dosoe/beets_tag_hook
Add two events extracting_trackdata and extracting_albumdata
This commit is contained in:
commit
c0af155323
3 changed files with 25 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ import traceback
|
|||
from six.moves.urllib.parse import urljoin
|
||||
|
||||
from beets import logging
|
||||
from beets import plugins
|
||||
import beets.autotag.hooks
|
||||
import beets
|
||||
from beets import util
|
||||
|
|
@ -265,6 +266,11 @@ def track_info(recording, index=None, medium=None, medium_index=None,
|
|||
if arranger:
|
||||
info.arranger = u', '.join(arranger)
|
||||
|
||||
# Supplementary fields provided by plugins
|
||||
extra_trackdatas = plugins.send('mb_track_extract', data=recording)
|
||||
for extra_trackdata in extra_trackdatas:
|
||||
info.update(extra_trackdata)
|
||||
|
||||
info.decode()
|
||||
return info
|
||||
|
||||
|
|
@ -453,6 +459,10 @@ def album_info(release):
|
|||
if config['musicbrainz']['genres'] and genres:
|
||||
info.genre = ';'.join(g['name'] for g in genres)
|
||||
|
||||
extra_albumdatas = plugins.send('mb_album_extract', data=release)
|
||||
for extra_albumdata in extra_albumdatas:
|
||||
info.update(extra_albumdata)
|
||||
|
||||
info.decode()
|
||||
return info
|
||||
|
||||
|
|
|
|||
|
|
@ -204,6 +204,8 @@ Other new things:
|
|||
configuration.
|
||||
Thanks to :user:`FichteFoll`.
|
||||
:bug:`2797` :bug:`2988`
|
||||
* Add ``mb_album_extract`` and ``mb_track_extract`` hooks to allow
|
||||
plugins to add new fields based on MusicBrainz data. Thanks to :user:`dosoe`.
|
||||
* Removes usage of the bs1770gain replaygain backend.
|
||||
Thanks to :user:`SamuelCook`.
|
||||
* Added ``trackdisambig`` which stores the recording disambiguation from
|
||||
|
|
@ -2007,7 +2009,7 @@ Major new features and bigger changes:
|
|||
search results you wish to see when looking up releases at MusicBrainz
|
||||
during import. :bug:`1245`
|
||||
* The importer now records the data source for a match in a new
|
||||
flexible attribute `data_source` on items and albums. :bug:`1311`
|
||||
flexible attribute ``data_source`` on items and albums. :bug:`1311`
|
||||
* The colors used in the terminal interface are now configurable via the new
|
||||
config option ``colors``, nested under the option ``ui``. (Also, the `color`
|
||||
config option has been moved from top-level to under ``ui``. Beets will
|
||||
|
|
|
|||
|
|
@ -245,6 +245,18 @@ The events currently available are:
|
|||
during a ``beet import`` interactive session. Plugins can use this event for
|
||||
:ref:`appending choices to the prompt <append_prompt_choices>` by returning a
|
||||
list of ``PromptChoices``. Parameters: ``task`` and ``session``.
|
||||
|
||||
* `mb_track_extract`: called after the metadata is obtained from
|
||||
MusicBrainz. The parameter is a ``dict`` containing the tags retrieved from
|
||||
MusicBrainz for a track. Plugins must return a new (potentially empty)
|
||||
``dict`` with additional ``field: value`` pairs, which the autotagger will
|
||||
apply to the item, as flexible attributes if ``field`` is not a hardcoded
|
||||
field. Fields already present on the track are overwritten.
|
||||
Parameter: ``data``
|
||||
|
||||
* `mb_album_extract`: Like `mb_track_extract`, but for album tags. Overwrites
|
||||
tags set at the track level, if they have the same ``field``.
|
||||
Parameter: ``data``
|
||||
|
||||
The included ``mpdupdate`` plugin provides an example use case for event listeners.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue