mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 12:02:41 +01:00
Send event in hooks.{album,track}_for_mbid (#2921)
Send events from {album,track}_for_mbid, then remove the decorators from
{albums,tracks}_for_id so that duplicate events are not fired.
When moving to generators and decorators in autotag.hooks (#2249),
albuminfo_received and trackinfo_received stopped being sent from code
directly calling hooks.{album,track}_for_mbid. This is most visible when
trying to write a plugin to interact with mbsync, as the documentation
explicitly says it should work.
This commit is contained in:
parent
7e0fbef9fe
commit
fa4a18879f
2 changed files with 13 additions and 4 deletions
|
|
@ -539,7 +539,10 @@ def album_for_mbid(release_id):
|
|||
if the ID is not found.
|
||||
"""
|
||||
try:
|
||||
return mb.album_for_id(release_id)
|
||||
album = mb.album_for_id(release_id)
|
||||
if album:
|
||||
plugins.send(u'albuminfo_received', info=album)
|
||||
return album
|
||||
except mb.MusicBrainzAPIError as exc:
|
||||
exc.log(log)
|
||||
|
||||
|
|
@ -549,12 +552,14 @@ def track_for_mbid(recording_id):
|
|||
if the ID is not found.
|
||||
"""
|
||||
try:
|
||||
return mb.track_for_id(recording_id)
|
||||
track = mb.track_for_id(recording_id)
|
||||
if track:
|
||||
plugins.send(u'trackinfo_received', info=track)
|
||||
return track
|
||||
except mb.MusicBrainzAPIError as exc:
|
||||
exc.log(log)
|
||||
|
||||
|
||||
@plugins.notify_info_yielded(u'albuminfo_received')
|
||||
def albums_for_id(album_id):
|
||||
"""Get a list of albums for an ID."""
|
||||
a = album_for_mbid(album_id)
|
||||
|
|
@ -562,10 +567,10 @@ def albums_for_id(album_id):
|
|||
yield a
|
||||
for a in plugins.album_for_id(album_id):
|
||||
if a:
|
||||
plugins.send(u'albuminfo_received', info=a)
|
||||
yield a
|
||||
|
||||
|
||||
@plugins.notify_info_yielded(u'trackinfo_received')
|
||||
def tracks_for_id(track_id):
|
||||
"""Get a list of tracks for an ID."""
|
||||
t = track_for_mbid(track_id)
|
||||
|
|
@ -573,6 +578,7 @@ def tracks_for_id(track_id):
|
|||
yield t
|
||||
for t in plugins.track_for_id(track_id):
|
||||
if t:
|
||||
plugins.send(u'trackinfo_received', info=t)
|
||||
yield t
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,9 @@ Fixes:
|
|||
tracks. :bug:`2537`
|
||||
* In the ``mbsync`` plugin, support MusicBrainz recording ID changes, relying
|
||||
on release track IDs instead. Thanks to :user:`jdetrey`. :bug:`1234`
|
||||
* Properly send ``albuminfo_received`` and ``trackinfo_received`` in all cases,
|
||||
most notably when using the ``mbsync`` plugin. This was a regression since
|
||||
version 1.4.1. :bug:`2921`
|
||||
|
||||
|
||||
For developers:
|
||||
|
|
|
|||
Loading…
Reference in a new issue