return self._parseSongs(result)
else:
return []
-
+
+ # Get artist's popular songs
+ def getArtistPopularSongs(self, artistID, limit = SONG_LIMIT):
+ result = self._callRemote('getArtistPopularSongs', {'artistID' : artistID})
+ if 'result' in result:
+ return self._parseSongs(result, limit)
+ else:
+ return []
+
# Gets the popular songs
def getPopularSongsToday(self, limit=SONG_LIMIT):
result = self._callRemote('getPopularSongsToday', {'limit' : limit})
if 'result' in items:
i = 0
list = []
- if 'songs' in items['result']:
- l = len(items['result']['songs'])
- index = 'songs'
- elif 'song' in items['result']:
- l = 1
- index = 'song'
- else:
- l = len(items['result'])
- index = ''
+ index = ''
+ l = -1
+ try:
+ if 'songs' in items['result'][0]:
+ l = len(items['result'][0]['songs'])
+ index = 'songs[]'
+ except: pass
+ try:
+ if l < 0 and 'songs' in items['result']:
+ l = len(items['result']['songs'])
+ index = 'songs'
+ except: pass
+ try:
+ if l < 0 and 'song' in items['result']:
+ l = 1
+ index = 'song'
+ except: pass
+ try:
+ if l < 0:
+ l = len(items['result'])
+ except: pass
+
if limit > 0 and l > limit:
l = limit
while(i < l):
- if index == 'songs':
+ if index == 'songs[]':
+ s = items['result'][0]['songs'][i]
+ elif index == 'songs':
s = items['result'][index][i]
elif index == 'song':
s = items['result'][index]
#res = groovesharkApi.addUserFavoriteSong('27425375')
#res = groovesharkApi.logout()
#res = groovesharkApi.getUserPlaylistsEx('stephendenham')
+#res = groovesharkApi.getArtistPopularSongs('3707')
#
#pprint.pprint(res)