diff --git a/NEWS b/NEWS index 47f74492d..2d351890c 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,8 @@ * Fixed bug that completely broke non-autotagged imports ("import -A"). * Fixed bug that logged the wrong paths when using "import -l". * Fixed autotagging for the creatively-named band !!!. +* Efficiency tweak should reduce the number of MusicBrainz queries per + autotagged album. * A new "-v" command line switch enables debugging output. 1.0b4 diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index 6705ee9b4..6b1c20994 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -448,8 +448,9 @@ def tag_album(items, search_artist=None, search_album=None): # Get candidate metadata from search. if not search_artist or not search_album: raise InsufficientMetadataError() - candidates = mb.match_album(search_artist, search_album, len(items)) - candidates = list(candidates)[:MAX_CANDIDATES] + candidates = mb.match_album(search_artist, search_album, + len(items), MAX_CANDIDATES) + candidates = list(candidates) # Get candidates from plugins. candidates.extend(plugins.candidates(items)) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 23b30c57d..8f055099e 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -183,7 +183,7 @@ def release_dict(release, tracks=None): return out -def match_album(artist, album, tracks=None): +def match_album(artist, album, tracks=None, limit=SEARCH_LIMIT): """Searches for a single album ("release" in MusicBrainz parlance) and returns an iterator over dictionaries of information (as returned by `release_dict`). diff --git a/beetsplug/lastid.py b/beetsplug/lastid.py index 40fe45544..f77340953 100644 --- a/beetsplug/lastid.py +++ b/beetsplug/lastid.py @@ -131,8 +131,8 @@ class LastIdPlugin(BeetsPlugin): criteria['artistName'] = last_artist # Perform the search. - cands = mb.get_releases(**criteria) - cands = list(cands)[:autotag.MAX_CANDIDATES] + criteria['limit'] = autotag.MAX_CANDIDATES + cands = list(mb.get_releases(**criteria)) log.debug('Matched last candidates: %s' % ', '.join([cand['album'] for cand in cands]))