Add search of artist's albums.
[clinton/xbmc-groove.git] / default.py
CommitLineData
7ce01be6 1import urllib, sys, os, shutil, re, time, xbmcaddon, xbmcplugin, xbmcgui, xbmc
8817bb2e 2MODE_SEARCH_SONGS = 1
3MODE_SEARCH_ALBUMS = 2
4MODE_SEARCH_ARTISTS = 3
86f629ea 5MODE_SEARCH_ARTISTS_ALBUMS = 4
6MODE_SEARCH_PLAYLISTS = 5
7MODE_POPULAR_SONGS = 6
8MODE_FAVORITES = 7
9MODE_PLAYLISTS = 8
10MODE_ALBUM = 9
11MODE_ARTIST = 10
12MODE_PLAYLIST = 11
13MODE_SONG = 12
14MODE_FAVORITE = 13
7ea6f166 15
38df1fa5 16ACTION_MOVE_LEFT = 1
7ea6f166 17ACTION_MOVE_UP = 3
18ACTION_MOVE_DOWN = 4
19ACTION_PAGE_UP = 5
20ACTION_PAGE_DOWN = 6
21ACTION_SELECT_ITEM = 7
22ACTION_PREVIOUS_MENU = 10
8817bb2e 23
86f629ea 24# Formats for track labels
25ARTIST_ALBUM_NAME_LABEL = 0
26NAME_ALBUM_ARTIST_LABEL = 1
27
6ae708d0 28baseDir = os.getcwd()
29resDir = xbmc.translatePath(os.path.join(baseDir, 'resources'))
8817bb2e 30libDir = xbmc.translatePath(os.path.join(resDir, 'lib'))
31imgDir = xbmc.translatePath(os.path.join(resDir, 'img'))
7ce01be6 32cacheDir = os.path.join(xbmc.translatePath('special://masterprofile/addon_data/'), os.path.basename(os.getcwd()))
33thumbDirName = 'thumb'
34thumbDir = os.path.join('special://masterprofile/addon_data/', os.path.basename(os.getcwd()), thumbDirName)
4be42357 35
36baseModeUrl = 'plugin://plugin.audio.groove/'
e278f474 37playlistUrl = baseModeUrl + '?mode=' + str(MODE_PLAYLIST)
4be42357 38playlistsUrl = baseModeUrl + '?mode=' + str(MODE_PLAYLISTS)
39favoritesUrl = baseModeUrl + '?mode=' + str(MODE_FAVORITES)
40
7ce01be6 41thumbDef = os.path.join(imgDir, 'default.tbn')
8817bb2e 42
43sys.path.append (libDir)
7ce01be6 44from GroovesharkAPI import GrooveAPI
45
a3ad8f73 46try:
47 groovesharkApi = GrooveAPI()
7ce01be6 48 if groovesharkApi.pingService() != True:
49 raise StandardError('No Grooveshark service')
a3ad8f73 50except:
51 dialog = xbmcgui.Dialog()
52 dialog.ok('Grooveshark XBMC', 'Unable to connect with Grooveshark.', 'Please try again later')
53 sys.exit(-1)
54
8817bb2e 55
56class _Info:
57 def __init__( self, *args, **kwargs ):
58 self.__dict__.update( kwargs )
e278f474 59
7ce01be6 60
8817bb2e 61class Groveshark:
973b4c6c 62
7ea6f166 63 albumImg = xbmc.translatePath(os.path.join(imgDir, 'album.png'))
64 artistImg = xbmc.translatePath(os.path.join(imgDir, 'artist.png'))
86f629ea 65 artistsAlbumsImg = xbmc.translatePath(os.path.join(imgDir, 'artistsalbums.png'))
7ea6f166 66 favoritesImg = xbmc.translatePath(os.path.join(imgDir, 'favorites.png'))
67 playlistImg = xbmc.translatePath(os.path.join(imgDir, 'playlist.png'))
86f629ea 68 usersplaylistsImg = xbmc.translatePath(os.path.join(imgDir, 'usersplaylists.png'))
7ea6f166 69 popularSongsImg = xbmc.translatePath(os.path.join(imgDir, 'popularSongs.png'))
70 songImg = xbmc.translatePath(os.path.join(imgDir, 'song.png'))
71 defImg = xbmc.translatePath(os.path.join(imgDir, 'default.tbn'))
2254a6b5 72 fanImg = xbmc.translatePath(os.path.join(baseDir, 'fanart.png'))
8817bb2e 73
2254a6b5 74 settings = xbmcaddon.Addon(id='plugin.audio.groove')
7ce01be6 75 songsearchlimit = int(settings.getSetting('songsearchlimit'))
76 albumsearchlimit = int(settings.getSetting('albumsearchlimit'))
77 artistsearchlimit = int(settings.getSetting('artistsearchlimit'))
2254a6b5 78 username = settings.getSetting('username')
79 password = settings.getSetting('password')
38df1fa5 80 userid = 0
4be42357 81
8817bb2e 82 def __init__( self ):
83 self._handle = int(sys.argv[1])
7ce01be6 84 if os.path.isdir(cacheDir) == False:
85 os.makedirs(cacheDir)
86 xbmc.log("Made " + cacheDir)
164e42d8 87 artDir = xbmc.translatePath(thumbDir)
88 if os.path.isdir(artDir) == False:
3a794693 89 os.makedirs(artDir)
90 xbmc.log("Made " + artDir)
b738088f 91
e278f474 92 # Top-level menu
8817bb2e 93 def categories(self):
2254a6b5 94
38df1fa5 95 self.userid = self._get_login()
b738088f 96
97 # Setup
6ae708d0 98 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
6ae708d0 99
86f629ea 100 self._add_dir('Search for songs...', '', MODE_SEARCH_SONGS, self.songImg, 0)
101 self._add_dir('Search for albums...', '', MODE_SEARCH_ALBUMS, self.albumImg, 0)
102 self._add_dir('Search for artists...', '', MODE_SEARCH_ARTISTS, self.artistImg, 0)
103 self._add_dir("Search for artist's albums...", '', MODE_SEARCH_ARTISTS_ALBUMS, self.artistsAlbumsImg, 0)
104 self._add_dir("Search for user's playlists...", '', MODE_SEARCH_PLAYLISTS, self.usersplaylistsImg, 0)
36cc00d7 105 self._add_dir('Popular songs', '', MODE_POPULAR_SONGS, self.popularSongsImg, 0)
38df1fa5 106 if (self.userid != 0):
86f629ea 107 self._add_dir('My favorites', '', MODE_FAVORITES, self.favoritesImg, 0)
108 self._add_dir('My playlists', '', MODE_PLAYLISTS, self.playlistImg, 0)
e278f474 109
110 # Search for songs
8817bb2e 111 def searchSongs(self):
86f629ea 112 query = self._get_keyboard(default="", heading="Search for songs")
7ea6f166 113 if (query != ''):
7ce01be6 114 songs = groovesharkApi.getSongSearchResults(query, limit = self.songsearchlimit)
8817bb2e 115 if (len(songs) > 0):
6ae708d0 116 self._add_songs_directory(songs)
8817bb2e 117 else:
118 dialog = xbmcgui.Dialog()
38df1fa5 119 dialog.ok('Grooveshark XBMC', 'No matching songs.')
8817bb2e 120 self.categories()
7ea6f166 121 else:
122 self.categories()
8817bb2e 123
e278f474 124 # Search for albums
8817bb2e 125 def searchAlbums(self):
86f629ea 126 query = self._get_keyboard(default="", heading="Search for albums")
7ea6f166 127 if (query != ''):
7ce01be6 128 albums = groovesharkApi.getAlbumSearchResults(query, limit = self.albumsearchlimit)
8817bb2e 129 if (len(albums) > 0):
6ae708d0 130 self._add_albums_directory(albums)
8817bb2e 131 else:
132 dialog = xbmcgui.Dialog()
38df1fa5 133 dialog.ok('Grooveshark XBMC', 'No matching albums.')
8817bb2e 134 self.categories()
7ea6f166 135 else:
136 self.categories()
8817bb2e 137
e278f474 138 # Search for artists
8817bb2e 139 def searchArtists(self):
86f629ea 140 query = self._get_keyboard(default="", heading="Search for artists")
7ea6f166 141 if (query != ''):
7ce01be6 142 artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit)
8817bb2e 143 if (len(artists) > 0):
6ae708d0 144 self._add_artists_directory(artists)
8817bb2e 145 else:
146 dialog = xbmcgui.Dialog()
38df1fa5 147 dialog.ok('Grooveshark XBMC', 'No matching artists.')
8817bb2e 148 self.categories()
7ea6f166 149 else:
150 self.categories()
86f629ea 151
152 # Search for playlists
153 def searchPlaylists(self):
154 query = self._get_keyboard(default="", heading="Search for user's playlists")
155 if (query != ''):
156 playlists = groovesharkApi.getUserPlaylistsEx(query)
157 if (len(playlists) > 0):
158 self._add_playlists_directory(playlists)
159 else:
160 dialog = xbmcgui.Dialog()
161 dialog.ok('Grooveshark XBMC', 'No Grooveshark playlists found.')
162 self.categories()
163 else:
164 self.categories()
165
166 # Search for artists albums
167 def searchArtistsAlbums(self):
168 query = self._get_keyboard(default="", heading="Search for artist's albums")
169 if (query != ''):
170 artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit)
171 if (len(artists) > 0):
172 artist = artists[0]
173 artistID = artist[1]
174 xbmc.log("Found " + artist[0] + "...")
175 albums = groovesharkApi.getArtistAlbums(artistID, limit = self.albumsearchlimit)
176 if (len(albums) > 0):
177 self._add_albums_directory(albums)
178 else:
179 dialog = xbmcgui.Dialog()
180 dialog.ok('Grooveshark XBMC', 'No matching albums.')
181 self.categories()
182 else:
183 dialog = xbmcgui.Dialog()
184 dialog.ok('Grooveshark XBMC', 'No matching artists.')
185 self.categories()
186 else:
187 self.categories()
188
e278f474 189 # Get my favorites
8817bb2e 190 def favorites(self):
36cc00d7 191 userid = self._get_login()
192 if (userid != 0):
7ce01be6 193 favorites = groovesharkApi.getUserFavoriteSongs()
36cc00d7 194 if (len(favorites) > 0):
7ce01be6 195 self._add_songs_directory(favorites)
36cc00d7 196 else:
197 dialog = xbmcgui.Dialog()
38df1fa5 198 dialog.ok('Grooveshark XBMC', 'You have no favorites.')
36cc00d7 199 self.categories()
8817bb2e 200
e278f474 201 # Get popular songs
36cc00d7 202 def popularSongs(self):
7ce01be6 203 popular = groovesharkApi.getPopularSongsToday(limit = self.songsearchlimit)
8817bb2e 204 if (len(popular) > 0):
6ae708d0 205 self._add_songs_directory(popular)
8817bb2e 206 else:
207 dialog = xbmcgui.Dialog()
38df1fa5 208 dialog.ok('Grooveshark XBMC', 'No popular songs.')
8817bb2e 209 self.categories()
36cc00d7 210
e278f474 211 # Get my playlists
8817bb2e 212 def playlists(self):
213 userid = self._get_login()
214 if (userid != 0):
7ce01be6 215 playlists = groovesharkApi.getUserPlaylists()
8817bb2e 216 if (len(playlists) > 0):
6ae708d0 217 self._add_playlists_directory(playlists)
8817bb2e 218 else:
219 dialog = xbmcgui.Dialog()
38df1fa5 220 dialog.ok('Grooveshark XBMC', 'You have no Grooveshark playlists.')
8817bb2e 221 self.categories()
7ea6f166 222 else:
223 dialog = xbmcgui.Dialog()
38df1fa5 224 dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to see your Grooveshark playlists.')
7ea6f166 225
e278f474 226 # Make songs a favorite
8817bb2e 227 def favorite(self, songid):
228 userid = self._get_login()
229 if (userid != 0):
406ab447 230 xbmc.log("Favorite song: " + str(songid))
7ce01be6 231 groovesharkApi.addUserFavoriteSong(songID = songid)
38df1fa5 232 xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Added to favorites, 1000, ' + thumbDef + ')')
8817bb2e 233 else:
234 dialog = xbmcgui.Dialog()
38df1fa5 235 dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to add favorites.')
e278f474 236
237 # Show selected album
36cc00d7 238 def album(self, albumid):
7ce01be6 239 album = groovesharkApi.getAlbumSongs(albumid, limit = self.songsearchlimit)
86f629ea 240 self._add_songs_directory(album, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL)
e278f474 241
242 # Show selected artist
8817bb2e 243 def artist(self, artistid):
7ce01be6 244 albums = groovesharkApi.getArtistAlbums(artistid, limit = self.albumsearchlimit)
7fda21f0 245 self._add_albums_directory(albums)
8817bb2e 246
e278f474 247 # Show selected playlist
7ce01be6 248 def playlist(self, playlistid):
8817bb2e 249 userid = self._get_login()
250 if (userid != 0):
7ce01be6 251 songs = groovesharkApi.getPlaylistSongs(playlistid)
86f629ea 252 self._add_songs_directory(songs, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL)
8817bb2e 253 else:
254 dialog = xbmcgui.Dialog()
38df1fa5 255 dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to get Grooveshark playlists.')
8817bb2e 256
e278f474 257 # Play a song
6ae708d0 258 def playSong(self, item):
7ce01be6 259 songid = item.getProperty('songid')
260 song = groovesharkApi.getSongURLFromSongID(songid)
cbb0985e 261 if song != '':
7ce01be6 262 item.setPath(song)
263 xbmc.log("Playing: " + song)
264 xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
265 else:
cbb0985e 266 xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Unable to play song, 1000, ' + thumbDef + ')')
3fcef5ba 267
e278f474 268 # Make a song directory item
86f629ea 269 def songItem(self, songid, name, album, artist, coverart, trackLabelFormat=ARTIST_ALBUM_NAME_LABEL):
7ce01be6 270 songImg = self._get_icon(coverart, 'song-' + str(songid) + "-image")
86f629ea 271 if trackLabelFormat == NAME_ALBUM_ARTIST_LABEL:
272 trackLabel = name + " - " + album + " - " + artist
273 else:
274 trackLabel = artist + " - " + album + " - " + name
275 item = xbmcgui.ListItem(label = trackLabel, thumbnailImage=songImg, iconImage=songImg)
7ce01be6 276 item.setInfo( type="music", infoLabels={ "title": name, "album": album, "artist": artist} )
2254a6b5 277 item.setProperty('mimetype', 'audio/mpeg')
278 item.setProperty("IsPlayable", "true")
7ce01be6 279 item.setProperty('songid', str(songid))
280 item.setProperty('coverart', songImg)
281 item.setProperty('title', name)
282 item.setProperty('album', album)
283 item.setProperty('artist', artist)
284
6ae708d0 285 return item
2254a6b5 286
e278f474 287 # Get keyboard input
8817bb2e 288 def _get_keyboard(self, default="", heading="", hidden=False):
3cfead3c 289 kb = xbmc.Keyboard(default, heading, hidden)
290 kb.doModal()
291 if (kb.isConfirmed()):
292 return unicode(kb.getText(), "utf-8")
293 return ''
8817bb2e 294
e278f474 295 # Login to grooveshark
8817bb2e 296 def _get_login(self):
2254a6b5 297 if (self.username == "" or self.password == ""):
8817bb2e 298 dialog = xbmcgui.Dialog()
38df1fa5 299 dialog.ok('Grooveshark XBMC', 'Unable to login.', 'Check username and password in settings.')
8817bb2e 300 return 0
301 else:
38df1fa5 302 if self.userid == 0:
7ce01be6 303 uid = groovesharkApi.login(self.username, self.password)
38df1fa5 304 if (uid != 0):
38df1fa5 305 return uid
8817bb2e 306 else:
307 dialog = xbmcgui.Dialog()
38df1fa5 308 dialog.ok('Grooveshark XBMC', 'Unable to login.', 'Check username and password in settings.')
8817bb2e 309 return 0
310
e278f474 311 # Get a song directory item
86f629ea 312 def _get_song_item(self, song, trackLabelFormat):
6ae708d0 313 name = song[0]
7ce01be6 314 songid = song[1]
315 album = song[2]
316 artist = song[4]
317 coverart = song[6]
86f629ea 318 return self.songItem(songid, name, album, artist, coverart, trackLabelFormat)
6ae708d0 319
320 # File download
7ce01be6 321 def _get_icon(self, url, songid):
322 if url != 'None':
323 localThumb = os.path.join(xbmc.translatePath(os.path.join(thumbDir, str(songid)))) + '.tbn'
324 try:
325 if os.path.isfile(localThumb) == False:
326 loc = urllib.URLopener()
327 loc.retrieve(url, localThumb)
328 except:
329 shutil.copy2(thumbDef, localThumb)
330 return os.path.join(os.path.join(thumbDir, str(songid))) + '.tbn'
331 else:
332 return thumbDef
e278f474 333
334 # Add songs to directory
86f629ea 335 def _add_songs_directory(self, songs, trackLabelFormat=ARTIST_ALBUM_NAME_LABEL):
6ae708d0 336 n = len(songs)
337 xbmc.log("Found " + str(n) + " songs...")
8817bb2e 338 i = 0
6ae708d0 339 while i < n:
8817bb2e 340 song = songs[i]
86f629ea 341 item = self._get_song_item(song, trackLabelFormat)
7ce01be6 342 coverart = item.getProperty('coverart')
6ae708d0 343 songname = song[0]
344 songid = song[1]
7ce01be6 345 songalbum = song[2]
346 songartist = song[4]
e278f474 347 u=sys.argv[0]+"?mode="+str(MODE_SONG)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid) \
6ae708d0 348 +"&album="+urllib.quote_plus(songalbum) \
349 +"&artist="+urllib.quote_plus(songartist) \
7ce01be6 350 +"&coverart="+urllib.quote_plus(coverart)
e278f474 351 fav=sys.argv[0]+"?mode="+str(MODE_FAVORITE)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid)
6ae708d0 352 menuItems = []
7ce01be6 353 menuItems.append(("Grooveshark favorite", "XBMC.RunPlugin("+fav+")"))
6ae708d0 354 item.addContextMenuItems(menuItems, replaceItems=False)
e278f474 355 xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=False, totalItems=n)
8817bb2e 356 i = i + 1
cb06c186 357
8817bb2e 358 xbmcplugin.setContent(self._handle, 'songs')
31731635 359 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
e278f474 360
361 # Add albums to directory
7ce01be6 362 def _add_albums_directory(self, albums):
31731635 363 n = len(albums)
364 xbmc.log("Found " + str(n) + " albums...")
8817bb2e 365 i = 0
31731635 366 while i < n:
8817bb2e 367 album = albums[i]
368 albumArtistName = album[0]
369 albumName = album[2]
370 albumID = album[3]
2254a6b5 371 albumImage = self._get_icon(album[4], 'album-' + str(albumID))
31731635 372 self._add_dir(albumName + " - " + albumArtistName, '', MODE_ALBUM, albumImage, albumID, n)
8817bb2e 373 i = i + 1
374 xbmcplugin.setContent(self._handle, 'albums')
375 xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_ALBUM_IGNORE_THE)
31731635 376 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
e278f474 377
378 # Add artists to directory
6ae708d0 379 def _add_artists_directory(self, artists):
31731635 380 n = len(artists)
381 xbmc.log("Found " + str(n) + " artists...")
8817bb2e 382 i = 0
31731635 383 while i < n:
8817bb2e 384 artist = artists[i]
385 artistName = artist[0]
386 artistID = artist[1]
31731635 387 self._add_dir(artistName, '', MODE_ARTIST, self.artistImg, artistID, n)
8817bb2e 388 i = i + 1
389 xbmcplugin.setContent(self._handle, 'artists')
390 xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_ARTIST_IGNORE_THE)
31731635 391 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
e278f474 392
393 # Add playlists to directory
6ae708d0 394 def _add_playlists_directory(self, playlists):
31731635 395 n = len(playlists)
396 xbmc.log("Found " + str(n) + " playlists...")
8817bb2e 397 i = 0
31731635 398 while i < n:
8817bb2e 399 playlist = playlists[i]
400 playlistName = playlist[0]
401 playlistID = playlist[1]
86f629ea 402 dir = self._add_dir(playlistName, '', MODE_PLAYLIST, self.playlistImg, playlistID, n)
8817bb2e 403 i = i + 1
404 xbmcplugin.setContent(self._handle, 'files')
86f629ea 405 xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_LABEL)
31731635 406 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
3fcef5ba 407
e278f474 408 # Add whatever directory
31731635 409 def _add_dir(self, name, url, mode, iconimage, id, items=1):
e278f474 410
411 u=sys.argv[0]+"?mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&id="+str(id)
8817bb2e 412 dir=xbmcgui.ListItem(name, iconImage=iconimage, thumbnailImage=iconimage)
b738088f 413 dir.setInfo( type="Music", infoLabels={ "title": name } )
31731635 414 return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=dir,isFolder=True, totalItems=items)
6ae708d0 415
e278f474 416
417# Parse URL parameters
8817bb2e 418def get_params():
419 param=[]
420 paramstring=sys.argv[2]
e278f474 421 xbmc.log(paramstring)
8817bb2e 422 if len(paramstring)>=2:
423 params=sys.argv[2]
424 cleanedparams=params.replace('?','')
425 if (params[len(params)-1]=='/'):
426 params=params[0:len(params)-2]
427 pairsofparams=cleanedparams.split('&')
428 param={}
429 for i in range(len(pairsofparams)):
430 splitparams={}
431 splitparams=pairsofparams[i].split('=')
432 if (len(splitparams))==2:
433 param[splitparams[0]]=splitparams[1]
8817bb2e 434 return param
435
e278f474 436# Main
8817bb2e 437grooveshark = Groveshark();
e278f474 438
8817bb2e 439params=get_params()
8817bb2e 440mode=None
8817bb2e 441try: mode=int(params["mode"])
442except: pass
7ce01be6 443id=0
444try: id=int(params["id"])
445except: pass
e278f474 446
447# Call function for URL
8817bb2e 448if mode==None:
449 grooveshark.categories()
450
451elif mode==MODE_SEARCH_SONGS:
452 grooveshark.searchSongs()
453
454elif mode==MODE_SEARCH_ALBUMS:
455 grooveshark.searchAlbums()
456
457elif mode==MODE_SEARCH_ARTISTS:
458 grooveshark.searchArtists()
86f629ea 459
460elif mode==MODE_SEARCH_ARTISTS_ALBUMS:
461 grooveshark.searchArtistsAlbums()
462
463elif mode==MODE_SEARCH_PLAYLISTS:
464 grooveshark.searchPlaylists()
8817bb2e 465
36cc00d7 466elif mode==MODE_POPULAR_SONGS:
467 grooveshark.popularSongs()
8817bb2e 468
8817bb2e 469elif mode==MODE_FAVORITES:
470 grooveshark.favorites()
471
e278f474 472elif mode==MODE_PLAYLISTS:
473 grooveshark.playlists()
474
8817bb2e 475elif mode==MODE_SONG:
7ce01be6 476 try: name=urllib.unquote_plus(params["name"])
477 except: pass
8817bb2e 478 try: album=urllib.unquote_plus(params["album"])
479 except: pass
480 try: artist=urllib.unquote_plus(params["artist"])
481 except: pass
7ce01be6 482 try: coverart=urllib.unquote_plus(params["coverart"])
8817bb2e 483 except: pass
7ce01be6 484 song = grooveshark.songItem(id, name, album, artist, coverart)
3fcef5ba 485 grooveshark.playSong(song)
8817bb2e 486
487elif mode==MODE_ARTIST:
4be42357 488 grooveshark.artist(id)
8817bb2e 489
490elif mode==MODE_ALBUM:
4be42357 491 grooveshark.album(id)
8817bb2e 492
493elif mode==MODE_PLAYLIST:
7ce01be6 494 grooveshark.playlist(id)
8817bb2e 495
496elif mode==MODE_FAVORITE:
4be42357 497 grooveshark.favorite(id)
8817bb2e 498
e278f474 499if mode < MODE_SONG:
8817bb2e 500 xbmcplugin.endOfDirectory(int(sys.argv[1]))