Permalink
Browse files

reworked favorites

  • Loading branch information...
wendlers committed Oct 9, 2012
1 parent 162398e commit 53b0de8ab332e9b6eab860204fcadd68b71b6df1
Showing with 99 additions and 174 deletions.
  1. +17 −10 README.md
  2. +5 −6 etc/pyscmpd.conf
  3. +18 −10 src/pyscmpd/daemon.py
  4. +6 −6 src/pyscmpd/gstplayer.py
  5. +3 −3 src/pyscmpd/pyscmpdctrl.py
  6. +1 −1 src/pyscmpd/resource.py
  7. +2 −2 src/pyscmpd/scmpd.py
  8. +47 −136 src/pyscmpd/scprovider.py
View
@@ -215,9 +215,11 @@ __Favorite Users__
To modify the list of your favorite users to browse, edit the *[favorite-users]* section
in "~/.pyscmpd/pyscmp.conf". The format used for favorite users is:
- category: user1, user2, ...
+ category1: user1, user2, ...
+ category2: user1, user2, ...
+ ...
-*category* is then shown in the browser as subfolder folder of *favorite-users* folder, containing all
+*categoryN* is then shown in the browser as subfolder folder of *users* folder, containing all
the users specified. *userN* is the user name of a soundcloud user as shown in the URL. E.g.
"griz" for [GRiZ] (http://soundcloud.com/griz).
@@ -226,20 +228,23 @@ __Favorite Groups__
To define the favaorite groups shown in the browser, add them under the *[favorite-groups]* section
in "~/.pyscmpd/pyscmp.conf". The format used for favorite users is:
- groups: group1, group2, ...
+ categroy1: group1, group2, ...
+ categroy2: group1, group2, ...
+ ...
-*groupN* is shon in the broser as subfolder of the *favorite-groups* folder. *groupN* is the group name as shown
+*categoryN* is shown in the broser as subfolder of the *groups* folder. *groupN* is the group name as shown
in the URL when browsing a group. E.g. "deep-house-4".
__Favorite Favorites__
-To define a set of users whos favorite tracks are listed under the *favorite-favorites* folder, add them to the
+To define a set of users whos favorite tracks are listed under the *favorites* folder, add them to the
*[favorite-favorites]* section in "~/.pyscmpd/pyscmp.conf". The format used for favorite favorites is:
- favorites: <user1>, <user2>, ...
+ category1: user1, user2, ...
+ category2: user1, user2, ...
+ ...
-For each *userN*, a subfolder of *favorite-favorites* is shown in the browser. When *userN* is opened, all the favorite
-tracks of that user are listed.
+For each *categoryN*, a subfolder of *favorites* is shown in the browser. When *userN* is opened, all the favorite tracks of that user are listed.
__Complete Example__
@@ -252,10 +257,12 @@ The following shows a complete sample for the two mentioned section as seen in *
tech-house: beatkind, atmosphererecords
[favorite-groups]
- groups: deep-house-4, minimal-tech-house, swing-fever-electroswing-group, ghettoswing-and-swingstep
+ house: deep-house-4, minimal-tech-house,
+ swing: swing-fever-electroswing-group, ghettoswing-and-swingstep
[favorite-favorites]
- favorites: kaltpost
+ me: kaltpost
+ friends: somefrinduser
__Note:__ Each time "~/.pyscmpd/pyscmp.conf" is modified, the daemon needs to be restarted by:
View
@@ -28,27 +28,26 @@ file=/tmp/pyscmpd.log
##
[favorite-users]
-electroswing : shemian
-gethoswing : maddecent, barelylegit
+electroswing : shemian, maddecent, barelylegit
electrosoul : griz
deephouse : freudeamtanzen, adriatique
worldtrance : gogmusic
##
# Favorite groups
#
-# format: groups: <group1>, <group2>, ...
+# format: <category>: <user1>, <user2>, ...
##
[favorite-groups]
-groups: deep-house-4, minimal-tech-house
+house: deep-house-4, minimal-tech-house
##
# Favorite favorites
#
-# format: favorites: <user1>, <user2>, ...
+# format: <category>: <user1>, <user2>, ...
##
[favorite-favorites]
-favorites: kaltpost
+me: kaltpost
View
@@ -237,21 +237,29 @@ def readConfig(self, cfgFile, foreground=False):
self.favoriteUsers.append({"name" : category.strip(), "users" : users})
- if parser.has_option("favorite-groups", "groups"):
+ if parser.has_section("favorite-groups"):
- groupsRaw = parser.get("favorite-groups", "groups").split(",")
- groups = []
+ for category, values in parser.items("favorite-groups"):
- for group in groupsRaw:
- self.favoriteGroups.append(group.strip())
+ groupsRaw = values.split(",")
+ groups = []
- if parser.has_option("favorite-favorites", "favorites"):
+ for group in groupsRaw:
+ groups.append(group.strip())
+
+ self.favoriteGroups.append({"name" : category.strip(), "groups" : groups})
+
+ if parser.has_section("favorite-favorites"):
- favoritesRaw = parser.get("favorite-favorites", "favorites").split(",")
- favorites = []
+ for category, values in parser.items("favorite-favorites"):
+
+ favoritesRaw = values.split(",")
+ favorites = []
+
+ for favorite in favoritesRaw:
+ favorites.append(favorite.strip())
- for favorite in favoritesRaw:
- self.favoriteFavorites.append(favorite.strip())
+ self.favoriteFavorites.append({"name" : category.strip(), "users" : favorites})
except Exception as e:
View
@@ -81,7 +81,7 @@ def play(self, filePos=0):
f = self.children[filePos]
- logging.info("Playing file at playlist pos %d: %s" % (filePos, f.__str__()))
+ logging.info("Playing file at playlist pos %d: %s" % (filePos, f.getName()))
self.player.set_state(gst.STATE_NULL)
self.player.set_property('uri', f.getStreamUri())
@@ -171,7 +171,7 @@ def getResourcePosInPlaylist(self, res, playlist):
def move(self, filePosFrom, filePosTo):
- logging.info("move posFrom %d, posTo %d" % (filePosFrom, filePosTo))
+ logging.debug("Move posFrom %d, posTo %d" % (filePosFrom, filePosTo))
if filePosFrom > len(self.children):
logging.error("Invalid filePosFrom (%d) given. Only %d files in current playlist." %
@@ -188,7 +188,7 @@ def move(self, filePosFrom, filePosTo):
c = children[filePosFrom]
- logging.info("File on posFrom: %s" % c.__str__())
+ logging.debug("File on posFrom: %s" % c.__str__())
children.remove(c)
children.insert(filePosTo, c)
@@ -206,15 +206,15 @@ def moveId(self, fileIdFrom, filePosTo):
if fileIdFrom <= resource.ID_OFFSET:
- logging.info("using moveId/move mixup workaround")
+ logging.debug("Using moveId/move mixup workaround")
# I think client is doing wrong and mixes up moveId with move
# (ncmpcpp does this). Anyway, trying to workaorund this ...
self.move(fileIdFrom, filePosTo)
else:
- logging.info("moveId idFrom %d, posTo %d" % (fileIdFrom, filePosTo))
+ logging.debug("moveId idFrom %d, posTo %d" % (fileIdFrom, filePosTo))
if filePosTo > len(self.children):
logging.error("Invalid filePosTo (%d) given. Only %d files in current playlist." %
@@ -340,7 +340,7 @@ def listPlaylists(self):
try:
for (root, dirs, files) in os.walk(PLAYLIST_DIR):
- logging.info("found playlist files: %s" % files)
+ logging.debug("Found playlist files: %s" % files)
for f in files:
plFiles.append(f)
@@ -51,12 +51,12 @@ def prepare():
f.write("level=info\n")
f.write("file=%s\n" % DEF_LOG_FILE)
f.write("\n[favorite-users]\n")
- f.write("gethoswing : maddecent, barelylegit\n")
+ f.write("electroswing : maddecent, barelylegit\n")
f.write("electrosoul: griz\n")
f.write("\n[favorite-groups]\n")
- f.write("groups: deep-house-4, minimal-tech-house\n")
+ f.write("house: deep-house-4, minimal-tech-house\n")
f.write("\n[favorite-favorites]\n")
- f.write("favorites: kaltpost\n")
+ f.write("me: kaltpost\n")
f.close()
pyscmpd = None
View
@@ -120,7 +120,7 @@ def getChildByPath(self, path):
while True:
(l, s, r) = p.partition("/")
- logging.info("Consuming path [%s]/[%s]" % (l, r))
+ logging.debug("Consuming path [%s]/[%s]" % (l, r))
if l == "" or c == None or not c.getType() == Resource.TYPE_DIRECTORY:
return None
View
@@ -210,7 +210,7 @@ def songs(self):
l = len(p)
for t in p:
- logging.info("Track: %s" % t.__str__())
+ logging.debug("Track: %s" % t.__str__())
s = mpdserver.MpdPlaylistSong(
playlistPosition = i,
artist = t.getMeta("Artist").encode('ASCII', 'ignore'),
@@ -260,7 +260,7 @@ def handle_args(self, song):
self.uniqueId = t.getId()
- logging.info("Successfully added song: %s" % t.__str__())
+ logging.debug("Successfully added song: %s" % t.__str__())
def items(self):
return [("id", self.uniqueId)]
Oops, something went wrong.

0 comments on commit 53b0de8

Please sign in to comment.