+
+ def makePlaylist(self, albumid, name):
+ userid = self._get_login()
+ if (userid != 0):
+ re.split(' - ',name,1)
+ nameTokens = re.split(' - ',name,1)
+ name = self._get_keyboard(default=nameTokens[0], heading="Grooveshark playlist name")
+ if name != '':
+ groovesharkApi.setRemoveDuplicates(True)
+ album = groovesharkApi.albumGetSongs(albumid, self.songsearchlimit)
+ songids = []
+ for song in album:
+ songids.append(song[1])
+ if groovesharkApi.playlistCreateUnique(name, songids) == 0:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'Cannot create Grooveshark playlist ', name)
+ else:
+ xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Grooveshark playlist created, 1000, ' + thumbDef + ')')
+ else:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to create a Grooveshark playlist.')
+
+ def removePlaylist(self, playlistid, name):
+ dialog = xbmcgui.Dialog()
+ if dialog.yesno('Grooveshark XBMC', name, 'Delete this Grooveshark playlist?') == True:
+ userid = self._get_login()
+ if (userid != 0):
+ groovesharkApi.playlistDelete(playlistid)
+ xbmc.executebuiltin("Container.Refresh(" + playlistsUrl + ")")
+ else:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to delete a Grooveshark playlist.')
+
+ def removePlaylistSong(self, playlistid, playlistname, songpos):
+ dialog = xbmcgui.Dialog()
+ if dialog.yesno('Grooveshark XBMC', 'Delete this song from the Grooveshark playlist?') == True:
+ userid = self._get_login()
+ if (userid != 0):
+ if groovesharkApi.playlistDeleteSong(playlistid, songpos) == 0:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'Failed to remove ', ' song from Grooveshark playlist.')
+ else:
+ xbmc.executebuiltin("Container.Refresh(" + playlistUrl + "&id="+str(playlistid) + "&name=" + playlistname + ",replace)")
+ else:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to delete a song from a Grooveshark playlist.')
+
+ def addPlaylistSong(self, songid):
+ userid = self._get_login()
+ if (userid != 0):
+ playlists = groovesharkApi.userGetPlaylists()
+ if (len(playlists) > 0):
+ ret = 0
+ playlistSelect = GroovesharkPlaylistSelect(items=playlists)
+ playlistSelect.setFocus(playlistSelect.playlistControl)
+ playlistSelect.doModal()
+ i = playlistSelect.selected
+ del playlistSelect
+ if i > -1:
+ # New playlist
+ if i >= len(playlists):
+ name = self._get_keyboard(default='', heading="Grooveshark playlist name")
+ if name != '':
+ songIds = []
+ songIds.append(songid)
+ if groovesharkApi.playlistCreateUnique(name, songIds) == 0:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'Cannot create Grooveshark playlist ', name)
+ else:
+ xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Grooveshark playlist created, 1000, ' + thumbDef + ')')
+ # Existing playlist
+ else:
+ playlist = playlists[i]
+ playlistid = playlist[1]
+ xbmc.log("Add song " + str(songid) + " to playlist " + str(playlistid))
+ ret = groovesharkApi.playlistAddSong(playlistid, songid, 0)
+ if ret == 0:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'Cannot add to playlist ')
+ else:
+ xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Added song to Grooveshark playlist, 1000, ' + thumbDef + ')')
+ else:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'You have no Grooveshark playlists.')
+ self.categories()
+ else:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to add a song to a Grooveshark playlist.')
+
+ def renamePlaylist(self, playlistid, name):
+ userid = self._get_login()
+ if (userid != 0):
+ newname = self._get_keyboard(default=name, heading="Grooveshark playlist name")
+ if newname == '':
+ return
+ elif groovesharkApi.playlistRename(playlistid, newname) == 0:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'Cannot rename Grooveshark playlist ', name)
+ else:
+ xbmc.executebuiltin("Container.Refresh")
+ else:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark XBMC', 'You must be logged in ', ' to rename a Grooveshark playlist.')