From 00e7523374cf97ee35bb930e4abc586e243096b1 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 6 Dec 2011 19:05:53 -0800 Subject: [PATCH] fix searching when to tags are present --- beets/autotag/hooks.py | 3 ++- beets/autotag/match.py | 1 - beets/autotag/mb.py | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index f587b35e6..7f400e4ed 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -117,7 +117,8 @@ def _item_candidates(item, artist, title): out = [] # MusicBrainz candidates. - out.extend(mb.match_track(artist, title)) + if artist and title: + out.extend(mb.match_track(artist, title)) # Plugin candidates. out.extend(plugins.item_candidates(item)) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 178eb9a90..4edc0557b 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -17,7 +17,6 @@ releases and tracks. """ import logging import re -import copy from munkres import Munkres from unidecode import unidecode diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 73b3d371d..6c30d8fa1 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -157,6 +157,10 @@ def match_album(artist, album, tracks=None, limit=SEARCH_LIMIT): if tracks is not None: criteria['tracks'] = str(tracks) + # Abort if we have no search terms. + if not any(criteria.itervalues()): + return + _adapt_criteria(criteria) res = musicbrainz3.release_search(limit=limit, **criteria) for release in res['release-list']: @@ -173,6 +177,9 @@ def match_track(artist, title, limit=SEARCH_LIMIT): 'recording': title, } + if not any(criteria.itervalues()): + return + _adapt_criteria(criteria) res = musicbrainz3.recording_search(limit=limit, **criteria) for recording in res['recording-list']: