Permalink
Browse files

added listplaylists, remove playlist

  • Loading branch information...
1 parent 2252eab commit c13cb66ac286633820e187d2bf3df316b72502e3 @wendlers committed Oct 17, 2012
Showing with 50 additions and 1 deletion.
  1. +11 −0 src/pyscmpd/gstplayer.py
  2. +20 −0 src/pyscmpd/respersist.py
  3. +19 −1 src/pyscmpd/scmpd.py
View
@@ -379,3 +379,14 @@ def listPlaylists(self):
logging.warn("Unable to retrive playlists: %s" % `e`)
return plFiles
+
+ def removePlaylist(self, plName):
+
+ p = persist.ResourceFilePersistence(PLAYLIST_DIR)
+ p.remove(plName)
+
+ def renamePlaylist(self, plNameSrc, plNameDst):
+
+ p = persist.ResourceFilePersistence(PLAYLIST_DIR)
+ p.rename(plNameSrc, plNameDst)
+
View
@@ -21,6 +21,7 @@
This file is part of the pyscmpd project.
'''
+import os
import logging
import pickle
@@ -68,3 +69,22 @@ def retrive(self, key):
return obj
+ def remove(self, key):
+
+ try:
+
+ os.remove("%s/%s" % (self.baseDir, key))
+
+ except Exception as e:
+ logging.warn("Unable to remove playlist: %s" % `e`)
+
+ def rename(self, srcKey, dstKey):
+
+ try:
+
+ os.rename("%s/%s" % (self.baseDir, srcKey), "%s/%s" % (self.baseDir, dstKey))
+
+ except Exception as e:
+ logging.warn("Unable to rename playlist: %s" % `e`)
+
+
View
@@ -64,6 +64,8 @@ def __init__(self, favoriteUsers, favoriteGroups, favoriteFavorites, serverPort
self.requestHandler.RegisterCommand(Save)
self.requestHandler.RegisterCommand(Load)
self.requestHandler.RegisterCommand(ListPlaylistInfo)
+ self.requestHandler.RegisterCommand(ListPlaylists)
+ self.requestHandler.RegisterCommand(Rm)
self.requestHandler.Playlist = MpdPlaylist
@@ -175,7 +177,7 @@ def items(self):
r = ScMpdServerDaemon.scroot.getChildByPath(self.directory)
if r == None or not r.getType() == 1:
- logging.warn("[%s] is not a directory" % r.getName())
+ logging.warn("[%s] is not a directory" % self.directory)
return i
# process 'directory'
@@ -231,6 +233,22 @@ def songs(self):
return pl
+class ListPlaylists(mpdserver.ListPlaylists):
+
+ def handle_playlists(self):
+ pass
+
+ def items(self):
+ return [("playlist",pl) for pl in ScMpdServerDaemon.player.listPlaylists()]
+
+class Rm(mpdserver.Rm):
+
+ def handle_args(self, playlistName):
+
+ logging.info("Deleting playlist: %s" % playlistName)
+
+ ScMpdServerDaemon.player.removePlaylist(playlistName)
+
class Add(mpdserver.Add):
def handle_args(self, song):

0 comments on commit c13cb66

Please sign in to comment.