From 3d755857ed05ca9ed03bac7b55b0d083d77781ca Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Sun, 26 Apr 2015 23:20:16 -0400 Subject: [PATCH] check artist name when multiple artists may be returned First result is not the lexically closest match, but sometimes a more popular artist with a song or album similar to the artist searched for. --- default.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/default.py b/default.py index 2eba189..796d1da 100644 --- a/default.py +++ b/default.py @@ -355,7 +355,8 @@ class Grooveshark: if (query != ''): artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit) if (len(artists) > 0): - artist = artists[0] + # check for artist name match, first result is sometimes not the closest lexical match + artist = next ((a for a in artists if a[0].lower() == query.lower()), artists[0]) artistID = artist[1] if __debugging__ : xbmc.log("Found " + artist[0] + "...") @@ -464,7 +465,11 @@ class Grooveshark: if (query != ''): artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit) if (len(artists) > 0): - artist = artists[0] + # check for exact artist name match, sometimes a more + # popular artist is returned first (e.g. 'Angel Dust' + # gets you 'Faith No More' because of their popular + # album 'Angel Dust') + artist = next ((a for a in artists if a[0].lower() == query.lower()), artists[0]) artistID = artist[1] if __debugging__ : xbmc.log("Found " + artist[0] + "...") -- 2.20.1