libDir = xbmc.translatePath(os.path.join(resDir, 'lib'))
imgDir = xbmc.translatePath(os.path.join(resDir, 'img'))
thumbDir = os.path.join('special://masterprofile/addon_data/', os.path.join(os.path.basename(os.getcwd()), 'thumb'))
+playlistUrl = 'plugin://plugin.audio.groove/?mode=6'
+thumbDef = os.path.join(os.path.basename(os.getcwd()), 'default.tbn')
sys.path.append (libDir)
from GrooveAPI import *
if (userid != 0):
xbmc.log("Favorite song: " + str(songid))
groovesharkApi.favoriteSong(songID = songid)
+ xbmc.executebuiltin('XBMC.Notification(Grooveshark, Added to favorites, 1000, ' + thumbDef + ')')
else:
dialog = xbmcgui.Dialog()
dialog.ok('Grooveshark', 'You must be logged in', 'to add favorites.')
if (userid != 0):
xbmc.log("Unfavorite song: " + str(songid))
groovesharkApi.unfavoriteSong(songID = songid)
+ xbmc.executebuiltin('XBMC.Notification(Grooveshark, Removed from favorites, 1000, ' + thumbDef + ')')
else:
dialog = xbmcgui.Dialog()
dialog.ok('Grooveshark', 'You must be logged in', 'to remove favorites.')
xbmc.log("Frown song: " + str(songid))
if groovesharkApi.radioFrown(songId = songid) != True:
xbmc.log("Unable to frown song " + str(songid))
+ else:
+ xbmc.executebuiltin('XBMC.Notification(Grooveshark, Frowned, 1000, ' + thumbDef + ')')
else:
dialog = xbmcgui.Dialog()
dialog.ok('Grooveshark', 'You must be logged in', 'to frown a song.')
def makePlaylist(self, albumid, name):
userid = self._get_login()
if (userid != 0):
- name_re = re.compile(r'[- ]')
- nameTokens = name_re.split("- ")
- name = self._get_keyboard(default=nameTokens[1], heading="Playlist name")
- album = groovesharkApi.albumGetSongs(albumid, self.songsearchlimit)
- songids = []
- for song in album:
- songids.append(song[1])
- id = groovesharkApi.playlistCreateUnique(name, songids)
- if id == 0:
- dialog = xbmcgui.Dialog()
- dialog.ok('Grooveshark', 'Cannot create playlist ', name)
+ re.split(' - ',name,1)
+ nameTokens = re.split(' - ',name,1)
+ name = self._get_keyboard(default=nameTokens[0], heading="Playlist name")
+ if name != '':
+ album = groovesharkApi.albumGetSongs(albumid, self.songsearchlimit)
+ songids = []
+ for song in album:
+ songids.append(song[1])
+ id = groovesharkApi.playlistCreateUnique(name, songids)
+ if id == 0:
+ dialog = xbmcgui.Dialog()
+ dialog.ok('Grooveshark', 'Cannot create playlist ', name)
+ else:
+ xbmc.executebuiltin('XBMC.Notification(Grooveshark, Playlist created, 1000, ' + thumbDef + ')')
else:
dialog = xbmcgui.Dialog()
dialog.ok('Grooveshark', 'You must be logged in ', ' to create a playlist.')
userid = self._get_login()
if (userid != 0):
groovesharkApi.playlistDelete(playlistid)
- xbmc.executebuiltin("Container.Refresh")
+ xbmc.executebuiltin("Container.Update(" + playlistUrl + ",replace)")
else:
dialog = xbmcgui.Dialog()
dialog.ok('Grooveshark', 'You must be logged in ', ' to delete a playlist.')
userid = self._get_login()
if (userid != 0):
newname = self._get_keyboard(default=name, heading="Playlist name")
- if groovesharkApi.playlistRename(playlistid, newname) == 0:
+ if newname == '':
+ return
+ elif groovesharkApi.playlistRename(playlistid, newname) == 0:
dialog = xbmcgui.Dialog()
dialog.ok('Grooveshark', 'Cannot rename playlist ', name)
else:
return item
def _get_keyboard(self, default="", heading="", hidden=False):
- kb = xbmc.Keyboard(default, heading, hidden)
- kb.doModal()
- if (kb.isConfirmed()):
- return unicode(kb.getText(), "utf-8")
- return ''
+ kb = xbmc.Keyboard(default, heading, hidden)
+ kb.doModal()
+ if (kb.isConfirmed()):
+ return unicode(kb.getText(), "utf-8")
+ return ''
def _get_login(self):
if (self.username == "" or self.password == ""):