From b2efd60162eb81f025c015df2160b4099dc957ad Mon Sep 17 00:00:00 2001 From: Manfred Urban Date: Sat, 7 Nov 2015 17:51:44 +0100 Subject: [PATCH] Needed to find new spot to emit events because hooks.*_for_id -methods are only called when searching for explicit IDs --- beets/autotag/hooks.py | 4 ---- beets/autotag/match.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index d53961a6c..5c4ce082e 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -530,8 +530,6 @@ def albums_for_id(album_id): """Get a list of albums for an ID.""" candidates = [album_for_mbid(album_id)] candidates.extend(plugins.album_for_id(album_id)) - for a in candidates: - plugins.send('albuminfo_received', info=a) return filter(None, candidates) @@ -539,8 +537,6 @@ def tracks_for_id(track_id): """Get a list of tracks for an ID.""" candidates = [track_for_mbid(track_id)] candidates.extend(plugins.track_for_id(track_id)) - for t in candidates: - plugins.send('trackinfo_received', info=t) return filter(None, candidates) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index c747f47c2..bd15368d2 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -350,6 +350,10 @@ def _add_candidate(items, results, info): log.debug(u'Ignored. Missing required tag: {0}', req_tag) return + # Notify subscribed plugins about fetched album info and let them perform + # their manipulations + plugins.send('albuminfo_received', info=info) + # Find mapping between the items and the track info. mapping, extra_items, extra_tracks = assign_items(items, info.tracks) @@ -459,6 +463,10 @@ def tag_item(item, search_artist=None, search_title=None, if trackid: log.debug(u'Searching for track ID: {0}', trackid) for track_info in hooks.tracks_for_id(trackid): + # Notify subscribed plugins about fetched track info and let them perform + # their manipulations + plugins.send('trackinfo_received', info=track_info) + dist = track_distance(item, track_info, incl_artist=True) candidates[track_info.track_id] = \ hooks.TrackMatch(dist, track_info) @@ -482,6 +490,10 @@ def tag_item(item, search_artist=None, search_title=None, # Get and evaluate candidate metadata. for track_info in hooks.item_candidates(item, search_artist, search_title): + # Notify subscribed plugins about fetched track info and let them perform + # their manipulations + plugins.send('trackinfo_received', info=track_info) + dist = track_distance(item, track_info, incl_artist=True) candidates[track_info.track_id] = hooks.TrackMatch(dist, track_info)