All XBMC Music Library integration.
[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, artistName = ""):
173 if artistName == "":
174 query = self._get_keyboard(default="", heading="Search for artist's albums")
175 else:
176 query = artistName
177 if (query != ''):
178 artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit)
179 if (len(artists) > 0):
180 artist = artists[0]
181 artistID = artist[1]
182 xbmc.log("Found " + artist[0] + "...")
183 albums = groovesharkApi.getArtistAlbums(artistID, limit = self.albumsearchlimit)
184 if (len(albums) > 0):
185 self._add_albums_directory(albums)
186 else:
187 dialog = xbmcgui.Dialog()
188 dialog.ok('Grooveshark XBMC', 'No matching albums.')
189 self.categories()
190 else:
191 dialog = xbmcgui.Dialog()
192 dialog.ok('Grooveshark XBMC', 'No matching artists.')
193 self.categories()
194 else:
195 self.categories()
196
197 # Get my favorites
198 def favorites(self):
199 userid = self._get_login()
200 if (userid != 0):
201 favorites = groovesharkApi.getUserFavoriteSongs()
202 if (len(favorites) > 0):
203 self._add_songs_directory(favorites)
204 else:
205 dialog = xbmcgui.Dialog()
206 dialog.ok('Grooveshark XBMC', 'You have no favorites.')
207 self.categories()
208
209 # Get popular songs
210 def popularSongs(self):
211 popular = groovesharkApi.getPopularSongsToday(limit = self.songsearchlimit)
212 if (len(popular) > 0):
213 self._add_songs_directory(popular)
214 else:
215 dialog = xbmcgui.Dialog()
216 dialog.ok('Grooveshark XBMC', 'No popular songs.')
217 self.categories()
218
219 # Get my playlists
220 def playlists(self):
221 userid = self._get_login()
222 if (userid != 0):
223 playlists = groovesharkApi.getUserPlaylists()
224 if (len(playlists) > 0):
225 self._add_playlists_directory(playlists)
226 else:
227 dialog = xbmcgui.Dialog()
228 dialog.ok('Grooveshark XBMC', 'You have no Grooveshark playlists.')
229 self.categories()
230 else:
231 dialog = xbmcgui.Dialog()
232 dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to see your Grooveshark playlists.')
233
234 # Make songs a favorite
235 def favorite(self, songid):
236 userid = self._get_login()
237 if (userid != 0):
238 xbmc.log("Favorite song: " + str(songid))
239 groovesharkApi.addUserFavoriteSong(songID = songid)
240 xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Added to favorites, 1000, ' + thumbDef + ')')
241 else:
242 dialog = xbmcgui.Dialog()
243 dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to add favorites.')
244
245 # Show selected album
246 def album(self, albumid):
247 album = groovesharkApi.getAlbumSongs(albumid, limit = self.songsearchlimit)
248 self._add_songs_directory(album, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL)
249
250 # Show selected artist
251 def artist(self, artistid):
252 albums = groovesharkApi.getArtistAlbums(artistid, limit = self.albumsearchlimit)
253 self._add_albums_directory(albums)
254
255 # Show selected playlist
256 def playlist(self, playlistid):
257 userid = self._get_login()
258 if (userid != 0):
259 songs = groovesharkApi.getPlaylistSongs(playlistid)
260 self._add_songs_directory(songs, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL)
261 else:
262 dialog = xbmcgui.Dialog()
263 dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to get Grooveshark playlists.')
264
265 # Show popular songs of the artist
266 def artistPopularSongs(self):
267 query = self._get_keyboard(default="", heading="Artist")
268 if (query != ''):
269 artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit)
270 if (len(artists) > 0):
271 artist = artists[0]
272 artistID = artist[1]
273 xbmc.log("Found " + artist[0] + "...")
274 songs = groovesharkApi.getArtistPopularSongs(artistID, limit = self.songsearchlimit)
275 if (len(songs) > 0):
276 self._add_songs_directory(songs, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL)
277 else:
278 dialog = xbmcgui.Dialog()
279 dialog.ok('Grooveshark XBMC', 'No popular songs.')
280 self.categories()
281 else:
282 dialog = xbmcgui.Dialog()
283 dialog.ok('Grooveshark XBMC', 'No matching artists.')
284 self.categories()
285 else:
286 self.categories()
287
288 # Play a song
289 def playSong(self, item):
290 songid = item.getProperty('songid')
291 song = groovesharkApi.getSongURLFromSongID(songid)
292 if song != '':
293 item.setPath(song)
294 xbmc.log("Playing: " + song)
295 xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
296 else:
297 xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Unable to play song, 1000, ' + thumbDef + ')')
298
299 # Make a song directory item
300 def songItem(self, songid, name, album, artist, coverart, trackLabelFormat=ARTIST_ALBUM_NAME_LABEL):
301 songImg = self._get_icon(coverart, 'song-' + str(songid) + "-image")
302 if trackLabelFormat == NAME_ALBUM_ARTIST_LABEL:
303 trackLabel = name + " - " + album + " - " + artist
304 else:
305 trackLabel = artist + " - " + album + " - " + name
306 item = xbmcgui.ListItem(label = trackLabel, thumbnailImage=songImg, iconImage=songImg)
307 item.setInfo( type="music", infoLabels={ "title": name, "album": album, "artist": artist} )
308 item.setProperty('mimetype', 'audio/mpeg')
309 item.setProperty("IsPlayable", "true")
310 item.setProperty('songid', str(songid))
311 item.setProperty('coverart', songImg)
312 item.setProperty('title', name)
313 item.setProperty('album', album)
314 item.setProperty('artist', artist)
315
316 return item
317
318 # Next page of songs
319 def songPage(self, page, trackLabelFormat):
320 self._add_songs_directory([], trackLabelFormat, page)
321
322 # Get keyboard input
323 def _get_keyboard(self, default="", heading="", hidden=False):
324 kb = xbmc.Keyboard(default, heading, hidden)
325 kb.doModal()
326 if (kb.isConfirmed()):
327 return unicode(kb.getText(), "utf-8")
328 return ''
329
330 # Login to grooveshark
331 def _get_login(self):
332 if (self.username == "" or self.password == ""):
333 dialog = xbmcgui.Dialog()
334 dialog.ok('Grooveshark XBMC', 'Unable to login.', 'Check username and password in settings.')
335 return 0
336 else:
337 if self.userid == 0:
338 uid = groovesharkApi.login(self.username, self.password)
339 if (uid != 0):
340 return uid
341 else:
342 dialog = xbmcgui.Dialog()
343 dialog.ok('Grooveshark XBMC', 'Unable to login.', 'Check username and password in settings.')
344 return 0
345
346 # Get a song directory item
347 def _get_song_item(self, song, trackLabelFormat):
348 name = song[0]
349 songid = song[1]
350 album = song[2]
351 artist = song[4]
352 coverart = song[6]
353 return self.songItem(songid, name, album, artist, coverart, trackLabelFormat)
354
355 # File download
356 def _get_icon(self, url, songid):
357 if url != 'None':
358 localThumb = os.path.join(xbmc.translatePath(os.path.join(thumbDir, str(songid)))) + '.tbn'
359 try:
360 if os.path.isfile(localThumb) == False:
361 loc = urllib.URLopener()
362 loc.retrieve(url, localThumb)
363 except:
364 shutil.copy2(thumbDef, localThumb)
365 return os.path.join(os.path.join(thumbDir, str(songid))) + '.tbn'
366 else:
367 return thumbDef
368
369 # Add songs to directory
370 def _add_songs_directory(self, songs, trackLabelFormat=ARTIST_ALBUM_NAME_LABEL, page=0):
371
372 totalSongs = len(songs)
373 page = int(page)
374
375 # No pages needed
376 if page == 0 and totalSongs <= self.songspagelimit:
377 xbmc.log("Found " + str(totalSongs) + " songs...")
378 # Pages
379 else:
380 # Cache all songs
381 if page == 0:
382 self._setSavedSongs(songs)
383 else:
384 songs = self._getSavedSongs()
385 totalSongs = len(songs)
386
387 if totalSongs > 0:
388 start = page * self.songspagelimit
389 end = start + self.songspagelimit
390 songs = songs[start:end]
391
392 for song in songs:
393 item = self._get_song_item(song, trackLabelFormat)
394 coverart = item.getProperty('coverart')
395 songname = song[0]
396 songid = song[1]
397 songalbum = song[2]
398 songartist = song[4]
399 u=sys.argv[0]+"?mode="+str(MODE_SONG)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid) \
400 +"&album="+urllib.quote_plus(songalbum) \
401 +"&artist="+urllib.quote_plus(songartist) \
402 +"&coverart="+urllib.quote_plus(coverart)
403 fav=sys.argv[0]+"?mode="+str(MODE_FAVORITE)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid)
404 menuItems = []
405 menuItems.append(("Grooveshark favorite", "XBMC.RunPlugin("+fav+")"))
406 item.addContextMenuItems(menuItems, replaceItems=False)
407 xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=False, totalItems=len(songs))
408
409 page = page + 1
410 if totalSongs > page * self.songspagelimit:
411 u=sys.argv[0]+"?mode="+str(MODE_SONG_PAGE)+"&id=0"+"&page="+str(page)+"&label="+str(trackLabelFormat)
412 self._add_dir('More songs...', u, MODE_SONG_PAGE, self.songImg, 0, totalSongs - (page * self.songspagelimit))
413
414 xbmcplugin.setContent(self._handle, 'songs')
415 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
416
417 # Add albums to directory
418 def _add_albums_directory(self, albums):
419 n = len(albums)
420 xbmc.log("Found " + str(n) + " albums...")
421 i = 0
422 while i < n:
423 album = albums[i]
424 albumArtistName = album[0]
425 albumName = album[2]
426 albumID = album[3]
427 albumImage = self._get_icon(album[4], 'album-' + str(albumID))
428 self._add_dir(albumName + " - " + albumArtistName, '', MODE_ALBUM, albumImage, albumID, n)
429 i = i + 1
430 xbmcplugin.setContent(self._handle, 'albums')
431 xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_ALBUM_IGNORE_THE)
432 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
433
434 # Add artists to directory
435 def _add_artists_directory(self, artists):
436 n = len(artists)
437 xbmc.log("Found " + str(n) + " artists...")
438 i = 0
439 while i < n:
440 artist = artists[i]
441 artistName = artist[0]
442 artistID = artist[1]
443 self._add_dir(artistName, '', MODE_ARTIST, self.artistImg, artistID, n)
444 i = i + 1
445 xbmcplugin.setContent(self._handle, 'artists')
446 xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_ARTIST_IGNORE_THE)
447 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
448
449 # Add playlists to directory
450 def _add_playlists_directory(self, playlists):
451 n = len(playlists)
452 xbmc.log("Found " + str(n) + " playlists...")
453 i = 0
454 while i < n:
455 playlist = playlists[i]
456 playlistName = playlist[0]
457 playlistID = playlist[1]
458 dir = self._add_dir(playlistName, '', MODE_PLAYLIST, self.playlistImg, playlistID, n)
459 i = i + 1
460 xbmcplugin.setContent(self._handle, 'files')
461 xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_LABEL)
462 xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
463
464 # Add whatever directory
465 def _add_dir(self, name, url, mode, iconimage, id, items=1):
466 if url == '':
467 u=sys.argv[0]+"?mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&id="+str(id)
468 else:
469 u = url
470 dir=xbmcgui.ListItem(name, iconImage=iconimage, thumbnailImage=iconimage)
471 dir.setInfo( type="Music", infoLabels={ "title": name } )
472 return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=dir,isFolder=True, totalItems=items)
473
474 def _getSavedSongs(self):
475 path = os.path.join(cacheDir, 'songs.dmp')
476 try:
477 f = open(path, 'rb')
478 songs = pickle.load(f)
479 f.close()
480 except:
481 songs = []
482 pass
483 return songs
484
485 def _setSavedSongs(self, songs):
486 try:
487 # Create the 'data' directory if it doesn't exist.
488 if not os.path.exists(cacheDir):
489 os.makedirs(cacheDir)
490 path = os.path.join(cacheDir, 'songs.dmp')
491 f = open(path, 'wb')
492 pickle.dump(songs, f, protocol=pickle.HIGHEST_PROTOCOL)
493 f.close()
494 except:
495 xbmc.log("An error occurred saving songs")
496 pass
497
498
499
500 # Parse URL parameters
501 def get_params():
502 param=[]
503 paramstring=sys.argv[2]
504 xbmc.log(paramstring)
505 if len(paramstring)>=2:
506 params=sys.argv[2]
507 cleanedparams=params.replace('?','')
508 if (params[len(params)-1]=='/'):
509 params=params[0:len(params)-2]
510 pairsofparams=cleanedparams.split('&')
511 param={}
512 for i in range(len(pairsofparams)):
513 splitparams={}
514 splitparams=pairsofparams[i].split('=')
515 if (len(splitparams))==2:
516 param[splitparams[0]]=splitparams[1]
517 return param
518
519 # Main
520 grooveshark = Groveshark();
521
522 params=get_params()
523 mode=None
524 try: mode=int(params["mode"])
525 except: pass
526 id=0
527 try: id=int(params["id"])
528 except: pass
529
530 # Call function for URL
531 if mode==None:
532 grooveshark.categories()
533
534 elif mode==MODE_SEARCH_SONGS:
535 grooveshark.searchSongs()
536
537 elif mode==MODE_SEARCH_ALBUMS:
538 grooveshark.searchAlbums()
539
540 elif mode==MODE_SEARCH_ARTISTS:
541 grooveshark.searchArtists()
542
543 elif mode==MODE_SEARCH_ARTISTS_ALBUMS:
544 grooveshark.searchArtistsAlbums()
545
546 elif mode==MODE_SEARCH_PLAYLISTS:
547 grooveshark.searchPlaylists()
548
549 elif mode==MODE_POPULAR_SONGS:
550 grooveshark.popularSongs()
551
552 elif mode==MODE_ARTIST_POPULAR:
553 try: name=urllib.unquote_plus(params["name"])
554 except:
555 name = ""
556 pass
557 grooveshark.artistPopularSongs(name)
558
559 elif mode==MODE_FAVORITES:
560 grooveshark.favorites()
561
562 elif mode==MODE_PLAYLISTS:
563 grooveshark.playlists()
564
565 elif mode==MODE_SONG_PAGE:
566 try: page=urllib.unquote_plus(params["page"])
567 except: pass
568 try: label=urllib.unquote_plus(params["label"])
569 except: pass
570 grooveshark.songPage(page, label)
571
572 elif mode==MODE_SONG:
573 try: name=urllib.unquote_plus(params["name"])
574 except: pass
575 try: album=urllib.unquote_plus(params["album"])
576 except: pass
577 try: artist=urllib.unquote_plus(params["artist"])
578 except: pass
579 try: coverart=urllib.unquote_plus(params["coverart"])
580 except: pass
581 song = grooveshark.songItem(id, name, album, artist, coverart)
582 grooveshark.playSong(song)
583
584 elif mode==MODE_ARTIST:
585 grooveshark.artist(id)
586
587 elif mode==MODE_ALBUM:
588 grooveshark.album(id)
589
590 elif mode==MODE_PLAYLIST:
591 grooveshark.playlist(id)
592
593 elif mode==MODE_FAVORITE:
594 grooveshark.favorite(id)
595
596 if mode < MODE_SONG:
597 xbmcplugin.endOfDirectory(int(sys.argv[1]))