New API.
authorstephendenham <stephendenham@2dec19e3-eb1d-4749-8193-008c8bba0994>
Thu, 13 Jan 2011 01:17:08 +0000 (01:17 +0000)
committerstephendenham <stephendenham@2dec19e3-eb1d-4749-8193-008c8bba0994>
Thu, 13 Jan 2011 01:17:08 +0000 (01:17 +0000)
git-svn-id: svn://svn.code.sf.net/p/xbmc-groove/code@30 2dec19e3-eb1d-4749-8193-008c8bba0994

resources/lib/GroovesharkAPI.py

index 2eadd13..85a1ad1 100644 (file)
@@ -328,6 +328,13 @@ class GrooveAPI:
                else:
                        return []
                
+       # Add song to user favorites
+       def addUserFavoriteSong(self, songID):
+               if (self.userID == 0):
+                       return False;
+               result = self._callRemote('addUserFavoriteSong', {'sessionID' : self.sessionID, 'songID' : songID})
+               return result['result']['success']
+               
        # Get the url to link to a song on Grooveshark
        def getSongURLFromSongID(self, songID):
                song = GrooveSong(self.cacheDir)
@@ -359,7 +366,7 @@ class GrooveAPI:
        # Creates a playlist with songs
        def createPlaylist(self, name, songIDs):
                result = self._callRemote('createPlaylist', {'name' : name, 'songIDs' : songIDs, 'sessionID' : self.sessionID})
-               if 'result' in result and result['result']['success'] == 'true'
+               if 'result' in result and result['result']['success'] == True
                        return result['result']['PlaylistID']
                elif 'errors' in result:
                        return 0
@@ -367,7 +374,7 @@ class GrooveAPI:
        # Sets the songs for a playlist
        def setPlaylistSongs(self, playlistID, songIDs):
                result = self._callRemote('setPlaylistSongs', {'playlistID' : playlistID, 'songIDs' : songIDs, 'sessionID' : self.sessionID})
-               if 'result' in result and result['result']['success'] == 'true'
+               if 'result' in result and result['result']['success'] == True
                        return True;
                else:
                        return False;
@@ -474,21 +481,22 @@ class GrooveAPI:
 
 
 # Test
-
+import sys
 res = []
 groovesharkApi = GrooveAPI('/tmp')
-#res = groovesharkApi.login('stephendenham', '*******')
+res = groovesharkApi.login(sys.argv[1], sys.argv[2])
 #res = groovesharkApi.getSongSearchResults('jimmy jazz', 3)
 #res = groovesharkApi.getPopularSongsToday()
 #res = groovesharkApi.getSongURLFromSongID('27425375')
 #res = groovesharkApi.getAlbumSearchResults('london calling', 3)
 #res = groovesharkApi.getArtistSearchResults('the clash', 3)
 #res = groovesharkApi.getUserFavoriteSongs()
-#res = groovesharkApi.getUserPlaylists()
-res = groovesharkApi.getSongInfo('27425375')
+res = groovesharkApi.getUserPlaylists()
+#res = groovesharkApi.getSongInfo('27425375')
 #res = groovesharkApi.getPlaylistSongs(40902662)
+#res = groovesharkApi.addUserFavoriteSong('27425375')
 
-#pprint.pprint(res)
+pprint.pprint(res)