From: stephendenham Date: Fri, 28 Jan 2011 11:10:57 +0000 (+0000) Subject: Playlist stuff. X-Git-Url: https://git.hcoop.net/clinton/xbmc-groove.git/commitdiff_plain/e6f8730bfc96ae4055c0e2c8f49ff61bf8f8981e?hp=2cb26beaf7cd59f89fa311043f9dd04238be48f0 Playlist stuff. git-svn-id: svn://svn.code.sf.net/p/xbmc-groove/code@46 2dec19e3-eb1d-4749-8193-008c8bba0994 --- diff --git a/default.py b/default.py index 5250150..d4c6dfa 100644 --- a/default.py +++ b/default.py @@ -343,13 +343,10 @@ class Groveshark: self._add_albums_directory(albums, artistid) # Show selected playlist - def playlist(self, playlistid, playlistname, version = 2): + def playlist(self, playlistid, playlistname): userid = self._get_login() if (userid != 0): - if version == 1: - songs = self.groovesharkApiv1.playlistGetSongs(playlistid) - else: - songs = groovesharkApi.getPlaylistSongs(playlistid) + songs = groovesharkApi.getPlaylistSongs(playlistid) self._add_songs_directory(songs, trackLabelFormat=NAME_ALBUM_ARTIST_LABEL, playlistid=playlistid, playlistname=playlistname) else: dialog = xbmcgui.Dialog() @@ -512,8 +509,8 @@ class Groveshark: # Remove song from playlist def removePlaylistSong(self, playlistid, playlistname, songpos): - dialog = xbmcgui.Dialog(version = 1) - if dialog.yesno('Grooveshark XBMC', 'Delete this song from the Grooveshark playlist?') == True: + dialog = xbmcgui.Dialog() + if dialog.yesno('Grooveshark XBMC', 'Delete this song from', 'the Grooveshark playlist?') == True: userid = self._get_login(version = 1) if (userid != 0): if self.groovesharkApiv1.playlistDeleteSong(playlistid, songpos) == 0: @@ -522,7 +519,7 @@ class Groveshark: else: # Refresh to remove item from directory xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Removed song from Grooveshark playlist, 1000, ' + thumbDef + ')') - xbmc.executebuiltin("Container.Update(" + playlistUrl + "&id="+str(playlistid) + "&name=" + playlistname + "&version=1)") + xbmc.executebuiltin("Container.Update(" + playlistUrl + "&id="+str(playlistid) + "&name=" + playlistname + ")") else: dialog = xbmcgui.Dialog() dialog.ok('Grooveshark XBMC', 'You must be logged in', 'to delete a song from a Grooveshark playlist.') @@ -835,10 +832,7 @@ elif mode==MODE_ALBUM: grooveshark.album(id) elif mode==MODE_PLAYLIST: - version = 2 - try: version=urllib.unquote_plus(params["version"]) - except: pass - grooveshark.playlist(id, name, version) + grooveshark.playlist(id, name) elif mode==MODE_FAVORITE: grooveshark.favorite(id) diff --git a/resources/lib/GroovesharkAPI.py b/resources/lib/GroovesharkAPI.py index edfab77..a205924 100644 --- a/resources/lib/GroovesharkAPI.py +++ b/resources/lib/GroovesharkAPI.py @@ -277,65 +277,6 @@ class GrooveAPIv1: else: return 0 - def playlistGetSongs(self, playlistId): - items = self.callRemote("playlist.getSongs", {"playlistID": playlistId}) - print items - if 'result' in items: - i = 0 - list = [] - index = '' - l = -1 - try: - if 'songs' in items['result'][0]: - l = len(items['result'][0]['songs']) - index = 'songs[]' - except: pass - try: - if l < 0 and 'songs' in items['result']: - l = len(items['result']['songs']) - index = 'songs' - except: pass - try: - if l < 0 and 'song' in items['result']: - l = 1 - index = 'song' - except: pass - try: - if l < 0: - l = len(items['result']) - except: pass - - while(i < l): - if index == 'songs[]': - s = items['result'][0]['songs'][i] - elif index == 'songs': - s = items['result'][index][i] - elif index == 'song': - s = items['result'][index] - else: - s = items['result'][i] - if 'CoverArtFilename' not in s: - info = self.getSongInfo(s['SongID']) - coverart = info['CoverArtFilename'] - elif s['CoverArtFilename'] != None: - coverart = THUMB_URL+s['CoverArtFilename'].encode('ascii', 'ignore') - else: - coverart = 'None' - list.append([s['SongName'].encode('ascii', 'ignore'),\ - s['SongID'],\ - s['AlbumName'].encode('ascii', 'ignore'),\ - s['AlbumID'],\ - s['ArtistName'].encode('ascii', 'ignore'),\ - s['ArtistID'],\ - coverart]) - i = i + 1 - return list - else: - return [] - - - return list - def playlistDelete(self, playlistId): if self.loggedIn == 1: result = self.callRemote("playlist.delete", {"playlistID": playlistId}) @@ -812,10 +753,11 @@ class GrooveAPI: #groovesharkApi = GrooveAPI() #res = groovesharkApi.pingService() #res = groovesharkApi.login(sys.argv[1], sys.argv[2]) -#songIDs = ['23404546','23401810','23401157'] -#res = groovesharkApi.createPlaylist("Test") -#res = groovesharkApi.setPlaylistSongs(res, songIDs) -#res = groovesharkApi.getPlaylistSongs(42251632) +#songIDs = "[23404546,23401810,23401157]" +#res = groovesharkApi.createPlaylist("Test", songIDs) +#res = groovesharkApi.setPlaylistSongs('42873478', songIDs) +#pprint.pprint(res) +#res = groovesharkApi.getPlaylistSongs('42873478') #res = groovesharkApi.getSongSearchResults('jimmy jazz', 3) #res = groovesharkApi.getPopularSongsToday(3) #res = groovesharkApi.getSongURLFromSongID('26579347')