fix implicit ID search

This was broken because hooks._album_for_id now returns a list. This was
assuming it returned a single value (or None).
This commit is contained in:
Adrian Sampson 2013-05-29 15:24:05 -07:00
parent bf1291a97d
commit 5e7964d2dd
2 changed files with 5 additions and 3 deletions

View file

@ -361,10 +361,11 @@ def match_by_id(items):
if bool(reduce(lambda x,y: x if x==y else (), albumids)):
albumid = albumids[0]
log.debug('Searching for discovered album ID: ' + albumid)
return hooks._album_for_id(albumid)
matches = hooks._album_for_id(albumid)
if matches:
return matches[0]
else:
log.debug('No album ID consensus.')
return None
def _recommendation(results):
"""Given a sorted list of AlbumMatch or TrackMatch objects, return a
@ -517,6 +518,7 @@ def tag_album(items, search_artist=None, search_album=None,
# Get the results from the data sources.
search_cands = hooks._album_candidates(items, search_artist,
search_album, va_likely)
log.debug(u'Evaluating %i candidates.' % len(search_cands))
for info in search_cands:
_add_candidate(items, candidates, info)

View file

@ -329,8 +329,8 @@ def _parse_id(s):
# Find the first thing that looks like a UUID/MBID.
match = re.search('[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}', s)
if match:
log.error('Invalid MBID.')
return match.group()
log.error('Invalid MBID.')
def album_for_id(albumid):
"""Fetches an album by its MusicBrainz ID and returns an AlbumInfo