97289139 |
1 | import urllib, sys, os, shutil, re, time, xbmcaddon, xbmcplugin, xbmcgui, xbmc, pickle |
8817bb2e |
2 | MODE_SEARCH_SONGS = 1 |
3 | MODE_SEARCH_ALBUMS = 2 |
4 | MODE_SEARCH_ARTISTS = 3 |
86f629ea |
5 | MODE_SEARCH_ARTISTS_ALBUMS = 4 |
6 | MODE_SEARCH_PLAYLISTS = 5 |
97289139 |
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 |
052028f1 |
15 | MODE_SIMILAR_ARTISTS = 14 |
16 | MODE_SONG = 15 |
17 | MODE_FAVORITE = 16 |
18 | MODE_UNFAVORITE = 17 |
19 | MODE_MAKE_PLAYLIST = 18 |
20 | MODE_REMOVE_PLAYLIST = 19 |
21 | MODE_RENAME_PLAYLIST = 20 |
22 | MODE_REMOVE_PLAYLIST_SONG = 21 |
23 | MODE_ADD_PLAYLIST_SONG = 22 |
7ea6f166 |
24 | |
38df1fa5 |
25 | ACTION_MOVE_LEFT = 1 |
7ea6f166 |
26 | ACTION_MOVE_UP = 3 |
27 | ACTION_MOVE_DOWN = 4 |
28 | ACTION_PAGE_UP = 5 |
29 | ACTION_PAGE_DOWN = 6 |
30 | ACTION_SELECT_ITEM = 7 |
31 | ACTION_PREVIOUS_MENU = 10 |
8817bb2e |
32 | |
86f629ea |
33 | # Formats for track labels |
34 | ARTIST_ALBUM_NAME_LABEL = 0 |
35 | NAME_ALBUM_ARTIST_LABEL = 1 |
36 | |
6ae708d0 |
37 | baseDir = os.getcwd() |
38 | resDir = xbmc.translatePath(os.path.join(baseDir, 'resources')) |
8817bb2e |
39 | libDir = xbmc.translatePath(os.path.join(resDir, 'lib')) |
40 | imgDir = xbmc.translatePath(os.path.join(resDir, 'img')) |
7ce01be6 |
41 | cacheDir = os.path.join(xbmc.translatePath('special://masterprofile/addon_data/'), os.path.basename(os.getcwd())) |
42 | thumbDirName = 'thumb' |
43 | thumbDir = os.path.join('special://masterprofile/addon_data/', os.path.basename(os.getcwd()), thumbDirName) |
4be42357 |
44 | |
45 | baseModeUrl = 'plugin://plugin.audio.groove/' |
e278f474 |
46 | playlistUrl = baseModeUrl + '?mode=' + str(MODE_PLAYLIST) |
4be42357 |
47 | playlistsUrl = baseModeUrl + '?mode=' + str(MODE_PLAYLISTS) |
48 | favoritesUrl = baseModeUrl + '?mode=' + str(MODE_FAVORITES) |
49 | |
3d95dfcb |
50 | searchArtistsAlbumsName = "Search for artist's albums..." |
51 | |
7ce01be6 |
52 | thumbDef = os.path.join(imgDir, 'default.tbn') |
052028f1 |
53 | listBackground = os.path.join(imgDir, 'listbackground.png') |
8817bb2e |
54 | |
55 | sys.path.append (libDir) |
7ce01be6 |
56 | from GroovesharkAPI import GrooveAPI |
052028f1 |
57 | from GroovesharkAPI import GrooveAPIv1 |
7ce01be6 |
58 | |
a3ad8f73 |
59 | try: |
60 | groovesharkApi = GrooveAPI() |
7ce01be6 |
61 | if groovesharkApi.pingService() != True: |
62 | raise StandardError('No Grooveshark service') |
a3ad8f73 |
63 | except: |
64 | dialog = xbmcgui.Dialog() |
65 | dialog.ok('Grooveshark XBMC', 'Unable to connect with Grooveshark.', 'Please try again later') |
66 | sys.exit(-1) |
67 | |
8817bb2e |
68 | |
69 | class _Info: |
70 | def __init__( self, *args, **kwargs ): |
71 | self.__dict__.update( kwargs ) |
e278f474 |
72 | |
052028f1 |
73 | # Window dialog to select a grooveshark playlist |
74 | class GroovesharkPlaylistSelect(xbmcgui.WindowDialog): |
75 | |
76 | def __init__(self, items=[]): |
77 | gap = int(self.getHeight()/100) |
78 | w = int(self.getWidth()*0.5) |
79 | h = self.getHeight()-30*gap |
80 | rw = self.getWidth() |
81 | rh = self.getHeight() |
82 | x = rw/2 - w/2 |
83 | y = rh/2 -h/2 |
84 | |
85 | self.imgBg = xbmcgui.ControlImage(x+gap, 5*gap+y, w-2*gap, h-5*gap, listBackground) |
86 | self.addControl(self.imgBg) |
87 | |
88 | self.playlistControl = xbmcgui.ControlList(2*gap+x, y+3*gap+30, w-4*gap, h-10*gap, textColor='0xFFFFFFFF', selectedColor='0xFFFF4242', itemTextYOffset=0, itemHeight=50, alignmentY = 0) |
89 | self.addControl(self.playlistControl) |
90 | |
91 | self.lastPos = 0 |
92 | self.isSelecting = False |
93 | self.selected = -1 |
94 | listitems = [] |
95 | for playlist in items: |
96 | listitems.append(xbmcgui.ListItem(playlist[0])) |
97 | listitems.append(xbmcgui.ListItem('New...')) |
98 | self.playlistControl.addItems(listitems) |
99 | self.setFocus(self.playlistControl) |
100 | self.playlistControl.selectItem(0) |
101 | item = self.playlistControl.getListItem(self.lastPos) |
102 | item.select(True) |
103 | |
104 | # Highlight selected item |
105 | def setHighlight(self): |
106 | if self.isSelecting: |
107 | return |
108 | else: |
109 | self.isSelecting = True |
110 | |
111 | pos = self.playlistControl.getSelectedPosition() |
112 | if pos >= 0: |
113 | item = self.playlistControl.getListItem(self.lastPos) |
114 | item.select(False) |
115 | item = self.playlistControl.getListItem(pos) |
116 | item.select(True) |
117 | self.lastPos = pos |
118 | self.isSelecting = False |
119 | |
120 | # Control - select |
121 | def onControl(self, control): |
122 | if control == self.playlistControl: |
123 | self.selected = self.playlistControl.getSelectedPosition() |
124 | self.close() |
125 | |
126 | # Action - close or up/down |
127 | def onAction(self, action): |
128 | if action == ACTION_PREVIOUS_MENU: |
129 | self.selected = -1 |
130 | self.close() |
131 | elif action == ACTION_MOVE_UP or action == ACTION_MOVE_DOWN or action == ACTION_PAGE_UP or action == ACTION_PAGE_DOWN == 6: |
132 | self.setFocus(self.playlistControl) |
133 | self.setHighlight() |
7ce01be6 |
134 | |
8817bb2e |
135 | class Groveshark: |
973b4c6c |
136 | |
7ea6f166 |
137 | albumImg = xbmc.translatePath(os.path.join(imgDir, 'album.png')) |
138 | artistImg = xbmc.translatePath(os.path.join(imgDir, 'artist.png')) |
86f629ea |
139 | artistsAlbumsImg = xbmc.translatePath(os.path.join(imgDir, 'artistsalbums.png')) |
7ea6f166 |
140 | favoritesImg = xbmc.translatePath(os.path.join(imgDir, 'favorites.png')) |
141 | playlistImg = xbmc.translatePath(os.path.join(imgDir, 'playlist.png')) |
86f629ea |
142 | usersplaylistsImg = xbmc.translatePath(os.path.join(imgDir, 'usersplaylists.png')) |
7ea6f166 |
143 | popularSongsImg = xbmc.translatePath(os.path.join(imgDir, 'popularSongs.png')) |
97289139 |
144 | popularSongsArtistImg = xbmc.translatePath(os.path.join(imgDir, 'popularSongsArtist.png')) |
7ea6f166 |
145 | songImg = xbmc.translatePath(os.path.join(imgDir, 'song.png')) |
146 | defImg = xbmc.translatePath(os.path.join(imgDir, 'default.tbn')) |
2254a6b5 |
147 | fanImg = xbmc.translatePath(os.path.join(baseDir, 'fanart.png')) |
8817bb2e |
148 | |
2254a6b5 |
149 | settings = xbmcaddon.Addon(id='plugin.audio.groove') |
7ce01be6 |
150 | songsearchlimit = int(settings.getSetting('songsearchlimit')) |
151 | albumsearchlimit = int(settings.getSetting('albumsearchlimit')) |
152 | artistsearchlimit = int(settings.getSetting('artistsearchlimit')) |
97289139 |
153 | songspagelimit = int(settings.getSetting('songspagelimit')) |
2254a6b5 |
154 | username = settings.getSetting('username') |
155 | password = settings.getSetting('password') |
052028f1 |
156 | sessionidv1 = settings.getSetting('sessionidv1') |
38df1fa5 |
157 | userid = 0 |
4be42357 |
158 | |
8817bb2e |
159 | def __init__( self ): |
160 | self._handle = int(sys.argv[1]) |
7ce01be6 |
161 | if os.path.isdir(cacheDir) == False: |
162 | os.makedirs(cacheDir) |
163 | xbmc.log("Made " + cacheDir) |
164e42d8 |
164 | artDir = xbmc.translatePath(thumbDir) |
165 | if os.path.isdir(artDir) == False: |
3a794693 |
166 | os.makedirs(artDir) |
167 | xbmc.log("Made " + artDir) |
052028f1 |
168 | |
169 | self.groovesharkApiv1 = GrooveAPIv1(self.sessionidv1) |
170 | |
e278f474 |
171 | # Top-level menu |
8817bb2e |
172 | def categories(self): |
2254a6b5 |
173 | |
38df1fa5 |
174 | self.userid = self._get_login() |
b738088f |
175 | |
176 | # Setup |
6ae708d0 |
177 | xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg) |
6ae708d0 |
178 | |
86f629ea |
179 | self._add_dir('Search for songs...', '', MODE_SEARCH_SONGS, self.songImg, 0) |
180 | self._add_dir('Search for albums...', '', MODE_SEARCH_ALBUMS, self.albumImg, 0) |
181 | self._add_dir('Search for artists...', '', MODE_SEARCH_ARTISTS, self.artistImg, 0) |
3d95dfcb |
182 | self._add_dir(searchArtistsAlbumsName, '', MODE_SEARCH_ARTISTS_ALBUMS, self.artistsAlbumsImg, 0) |
86f629ea |
183 | self._add_dir("Search for user's playlists...", '', MODE_SEARCH_PLAYLISTS, self.usersplaylistsImg, 0) |
97289139 |
184 | self._add_dir('Popular songs for artist...', '', MODE_ARTIST_POPULAR, self.popularSongsArtistImg, 0) |
36cc00d7 |
185 | self._add_dir('Popular songs', '', MODE_POPULAR_SONGS, self.popularSongsImg, 0) |
38df1fa5 |
186 | if (self.userid != 0): |
86f629ea |
187 | self._add_dir('My favorites', '', MODE_FAVORITES, self.favoritesImg, 0) |
188 | self._add_dir('My playlists', '', MODE_PLAYLISTS, self.playlistImg, 0) |
e278f474 |
189 | |
190 | # Search for songs |
8817bb2e |
191 | def searchSongs(self): |
86f629ea |
192 | query = self._get_keyboard(default="", heading="Search for songs") |
7ea6f166 |
193 | if (query != ''): |
7ce01be6 |
194 | songs = groovesharkApi.getSongSearchResults(query, limit = self.songsearchlimit) |
8817bb2e |
195 | if (len(songs) > 0): |
6ae708d0 |
196 | self._add_songs_directory(songs) |
8817bb2e |
197 | else: |
198 | dialog = xbmcgui.Dialog() |
38df1fa5 |
199 | dialog.ok('Grooveshark XBMC', 'No matching songs.') |
8817bb2e |
200 | self.categories() |
7ea6f166 |
201 | else: |
202 | self.categories() |
8817bb2e |
203 | |
e278f474 |
204 | # Search for albums |
8817bb2e |
205 | def searchAlbums(self): |
86f629ea |
206 | query = self._get_keyboard(default="", heading="Search for albums") |
7ea6f166 |
207 | if (query != ''): |
7ce01be6 |
208 | albums = groovesharkApi.getAlbumSearchResults(query, limit = self.albumsearchlimit) |
8817bb2e |
209 | if (len(albums) > 0): |
6ae708d0 |
210 | self._add_albums_directory(albums) |
8817bb2e |
211 | else: |
212 | dialog = xbmcgui.Dialog() |
38df1fa5 |
213 | dialog.ok('Grooveshark XBMC', 'No matching albums.') |
8817bb2e |
214 | self.categories() |
7ea6f166 |
215 | else: |
216 | self.categories() |
8817bb2e |
217 | |
e278f474 |
218 | # Search for artists |
8817bb2e |
219 | def searchArtists(self): |
86f629ea |
220 | query = self._get_keyboard(default="", heading="Search for artists") |
7ea6f166 |
221 | if (query != ''): |
7ce01be6 |
222 | artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit) |
8817bb2e |
223 | if (len(artists) > 0): |
6ae708d0 |
224 | self._add_artists_directory(artists) |
8817bb2e |
225 | else: |
226 | dialog = xbmcgui.Dialog() |
38df1fa5 |
227 | dialog.ok('Grooveshark XBMC', 'No matching artists.') |
8817bb2e |
228 | self.categories() |
7ea6f166 |
229 | else: |
230 | self.categories() |
86f629ea |
231 | |
232 | # Search for playlists |
233 | def searchPlaylists(self): |
97289139 |
234 | query = self._get_keyboard(default="", heading="Username") |
86f629ea |
235 | if (query != ''): |
236 | playlists = groovesharkApi.getUserPlaylistsEx(query) |
237 | if (len(playlists) > 0): |
238 | self._add_playlists_directory(playlists) |
239 | else: |
240 | dialog = xbmcgui.Dialog() |
241 | dialog.ok('Grooveshark XBMC', 'No Grooveshark playlists found.') |
242 | self.categories() |
243 | else: |
244 | self.categories() |
245 | |
246 | # Search for artists albums |
3d95dfcb |
247 | def searchArtistsAlbums(self, artistName = None): |
248 | if artistName == None or artistName == searchArtistsAlbumsName: |
99f72740 |
249 | query = self._get_keyboard(default="", heading="Search for artist's albums") |
250 | else: |
251 | query = artistName |
86f629ea |
252 | if (query != ''): |
253 | artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit) |
254 | if (len(artists) > 0): |
255 | artist = artists[0] |
256 | artistID = artist[1] |
257 | xbmc.log("Found " + artist[0] + "...") |
258 | albums = groovesharkApi.getArtistAlbums(artistID, limit = self.albumsearchlimit) |
259 | if (len(albums) > 0): |
052028f1 |
260 | self._add_albums_directory(albums, artistID) |
86f629ea |
261 | else: |
262 | dialog = xbmcgui.Dialog() |
263 | dialog.ok('Grooveshark XBMC', 'No matching albums.') |
264 | self.categories() |
265 | else: |
266 | dialog = xbmcgui.Dialog() |
267 | dialog.ok('Grooveshark XBMC', 'No matching artists.') |
268 | self.categories() |
269 | else: |
270 | self.categories() |
271 | |
e278f474 |
272 | # Get my favorites |
8817bb2e |
273 | def favorites(self): |
36cc00d7 |
274 | userid = self._get_login() |
275 | if (userid != 0): |
7ce01be6 |
276 | favorites = groovesharkApi.getUserFavoriteSongs() |
36cc00d7 |
277 | if (len(favorites) > 0): |
052028f1 |
278 | self._add_songs_directory(favorites, isFavorites=True) |
36cc00d7 |
279 | else: |
280 | dialog = xbmcgui.Dialog() |
38df1fa5 |
281 | dialog.ok('Grooveshark XBMC', 'You have no favorites.') |
36cc00d7 |
282 | self.categories() |
8817bb2e |
283 | |
e278f474 |
284 | # Get popular songs |
36cc00d7 |
285 | def popularSongs(self): |
7ce01be6 |
286 | popular = groovesharkApi.getPopularSongsToday(limit = self.songsearchlimit) |
8817bb2e |
287 | if (len(popular) > 0): |
6ae708d0 |
288 | self._add_songs_directory(popular) |
8817bb2e |
289 | else: |
290 | dialog = xbmcgui.Dialog() |
38df1fa5 |
291 | dialog.ok('Grooveshark XBMC', 'No popular songs.') |
8817bb2e |
292 | self.categories() |
36cc00d7 |
293 | |
e278f474 |
294 | # Get my playlists |
8817bb2e |
295 | def playlists(self): |
296 | userid = self._get_login() |
297 | if (userid != 0): |
7ce01be6 |
298 | playlists = groovesharkApi.getUserPlaylists() |
8817bb2e |
299 | if (len(playlists) > 0): |
6ae708d0 |
300 | self._add_playlists_directory(playlists) |
8817bb2e |
301 | else: |
302 | dialog = xbmcgui.Dialog() |
38df1fa5 |
303 | dialog.ok('Grooveshark XBMC', 'You have no Grooveshark playlists.') |
8817bb2e |
304 | self.categories() |
7ea6f166 |
305 | else: |
306 | dialog = xbmcgui.Dialog() |
38df1fa5 |
307 | dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to see your Grooveshark playlists.') |
7ea6f166 |
308 | |
e278f474 |
309 | # Make songs a favorite |
8817bb2e |
310 | def favorite(self, songid): |
311 | userid = self._get_login() |
312 | if (userid != 0): |
406ab447 |
313 | xbmc.log("Favorite song: " + str(songid)) |
7ce01be6 |
314 | groovesharkApi.addUserFavoriteSong(songID = songid) |
38df1fa5 |
315 | xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Added to favorites, 1000, ' + thumbDef + ')') |
8817bb2e |
316 | else: |
317 | dialog = xbmcgui.Dialog() |
38df1fa5 |
318 | dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to add favorites.') |
052028f1 |
319 | |
320 | # Remove song from favorites |
321 | def unfavorite(self, songid, prevMode=0): |
322 | userid = self._get_login(version = 1) |
323 | if (userid != 0): |
324 | xbmc.log("Unfavorite song: " + str(songid) + ', previous mode was ' + str(prevMode)) |
325 | self.groovesharkApiv1.unfavorite(songID = songid) |
326 | xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Removed from Grooveshark favorites, 1000, ' + thumbDef + ')') |
327 | # Refresh to remove item from directory |
328 | if (int(prevMode) == MODE_FAVORITES): |
329 | xbmc.executebuiltin("Container.Refresh(" + favoritesUrl + ")") |
330 | else: |
331 | dialog = xbmcgui.Dialog() |
332 | dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to remove Grooveshark favorites.') |
333 | |
e278f474 |
334 | |
335 | # Show selected album |
36cc00d7 |
336 | def album(self, albumid): |
7ce01be6 |
337 | album = groovesharkApi.getAlbumSongs(albumid, limit = self.songsearchlimit) |
86f629ea |
338 | self._add_songs_directory(album, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL) |
e278f474 |
339 | |
340 | # Show selected artist |
8817bb2e |
341 | def artist(self, artistid): |
7ce01be6 |
342 | albums = groovesharkApi.getArtistAlbums(artistid, limit = self.albumsearchlimit) |
052028f1 |
343 | self._add_albums_directory(albums, artistid) |
8817bb2e |
344 | |
e278f474 |
345 | # Show selected playlist |
052028f1 |
346 | def playlist(self, playlistid, playlistname, version = 2): |
8817bb2e |
347 | userid = self._get_login() |
348 | if (userid != 0): |
052028f1 |
349 | if version == 1: |
350 | songs = self.groovesharkApiv1.playlistGetSongs(playlistid) |
351 | else: |
352 | songs = groovesharkApi.getPlaylistSongs(playlistid) |
353 | self._add_songs_directory(songs, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL, playlistid=playlistid, playlistname=playlistname) |
8817bb2e |
354 | else: |
355 | dialog = xbmcgui.Dialog() |
38df1fa5 |
356 | dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to get Grooveshark playlists.') |
8817bb2e |
357 | |
97289139 |
358 | # Show popular songs of the artist |
359 | def artistPopularSongs(self): |
360 | query = self._get_keyboard(default="", heading="Artist") |
361 | if (query != ''): |
362 | artists = groovesharkApi.getArtistSearchResults(query, limit = self.artistsearchlimit) |
363 | if (len(artists) > 0): |
364 | artist = artists[0] |
365 | artistID = artist[1] |
366 | xbmc.log("Found " + artist[0] + "...") |
367 | songs = groovesharkApi.getArtistPopularSongs(artistID, limit = self.songsearchlimit) |
368 | if (len(songs) > 0): |
369 | self._add_songs_directory(songs, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL) |
370 | else: |
371 | dialog = xbmcgui.Dialog() |
372 | dialog.ok('Grooveshark XBMC', 'No popular songs.') |
373 | self.categories() |
374 | else: |
375 | dialog = xbmcgui.Dialog() |
376 | dialog.ok('Grooveshark XBMC', 'No matching artists.') |
377 | self.categories() |
378 | else: |
379 | self.categories() |
380 | |
e278f474 |
381 | # Play a song |
6ae708d0 |
382 | def playSong(self, item): |
7ce01be6 |
383 | songid = item.getProperty('songid') |
384 | song = groovesharkApi.getSongURLFromSongID(songid) |
cbb0985e |
385 | if song != '': |
7ce01be6 |
386 | item.setPath(song) |
387 | xbmc.log("Playing: " + song) |
388 | xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item) |
389 | else: |
cbb0985e |
390 | xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Unable to play song, 1000, ' + thumbDef + ')') |
3fcef5ba |
391 | |
e278f474 |
392 | # Make a song directory item |
86f629ea |
393 | def songItem(self, songid, name, album, artist, coverart, trackLabelFormat=ARTIST_ALBUM_NAME_LABEL): |
7ce01be6 |
394 | songImg = self._get_icon(coverart, 'song-' + str(songid) + "-image") |
86f629ea |
395 | if trackLabelFormat == NAME_ALBUM_ARTIST_LABEL: |
396 | trackLabel = name + " - " + album + " - " + artist |
397 | else: |
398 | trackLabel = artist + " - " + album + " - " + name |
399 | item = xbmcgui.ListItem(label = trackLabel, thumbnailImage=songImg, iconImage=songImg) |
7ce01be6 |
400 | item.setInfo( type="music", infoLabels={ "title": name, "album": album, "artist": artist} ) |
2254a6b5 |
401 | item.setProperty('mimetype', 'audio/mpeg') |
402 | item.setProperty("IsPlayable", "true") |
7ce01be6 |
403 | item.setProperty('songid', str(songid)) |
404 | item.setProperty('coverart', songImg) |
405 | item.setProperty('title', name) |
406 | item.setProperty('album', album) |
407 | item.setProperty('artist', artist) |
408 | |
6ae708d0 |
409 | return item |
2254a6b5 |
410 | |
97289139 |
411 | # Next page of songs |
052028f1 |
412 | def songPage(self, page, trackLabelFormat, playlistid = 0, playlistname = ''): |
413 | self._add_songs_directory([], trackLabelFormat, page, playlistid = playlistid, playlistname = playlistname) |
414 | |
415 | # Make a playlist from an album |
416 | def makePlaylist(self, albumid, name): |
417 | userid = self._get_login(version = 1) |
418 | if (userid != 0): |
419 | re.split(' - ',name,1) |
420 | nameTokens = re.split(' - ',name,1) # suggested name |
421 | name = self._get_keyboard(default=nameTokens[0], heading="Grooveshark playlist name") |
422 | if name != '': |
423 | album = groovesharkApi.getAlbumSongs(albumid, limit = self.songsearchlimit) |
424 | songids = [] |
425 | for song in album: |
426 | songids.append(song[1]) |
427 | if self.groovesharkApiv1.playlistCreateUnique(name, songids) == 0: |
428 | dialog = xbmcgui.Dialog() |
429 | dialog.ok('Grooveshark XBMC', 'Cannot create Grooveshark playlist ', name) |
430 | else: |
431 | xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Grooveshark playlist created, 1000, ' + thumbDef + ')') |
432 | else: |
433 | dialog = xbmcgui.Dialog() |
434 | dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to create a Grooveshark playlist.') |
435 | |
436 | # Rename a playlist |
437 | def renamePlaylist(self, playlistid, name): |
438 | userid = self._get_login(version = 1) |
439 | if (userid != 0): |
440 | newname = self._get_keyboard(default=name, heading="Grooveshark playlist name") |
441 | if newname == '': |
442 | return |
443 | elif self.groovesharkApiv1.playlistRename(playlistid, newname) == 0: |
444 | dialog = xbmcgui.Dialog() |
445 | dialog.ok('Grooveshark XBMC', 'Cannot rename Grooveshark playlist ', name) |
446 | else: |
447 | # Refresh to show new item name |
448 | xbmc.executebuiltin("Container.Refresh") |
449 | else: |
450 | dialog = xbmcgui.Dialog() |
451 | dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to rename a Grooveshark playlist.') |
452 | |
453 | # Remove a playlist |
454 | def removePlaylist(self, playlistid, name): |
455 | dialog = xbmcgui.Dialog() |
456 | if dialog.yesno('Grooveshark XBMC', name, 'Delete this Grooveshark playlist?') == True: |
457 | userid = self._get_login(version = 1) |
458 | if (userid != 0): |
459 | if self.groovesharkApiv1.playlistDelete(playlistid) == 0: |
460 | dialog = xbmcgui.Dialog() |
461 | dialog.ok('Grooveshark XBMC', 'Cannot remove Grooveshark playlist ', name) |
462 | else: |
463 | # Refresh to remove item from directory |
464 | xbmc.executebuiltin("Container.Refresh(" + playlistsUrl + ")") |
465 | else: |
466 | dialog = xbmcgui.Dialog() |
467 | dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to delete a Grooveshark playlist.') |
468 | |
469 | # Add song to playlist |
470 | def addPlaylistSong(self, songid): |
471 | userid = self._get_login(version = 1) |
472 | if (userid != 0): |
473 | playlists = groovesharkApi.getUserPlaylists() |
474 | if (len(playlists) > 0): |
475 | ret = 0 |
476 | # Select the playlist |
477 | playlistSelect = GroovesharkPlaylistSelect(items=playlists) |
478 | playlistSelect.setFocus(playlistSelect.playlistControl) |
479 | playlistSelect.doModal() |
480 | i = playlistSelect.selected |
481 | del playlistSelect |
482 | if i > -1: |
483 | # Add a new playlist |
484 | if i >= len(playlists): |
485 | name = self._get_keyboard(default='', heading="Grooveshark playlist name") |
486 | if name != '': |
487 | songIds = [] |
488 | songIds.append(songid) |
489 | if self.groovesharkApiv1.playlistCreateUnique(name, songIds) == 0: |
490 | dialog = xbmcgui.Dialog() |
491 | dialog.ok('Grooveshark XBMC', 'Cannot create Grooveshark playlist ', name) |
492 | else: |
493 | xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Grooveshark playlist created, 1000, ' + thumbDef + ')') |
494 | # Existing playlist |
495 | else: |
496 | playlist = playlists[i] |
497 | playlistid = playlist[1] |
498 | xbmc.log("Add song " + str(songid) + " to playlist " + str(playlistid)) |
499 | ret = self.groovesharkApiv1.playlistAddSong(playlistid, songid, 0) |
500 | if ret == 0: |
501 | dialog = xbmcgui.Dialog() |
502 | dialog.ok('Grooveshark XBMC', 'Cannot add to playlist ') |
503 | else: |
504 | xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Added song to Grooveshark playlist, 1000, ' + thumbDef + ')') |
505 | else: |
506 | dialog = xbmcgui.Dialog() |
507 | dialog.ok('Grooveshark XBMC', 'You have no Grooveshark playlists.') |
508 | self.categories() |
509 | else: |
510 | dialog = xbmcgui.Dialog() |
511 | dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to add a song to a Grooveshark playlist.') |
512 | |
513 | # Remove song from playlist |
514 | def removePlaylistSong(self, playlistid, playlistname, songpos): |
515 | dialog = xbmcgui.Dialog(version = 1) |
516 | if dialog.yesno('Grooveshark XBMC', 'Delete this song from the Grooveshark playlist?') == True: |
517 | userid = self._get_login(version = 1) |
518 | if (userid != 0): |
519 | if self.groovesharkApiv1.playlistDeleteSong(playlistid, songpos) == 0: |
520 | dialog = xbmcgui.Dialog() |
521 | dialog.ok('Grooveshark XBMC', 'Failed to remove', 'song from Grooveshark playlist.') |
522 | else: |
523 | # Refresh to remove item from directory |
524 | xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Removed song from Grooveshark playlist, 1000, ' + thumbDef + ')') |
525 | xbmc.executebuiltin("Container.Update(" + playlistUrl + "&id="+str(playlistid) + "&name=" + playlistname + "&version=1)") |
526 | else: |
527 | dialog = xbmcgui.Dialog() |
528 | dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to delete a song from a Grooveshark playlist.') |
529 | |
530 | # Find similar artists to searched artist |
531 | def similarArtists(self, artistId): |
532 | similar = self.groovesharkApiv1.artistGetSimilar(artistId, limit = self.artistsearchlimit) |
533 | if (len(similar) > 0): |
534 | self._add_artists_directory(similar) |
535 | else: |
536 | dialog = xbmcgui.Dialog() |
537 | dialog.ok('Grooveshark XBMC', 'No similar artists.') |
538 | self.categories() |
97289139 |
539 | |
e278f474 |
540 | # Get keyboard input |
8817bb2e |
541 | def _get_keyboard(self, default="", heading="", hidden=False): |
3cfead3c |
542 | kb = xbmc.Keyboard(default, heading, hidden) |
543 | kb.doModal() |
544 | if (kb.isConfirmed()): |
545 | return unicode(kb.getText(), "utf-8") |
546 | return '' |
8817bb2e |
547 | |
e278f474 |
548 | # Login to grooveshark |
052028f1 |
549 | def _get_login(self, version = 2): |
2254a6b5 |
550 | if (self.username == "" or self.password == ""): |
8817bb2e |
551 | dialog = xbmcgui.Dialog() |
38df1fa5 |
552 | dialog.ok('Grooveshark XBMC', 'Unable to login.', 'Check username and password in settings.') |
8817bb2e |
553 | return 0 |
554 | else: |
38df1fa5 |
555 | if self.userid == 0: |
052028f1 |
556 | if version == 1: |
557 | uid = self.groovesharkApiv1.login(self.username, self.password) |
558 | else: |
559 | uid = groovesharkApi.login(self.username, self.password) |
38df1fa5 |
560 | if (uid != 0): |
38df1fa5 |
561 | return uid |
8817bb2e |
562 | else: |
563 | dialog = xbmcgui.Dialog() |
38df1fa5 |
564 | dialog.ok('Grooveshark XBMC', 'Unable to login.', 'Check username and password in settings.') |
8817bb2e |
565 | return 0 |
566 | |
e278f474 |
567 | # Get a song directory item |
86f629ea |
568 | def _get_song_item(self, song, trackLabelFormat): |
6ae708d0 |
569 | name = song[0] |
7ce01be6 |
570 | songid = song[1] |
571 | album = song[2] |
572 | artist = song[4] |
573 | coverart = song[6] |
86f629ea |
574 | return self.songItem(songid, name, album, artist, coverart, trackLabelFormat) |
6ae708d0 |
575 | |
576 | # File download |
7ce01be6 |
577 | def _get_icon(self, url, songid): |
578 | if url != 'None': |
579 | localThumb = os.path.join(xbmc.translatePath(os.path.join(thumbDir, str(songid)))) + '.tbn' |
580 | try: |
581 | if os.path.isfile(localThumb) == False: |
582 | loc = urllib.URLopener() |
583 | loc.retrieve(url, localThumb) |
584 | except: |
585 | shutil.copy2(thumbDef, localThumb) |
586 | return os.path.join(os.path.join(thumbDir, str(songid))) + '.tbn' |
587 | else: |
588 | return thumbDef |
e278f474 |
589 | |
590 | # Add songs to directory |
052028f1 |
591 | def _add_songs_directory(self, songs, trackLabelFormat=ARTIST_ALBUM_NAME_LABEL, page=0, playlistid=0, playlistname='', isFavorites=False): |
97289139 |
592 | |
593 | totalSongs = len(songs) |
594 | page = int(page) |
595 | |
596 | # No pages needed |
597 | if page == 0 and totalSongs <= self.songspagelimit: |
598 | xbmc.log("Found " + str(totalSongs) + " songs...") |
599 | # Pages |
600 | else: |
601 | # Cache all songs |
602 | if page == 0: |
603 | self._setSavedSongs(songs) |
604 | else: |
605 | songs = self._getSavedSongs() |
606 | totalSongs = len(songs) |
607 | |
608 | if totalSongs > 0: |
609 | start = page * self.songspagelimit |
610 | end = start + self.songspagelimit |
611 | songs = songs[start:end] |
612 | |
052028f1 |
613 | id = 0 |
97289139 |
614 | for song in songs: |
86f629ea |
615 | item = self._get_song_item(song, trackLabelFormat) |
7ce01be6 |
616 | coverart = item.getProperty('coverart') |
6ae708d0 |
617 | songname = song[0] |
618 | songid = song[1] |
7ce01be6 |
619 | songalbum = song[2] |
620 | songartist = song[4] |
e278f474 |
621 | u=sys.argv[0]+"?mode="+str(MODE_SONG)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid) \ |
6ae708d0 |
622 | +"&album="+urllib.quote_plus(songalbum) \ |
623 | +"&artist="+urllib.quote_plus(songartist) \ |
7ce01be6 |
624 | +"&coverart="+urllib.quote_plus(coverart) |
e278f474 |
625 | fav=sys.argv[0]+"?mode="+str(MODE_FAVORITE)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid) |
052028f1 |
626 | unfav=sys.argv[0]+"?mode="+str(MODE_UNFAVORITE)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid)+"&prevmode=" |
6ae708d0 |
627 | menuItems = [] |
052028f1 |
628 | if isFavorites == True: |
629 | unfav = unfav +str(MODE_FAVORITES) |
630 | else: |
631 | menuItems.append(("Grooveshark favorite", "XBMC.RunPlugin("+fav+")")) |
632 | if self.sessionidv1 != '': |
633 | menuItems.append(("Not Grooveshark favorite", "XBMC.RunPlugin("+unfav+")")) |
634 | if playlistid > 0: |
635 | rmplaylstsong=sys.argv[0]+"?playlistid="+str(playlistid)+"&id="+str(id+1)+"&mode="+str(MODE_REMOVE_PLAYLIST_SONG)+"&name="+playlistname |
636 | menuItems.append(("Remove from Grooveshark playlist", "XBMC.RunPlugin("+rmplaylstsong+")")) |
637 | else: |
638 | addplaylstsong=sys.argv[0]+"?id="+str(songid)+"&mode="+str(MODE_ADD_PLAYLIST_SONG) |
639 | menuItems.append(("Add to Grooveshark playlist", "XBMC.RunPlugin("+addplaylstsong+")")) |
6ae708d0 |
640 | item.addContextMenuItems(menuItems, replaceItems=False) |
97289139 |
641 | xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=False, totalItems=len(songs)) |
052028f1 |
642 | id = id + 1 |
97289139 |
643 | |
644 | page = page + 1 |
645 | if totalSongs > page * self.songspagelimit: |
052028f1 |
646 | u=sys.argv[0]+"?mode="+str(MODE_SONG_PAGE)+"&id=playlistid"+"&page="+str(page)+"&label="+str(trackLabelFormat)+"&name="+playlistname |
97289139 |
647 | self._add_dir('More songs...', u, MODE_SONG_PAGE, self.songImg, 0, totalSongs - (page * self.songspagelimit)) |
cb06c186 |
648 | |
8817bb2e |
649 | xbmcplugin.setContent(self._handle, 'songs') |
31731635 |
650 | xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg) |
e278f474 |
651 | |
652 | # Add albums to directory |
052028f1 |
653 | def _add_albums_directory(self, albums, artistid=0): |
31731635 |
654 | n = len(albums) |
655 | xbmc.log("Found " + str(n) + " albums...") |
8817bb2e |
656 | i = 0 |
31731635 |
657 | while i < n: |
8817bb2e |
658 | album = albums[i] |
659 | albumArtistName = album[0] |
660 | albumName = album[2] |
661 | albumID = album[3] |
2254a6b5 |
662 | albumImage = self._get_icon(album[4], 'album-' + str(albumID)) |
31731635 |
663 | self._add_dir(albumName + " - " + albumArtistName, '', MODE_ALBUM, albumImage, albumID, n) |
8817bb2e |
664 | i = i + 1 |
052028f1 |
665 | if artistid > 0 and self.sessionidv1 != '': |
666 | self._add_dir('Similar artists...', '', MODE_SIMILAR_ARTISTS, self.artistImg, artistid) |
8817bb2e |
667 | xbmcplugin.setContent(self._handle, 'albums') |
668 | xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_ALBUM_IGNORE_THE) |
31731635 |
669 | xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg) |
e278f474 |
670 | |
671 | # Add artists to directory |
6ae708d0 |
672 | def _add_artists_directory(self, artists): |
31731635 |
673 | n = len(artists) |
674 | xbmc.log("Found " + str(n) + " artists...") |
8817bb2e |
675 | i = 0 |
31731635 |
676 | while i < n: |
8817bb2e |
677 | artist = artists[i] |
678 | artistName = artist[0] |
679 | artistID = artist[1] |
31731635 |
680 | self._add_dir(artistName, '', MODE_ARTIST, self.artistImg, artistID, n) |
8817bb2e |
681 | i = i + 1 |
682 | xbmcplugin.setContent(self._handle, 'artists') |
683 | xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_ARTIST_IGNORE_THE) |
31731635 |
684 | xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg) |
e278f474 |
685 | |
686 | # Add playlists to directory |
6ae708d0 |
687 | def _add_playlists_directory(self, playlists): |
31731635 |
688 | n = len(playlists) |
689 | xbmc.log("Found " + str(n) + " playlists...") |
8817bb2e |
690 | i = 0 |
31731635 |
691 | while i < n: |
8817bb2e |
692 | playlist = playlists[i] |
693 | playlistName = playlist[0] |
694 | playlistID = playlist[1] |
86f629ea |
695 | dir = self._add_dir(playlistName, '', MODE_PLAYLIST, self.playlistImg, playlistID, n) |
8817bb2e |
696 | i = i + 1 |
697 | xbmcplugin.setContent(self._handle, 'files') |
86f629ea |
698 | xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_LABEL) |
31731635 |
699 | xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg) |
3fcef5ba |
700 | |
e278f474 |
701 | # Add whatever directory |
31731635 |
702 | def _add_dir(self, name, url, mode, iconimage, id, items=1): |
052028f1 |
703 | |
97289139 |
704 | if url == '': |
705 | u=sys.argv[0]+"?mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&id="+str(id) |
706 | else: |
707 | u = url |
8817bb2e |
708 | dir=xbmcgui.ListItem(name, iconImage=iconimage, thumbnailImage=iconimage) |
b738088f |
709 | dir.setInfo( type="Music", infoLabels={ "title": name } ) |
052028f1 |
710 | |
711 | # Custom menu items |
712 | if self.sessionidv1 != '': |
713 | menuItems = [] |
714 | if mode == MODE_ALBUM: |
715 | mkplaylst=sys.argv[0]+"?mode="+str(MODE_MAKE_PLAYLIST)+"&name="+name+"&id="+str(id) |
716 | menuItems.append(("Make Grooveshark playlist", "XBMC.RunPlugin("+mkplaylst+")")) |
717 | if mode == MODE_PLAYLIST: |
718 | rmplaylst=sys.argv[0]+"?mode="+str(MODE_REMOVE_PLAYLIST)+"&name="+urllib.quote_plus(name)+"&id="+str(id) |
719 | menuItems.append(("Delete Grooveshark playlist", "XBMC.RunPlugin("+rmplaylst+")")) |
720 | mvplaylst=sys.argv[0]+"?mode="+str(MODE_RENAME_PLAYLIST)+"&name="+urllib.quote_plus(name)+"&id="+str(id) |
721 | menuItems.append(("Rename Grooveshark playlist", "XBMC.RunPlugin("+mvplaylst+")")) |
722 | dir.addContextMenuItems(menuItems, replaceItems=False) |
723 | |
31731635 |
724 | return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=dir,isFolder=True, totalItems=items) |
97289139 |
725 | |
726 | def _getSavedSongs(self): |
727 | path = os.path.join(cacheDir, 'songs.dmp') |
728 | try: |
729 | f = open(path, 'rb') |
730 | songs = pickle.load(f) |
731 | f.close() |
732 | except: |
733 | songs = [] |
734 | pass |
735 | return songs |
736 | |
737 | def _setSavedSongs(self, songs): |
738 | try: |
739 | # Create the 'data' directory if it doesn't exist. |
740 | if not os.path.exists(cacheDir): |
741 | os.makedirs(cacheDir) |
742 | path = os.path.join(cacheDir, 'songs.dmp') |
743 | f = open(path, 'wb') |
744 | pickle.dump(songs, f, protocol=pickle.HIGHEST_PROTOCOL) |
745 | f.close() |
746 | except: |
747 | xbmc.log("An error occurred saving songs") |
748 | pass |
749 | |
e278f474 |
750 | # Parse URL parameters |
8817bb2e |
751 | def get_params(): |
752 | param=[] |
753 | paramstring=sys.argv[2] |
e278f474 |
754 | xbmc.log(paramstring) |
8817bb2e |
755 | if len(paramstring)>=2: |
756 | params=sys.argv[2] |
757 | cleanedparams=params.replace('?','') |
758 | if (params[len(params)-1]=='/'): |
759 | params=params[0:len(params)-2] |
760 | pairsofparams=cleanedparams.split('&') |
761 | param={} |
762 | for i in range(len(pairsofparams)): |
763 | splitparams={} |
764 | splitparams=pairsofparams[i].split('=') |
765 | if (len(splitparams))==2: |
766 | param[splitparams[0]]=splitparams[1] |
8817bb2e |
767 | return param |
768 | |
e278f474 |
769 | # Main |
8817bb2e |
770 | grooveshark = Groveshark(); |
e278f474 |
771 | |
8817bb2e |
772 | params=get_params() |
8817bb2e |
773 | mode=None |
8817bb2e |
774 | try: mode=int(params["mode"]) |
775 | except: pass |
7ce01be6 |
776 | id=0 |
777 | try: id=int(params["id"]) |
778 | except: pass |
052028f1 |
779 | name = None |
780 | try: name=urllib.unquote_plus(params["name"]) |
781 | except: pass |
e278f474 |
782 | |
783 | # Call function for URL |
8817bb2e |
784 | if mode==None: |
785 | grooveshark.categories() |
786 | |
787 | elif mode==MODE_SEARCH_SONGS: |
788 | grooveshark.searchSongs() |
789 | |
790 | elif mode==MODE_SEARCH_ALBUMS: |
791 | grooveshark.searchAlbums() |
792 | |
793 | elif mode==MODE_SEARCH_ARTISTS: |
794 | grooveshark.searchArtists() |
86f629ea |
795 | |
796 | elif mode==MODE_SEARCH_ARTISTS_ALBUMS: |
a2e75b14 |
797 | grooveshark.searchArtistsAlbums(name) |
86f629ea |
798 | |
799 | elif mode==MODE_SEARCH_PLAYLISTS: |
800 | grooveshark.searchPlaylists() |
8817bb2e |
801 | |
36cc00d7 |
802 | elif mode==MODE_POPULAR_SONGS: |
803 | grooveshark.popularSongs() |
97289139 |
804 | |
805 | elif mode==MODE_ARTIST_POPULAR: |
a2e75b14 |
806 | grooveshark.artistPopularSongs() |
8817bb2e |
807 | |
8817bb2e |
808 | elif mode==MODE_FAVORITES: |
809 | grooveshark.favorites() |
810 | |
e278f474 |
811 | elif mode==MODE_PLAYLISTS: |
812 | grooveshark.playlists() |
97289139 |
813 | |
814 | elif mode==MODE_SONG_PAGE: |
815 | try: page=urllib.unquote_plus(params["page"]) |
816 | except: pass |
817 | try: label=urllib.unquote_plus(params["label"]) |
818 | except: pass |
052028f1 |
819 | grooveshark.songPage(page, label, id, name) |
e278f474 |
820 | |
8817bb2e |
821 | elif mode==MODE_SONG: |
8817bb2e |
822 | try: album=urllib.unquote_plus(params["album"]) |
823 | except: pass |
824 | try: artist=urllib.unquote_plus(params["artist"]) |
825 | except: pass |
7ce01be6 |
826 | try: coverart=urllib.unquote_plus(params["coverart"]) |
8817bb2e |
827 | except: pass |
7ce01be6 |
828 | song = grooveshark.songItem(id, name, album, artist, coverart) |
3fcef5ba |
829 | grooveshark.playSong(song) |
8817bb2e |
830 | |
831 | elif mode==MODE_ARTIST: |
4be42357 |
832 | grooveshark.artist(id) |
8817bb2e |
833 | |
834 | elif mode==MODE_ALBUM: |
4be42357 |
835 | grooveshark.album(id) |
8817bb2e |
836 | |
837 | elif mode==MODE_PLAYLIST: |
052028f1 |
838 | version = 2 |
839 | try: version=urllib.unquote_plus(params["version"]) |
840 | except: pass |
841 | grooveshark.playlist(id, name, version) |
8817bb2e |
842 | |
843 | elif mode==MODE_FAVORITE: |
4be42357 |
844 | grooveshark.favorite(id) |
97289139 |
845 | |
052028f1 |
846 | elif mode==MODE_UNFAVORITE: |
847 | try: prevMode=int(urllib.unquote_plus(params["prevmode"])) |
848 | except: |
849 | prevMode = 0 |
850 | grooveshark.unfavorite(id, prevMode) |
851 | |
852 | elif mode==MODE_SIMILAR_ARTISTS: |
853 | grooveshark.similarArtists(id) |
854 | |
855 | elif mode==MODE_MAKE_PLAYLIST: |
856 | grooveshark.makePlaylist(id, name) |
857 | |
858 | elif mode==MODE_REMOVE_PLAYLIST: |
859 | grooveshark.removePlaylist(id, name) |
860 | |
861 | elif mode==MODE_RENAME_PLAYLIST: |
862 | grooveshark.renamePlaylist(id, name) |
863 | |
864 | elif mode==MODE_REMOVE_PLAYLIST_SONG: |
865 | try: playlistID=urllib.unquote_plus(params["playlistid"]) |
866 | except: pass |
867 | grooveshark.removePlaylistSong(playlistID, name, id) |
868 | |
869 | elif mode==MODE_ADD_PLAYLIST_SONG: |
870 | grooveshark.addPlaylistSong(id) |
871 | |
e278f474 |
872 | if mode < MODE_SONG: |
8817bb2e |
873 | xbmcplugin.endOfDirectory(int(sys.argv[1])) |