summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2011-01-19 17:33:46 +0100
committerLaurent Bachelier <laurent@bachelier.name>2011-01-19 17:33:46 +0100
commit84b79b2ca530b37deda3e8f8aa7058f5687b8671 (patch)
tree453711808aa6baf96813f94c846f9c94c713e64b
parentCache and autoupdate final dirs (diff)
downloadmpdat-84b79b2ca530b37deda3e8f8aa7058f5687b8671.tar.xz
Add get_playlist_time()
-rw-r--r--mpdrast/client.py5
-rw-r--r--mpdrast/process.py3
2 files changed, 8 insertions, 0 deletions
diff --git a/mpdrast/client.py b/mpdrast/client.py
index 974350c..a0f2fd2 100644
--- a/mpdrast/client.py
+++ b/mpdrast/client.py
@@ -88,6 +88,11 @@ class MPDrastClient(mpd.MPDClient):
return int(self.status()["playlistlength"]) == 0
+ def get_playlist_time(self):
+ pl = (process.process_song(item) for item in self.playlistinfo())
+ return sum([song["time"] for song in pl])
+
+
def _find_changing_pos(self, number, type):
pl = (process.process_song(item) for item in self.playlistinfo())
value = None
diff --git a/mpdrast/process.py b/mpdrast/process.py
index efe240d..da5d13b 100644
--- a/mpdrast/process.py
+++ b/mpdrast/process.py
@@ -29,4 +29,7 @@ def process_song(item):
if item.has_key("pos"):
item["pos"] = int(item["pos"])
+ if item.has_key("time"):
+ item["time"] = int(item["time"])
+
return item