Remove unnecessary print statement.
[clinton/xbmc-groove.git] / resources / lib / GrooveAPI.py
index 63ab3db..d83989e 100644 (file)
@@ -34,7 +34,7 @@ class GrooveAPI:
                self.radioRecentArtists = []
                self.radioEnabled = False
 
-               self.dataDir = 'plugin_data/music/'
+               self.dataDir = 'addon_data'
                self.confDir = xbmc.translatePath(os.path.join('special://masterprofile/' + self.dataDir, os.path.basename(os.getcwd())))
                self.sessionID = self.getSavedSession()
                self.debug('Saved sessionID: ' + self.sessionID)
@@ -284,6 +284,16 @@ class GrooveAPI:
                                return 0
                else:
                        return 0
+
+       def playlistCreateUnique(self, name, songIds):
+               if self.loggedIn == 1:
+                       result = self.callRemote("playlist.createunique", {"name": name, "songIDs": songIds})
+                       if 'result' in result:
+                               return result['result']['playlistID']
+                       else:
+                               return 0
+               else:
+                       return 0
                        
        def playlistGetSongs(self, playlistId, limit=25):
                result = self.callRemote("playlist.getSongs", {"playlistID": playlistId})
@@ -317,6 +327,16 @@ class GrooveAPI:
                                return 1
                else:
                        return 0
+               
+       def playlistDeleteSong(self, playlistId, position):
+               if self.loggedIn == 1:
+                       result = self.callRemote("playlist.removeSong", {"playlistID": playlistId, "position": position})
+                       if 'fault' in result:
+                               return 0
+                       else:
+                               return 1
+               else:
+                       return 0
                        
        def playlistReplace(self, playlistId, songIds):
                if self.loggedIn == 1:
@@ -334,6 +354,7 @@ class GrooveAPI:
                        return False
                result = self.callRemote("autoplay.startWithArtistIDs", {"artistIDs": radio['seedArtists']})
                if 'fault' in result:
+                       print "Cannot autoplay artists"
                        self.radioEnabled = False
                else:
                        self.radioEnabled = True
@@ -345,6 +366,7 @@ class GrooveAPI:
                        return False
                result = self.callRemote("autoplay.start", {"songIDs": radio['seedSongs']})
                if 'fault' in result:
+                       print "Cannot autoplay songs"
                        self.radioEnabled = False
                else:
                        self.radioEnabled = True
@@ -382,8 +404,10 @@ class GrooveAPI:
                                radio['seedArtists'].remove(artistId)
                        except: pass
                        radio['seedArtists'].append(artistId)
+                       print "Saved radio"
                        return self.saveRadio(radio = radio)
                else:
+                       print "Failed to get radio"
                        return False
 
        def radioSong(self, songId = None):
@@ -393,8 +417,10 @@ class GrooveAPI:
                                radio['seedSongs'].remove(songId)
                        except: pass
                        radio['seedSongs'].append(songId)
+                       print "Saved radio"
                        return self.saveRadio(radio = radio)
                else:
+                       print "Failed to get radio"
                        return False
 
        def radioTurnedOn(self):
@@ -406,8 +432,8 @@ class GrooveAPI:
                        f = open(path, 'rb')
                        radio = pickle.load(f)
                        f.close()
-                       print radio
                except:
+                       print "Failed to open " + path
                        radio = {}
                        radio['seedSongs'] = []
                        radio['seedArtists'] = []
@@ -619,7 +645,7 @@ class GrooveAPI:
                                                s['artistID'],\
                                                s['albumName'].encode('ascii', 'ignore'),\
                                                s['albumID'],\
-                                               s['image']['tiny'].encode('ascii', 'ignore')])
+                                               s['image']['medium'].encode('ascii', 'ignore')])
                                        except:
                                                print 'GrooveShark: Could not parse album number: ' + str(i)
                                                traceback.print_exc()