Skip to content

Commit

Permalink
Reverted to original approach
Browse files Browse the repository at this point in the history
  • Loading branch information
m-urban committed Nov 7, 2015
1 parent d8851b9 commit e96e67f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
22 changes: 20 additions & 2 deletions beets/autotag/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,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('albuminfo_received', info=album)
return album
except mb.MusicBrainzAPIError as exc:
exc.log(log)

Expand All @@ -521,7 +524,10 @@ 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('trackinfo_received', info=track)
return track
except mb.MusicBrainzAPIError as exc:
exc.log(log)

Expand All @@ -530,13 +536,17 @@ 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)


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)


Expand Down Expand Up @@ -566,6 +576,10 @@ def album_candidates(items, artist, album, va_likely):
# Candidates from plugins.
out.extend(plugins.candidates(items, artist, album, va_likely))

# Notify subscribed plugins about fetched album info
for a in out:
plugins.send('albuminfo_received', info=a)

return out


Expand All @@ -586,4 +600,8 @@ def item_candidates(item, artist, title):
# Plugin candidates.
out.extend(plugins.item_candidates(item, artist, title))

# Notify subscribed plugins about fetched track info
for i in out:
plugins.send('trackinfo_received', info=i)

return out
12 changes: 0 additions & 12 deletions beets/autotag/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ 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)

Expand Down Expand Up @@ -463,10 +459,6 @@ 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)
Expand All @@ -490,10 +482,6 @@ 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)

Expand Down

0 comments on commit e96e67f

Please sign in to comment.