def retrivePlaylist(self, plName = CURR_PLAYLIST_KEY, makeCurrent = True): logging.info("Retriving playlist with key: %s" % plName) self.stop() self.currentSongNumber = -1 self.currentSongId = -1 p = persist.ResourceFilePersistence(PLAYLIST_DIR) c = p.retrive(plName) if not c == None: for t in c: k = t.getMeta("file") if not self.trackCache.has_key(k): logging.debug("Adding to track cache: %s" % k) self.trackCache[k] = t else: logging.debug("already in cache ..") if makeCurrent: self.children = c self.playlistVersion = self.playlistVersion + 1 return c
def storePlaylist(self, plName = CURR_PLAYLIST_KEY, playlist = None): logging.info("Storing playlist with key: %s" % plName) p = persist.ResourceFilePersistence(PLAYLIST_DIR) if playlist == None: p.store(plName, self.children) else: p.store(plName, playlist)
def playlistDelete(self, plName, songPos): p = persist.ResourceFilePersistence(PLAYLIST_DIR) c = p.retrive(plName) if c == None: loggin.warn("Unable to retrive playlist: %s" % plName) return try: s = c[songPos] c.remove(s) p.store(plName, c) except: logging.warn("Unable to delete song at position %i in playlist: %s" % (songPos, plName))
def playlistMove(self, plName, songId, songPos): p = persist.ResourceFilePersistence(PLAYLIST_DIR) c = p.retrive(plName) if c == None: loggin.warn("Unable to retrive playlist: %s" % plName) return try: s = c[songId] c.remove(s) c.insert(songPos, s) p.store(plName, c) except: logging.warn("Unable to move song with ID %i to position %i in playlist: %s" % (songId, songPos, plName))
def renamePlaylist(self, plNameSrc, plNameDst): p = persist.ResourceFilePersistence(PLAYLIST_DIR) p.rename(plNameSrc, plNameDst)
def removePlaylist(self, plName): p = persist.ResourceFilePersistence(PLAYLIST_DIR) p.remove(plName)