From ddf3432f758482d0dcb258d9f971051da54febcc Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 3 Jun 2012 20:48:53 +0530 Subject: [PATCH] Fix for '''TypeError: cannot concatenate 'str' and 'NoneType' obejects'''... when trying to scan music library. Basically just cut down the dictionary when searching for an artist with a limit=1 to return only the artistid as that was the only variable we were using --- headphones/mb.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/headphones/mb.py b/headphones/mb.py index f1b7e757..94e2c900 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -92,16 +92,17 @@ def findArtist(name, limit=1): else: uniquename = unicode(result['sort-name']) if result['name'] != uniquename and limit == 1: - logger.debug('Found an artist with a disambiguation: %s - doing an album based search' % name) + logger.info('Found an artist with a disambiguation: %s - doing an album based search' % name) artistdict = findArtistbyAlbum(name) if not artistdict: - logger.debug('Cannot determine the best match from an artist/album search. Using top match instead') + logger.info('Cannot determine the best match from an artist/album search. Using top match instead') artistlist.append({ - 'name': unicode(result['sort-name']), - 'uniquename': uniquename, + # Just need the artist id if the limit is 1 + # 'name': unicode(result['sort-name']), + # 'uniquename': uniquename, 'id': unicode(result['id']), - 'url': unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed - 'score': int(result['ext:score']) + # 'url': unicode("http://musicbrainz.org/artist/" + result['id']),#probably needs to be changed + # 'score': int(result['ext:score']) }) else: artistlist.append(artistdict) @@ -467,15 +468,16 @@ def findArtistbyAlbum(name): artist_dict = {} for releaseGroup in results: newArtist = releaseGroup['artist-credit'][0]['artist'] - if 'disambiguation' in newArtist: - uniquename = unicode(newArtist['sort-name'] + " (" + newArtist['disambiguation'] + ")") - else: - uniquename = unicode(newArtist['sort-name']) - artist_dict['name'] = unicode(newArtist['sort-name']) - artist_dict['uniquename'] = uniquename + # Only need the artist ID if we're doing an artist+album lookup + #if 'disambiguation' in newArtist: + # uniquename = unicode(newArtist['sort-name'] + " (" + newArtist['disambiguation'] + ")") + #else: + # uniquename = unicode(newArtist['sort-name']) + #artist_dict['name'] = unicode(newArtist['sort-name']) + #artist_dict['uniquename'] = uniquename artist_dict['id'] = unicode(newArtist['id']) - artist_dict['url'] = u'http://musicbrainz.org/artist/' + newArtist['id'] - artist_dict['score'] = int(releaseGroup['ext:score']) + #artist_dict['url'] = u'http://musicbrainz.org/artist/' + newArtist['id'] + #artist_dict['score'] = int(releaseGroup['ext:score'])