From 38884b92565d77892c0586366d9efd562d17cf79 Mon Sep 17 00:00:00 2001 From: Remy Date: Thu, 11 Aug 2011 19:00:06 -0700 Subject: [PATCH] Fixed NoneType error when searching for a disambiguation with no album title --- headphones/mb.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/headphones/mb.py b/headphones/mb.py index 1bf35308..53f87631 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -51,7 +51,14 @@ def findArtist(name, limit=1): artistdict = findArtistbyAlbum(name) if not artistdict: - return False + logger.debug('Cannot determine the best match from an artist/album search. Using top match instead') + artistlist.append({ + 'name': result.artist.name, + 'uniquename': result.artist.getUniqueName(), + 'id': u.extractUuid(result.artist.id), + 'url': result.artist.id, + 'score': result.score + }) else: artistlist.append(artistdict) @@ -393,7 +400,14 @@ def findArtistbyAlbum(name): myDB = db.DBConnection() - artist = myDB.action('SELECT AlbumTitle from have WHERE ArtistName=?', [name]).fetchone() + artist = myDB.action('SELECT AlbumTitle from have WHERE ArtistName=? AND AlbumTitle IS NOT NULL', [name]).fetchone() + + if not artist: + return False + + # Probably not neccessary but just want to double check + if not artist['AlbumTitle']: + return False term = '"'+artist['AlbumTitle']+'" AND artist:"'+name+'"'