From e7abd49e83bcd0eb941cd9abf8e5ca24119910a4 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 4 Nov 2012 21:54:01 -0500 Subject: [PATCH] Catch non-unicode artist names being passed into findArtistbyAlbum in mb.py --- headphones/mb.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/headphones/mb.py b/headphones/mb.py index 5a20e0ad..84c21ec5 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -407,6 +407,17 @@ def getTracksFromRelease(release): # Used when there is a disambiguation def findArtistbyAlbum(name): + # Somehow non unicode is getting passed into this function? + if not isinstance(name, unicode): + try: + name = name.decode('latin-1', 'replace') + except: + try: + name = name.decode(headphones.SYS_ENCODING, 'replace') + except: + logger.warn("Unable to convert artist to unicode so cannot do a database lookup") + return False + myDB = db.DBConnection() artist = myDB.action('SELECT AlbumTitle from have WHERE ArtistName=? AND AlbumTitle IS NOT NULL ORDER BY RANDOM()', [name]).fetchone()