path: root/
diff options
authorLaurent Bachelier <>2010-08-23 22:45:10 +0200
committerLaurent Bachelier <>2010-08-23 22:48:04 +0200
commit415630d657067695d460b19eba1509bdd3bf610a (patch)
tree04e1ee4eba99368a3c5e4dd5430bb254e0e449c4 /
parentSome method documentation (diff)
Cache and autoupdate final dirs
When and only when the MPD database is updated, the final dirs are computed again, on demand. The client code has been enhanced and simplified. It's not perfect yet (it reads the file each time the function is called, we could have an in-memory cache too).
Diffstat (limited to '')
1 files changed, 7 insertions, 3 deletions
diff --git a/ b/
index 404af27..d9bde2b 100755
--- a/
+++ b/
@@ -12,10 +12,14 @@ m.connect_from_env(mpd_host, mpd_port)
# get all "final" directories
+nb_dirs = len(m.get_final_dirs())
+print "We have found %s albums." % nb_dirs
# if the playlist is empty, add one random album
-if m.is_playlist_hungry(1):
- m.add(m.get_random_dir())
+while m.is_playlist_hungry(100) and nb_dirs:
+ rdir = m.get_random_dir()
+ m.add(rdir)
+ print "Added %s" % rdir
print m.status()
+print m.stats()