check artist name when multiple artists may be returned
authorClinton Ebadi <clinton@unknownlamer.org>
Mon, 27 Apr 2015 03:20:16 +0000 (23:20 -0400)
committerClinton Ebadi <clinton@unknownlamer.org>
Mon, 27 Apr 2015 03:20:16 +0000 (23:20 -0400)
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

index 2eba189..796d1da 100644 (file)
@@ -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] + "...")