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