Playlist stuff.
authorstephendenham <stephendenham@2dec19e3-eb1d-4749-8193-008c8bba0994>
Fri, 28 Jan 2011 11:10:57 +0000 (11:10 +0000)
committerstephendenham <stephendenham@2dec19e3-eb1d-4749-8193-008c8bba0994>
Fri, 28 Jan 2011 11:10:57 +0000 (11:10 +0000)
git-svn-id: svn://svn.code.sf.net/p/xbmc-groove/code@46 2dec19e3-eb1d-4749-8193-008c8bba0994

default.py
resources/lib/GroovesharkAPI.py

index 5250150..d4c6dfa 100644 (file)
@@ -343,13 +343,10 @@ class Groveshark:
         self._add_albums_directory(albums, artistid)
     
     # Show selected playlist
         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):
         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()
             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):
 
     # 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:
             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 + ')')
                 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.')
             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:
     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)
     
 elif mode==MODE_FAVORITE:
     grooveshark.favorite(id)
index edfab77..a205924 100644 (file)
@@ -277,65 +277,6 @@ class GrooveAPIv1:
                else:
                        return 0
                        
                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})
        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])
 #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')
 #res = groovesharkApi.getSongSearchResults('jimmy jazz', 3)
 #res = groovesharkApi.getPopularSongsToday(3)
 #res = groovesharkApi.getSongURLFromSongID('26579347')