Rewrite match_by_id to fix next vs __next__

This commit is contained in:
nathdwek@laptop 2016-10-22 12:37:38 +02:00
parent e94676e322
commit cee6c5fe52

View file

@ -261,20 +261,22 @@ def match_by_id(items):
None.
"""
albumids = (item.mb_albumid for item in items if item.mb_albumid)
# Did any of the items have an MB album ID?
try:
# Did any of the items have an MB album ID?
first = albumids.next()
first = next(albumids)
except StopIteration:
log.debug(u'No album ID found.')
return None
else:
# Is there a consensus on the MB album ID?
if all(first == other for other in albumids):
# If all album IDs are equal, look up the album.
log.debug(u'Searching for discovered album ID: {0}', first)
return hooks.album_for_mbid(first)
else:
# Is there a consensus on the MB album ID?
for other in albumids:
if other != first:
log.debug(u'No album ID consensus.')
return None
# If all album IDs are equal, look up the album.
log.debug(u'Searching for discovered album ID: {0}', first)
return hooks.album_for_mbid(first)
def _recommendation(results):