From cee6c5fe520d9a4910c492e1abf3236cf35a8729 Mon Sep 17 00:00:00 2001 From: "nathdwek@laptop" Date: Sat, 22 Oct 2016 12:37:38 +0200 Subject: [PATCH] Rewrite match_by_id to fix next vs __next__ --- beets/autotag/match.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index bfb2e9d56..5585c7f5c 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -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):