changeset 6:50745af6a63b

Print song lengths in something better than number of milliseconds, added ":lists" command to list all the playlists
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Fri, 18 Aug 2006 20:32:00 -0400
parents 187453f856a7
children f87b969fa973
files vixm/ui.py vixm/util.py
diffstat 2 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/vixm/ui.py	Fri Aug 18 20:26:11 2006 -0400
+++ b/vixm/ui.py	Fri Aug 18 20:32:00 2006 -0400
@@ -4,7 +4,7 @@
 from threading import Thread
 import xmms
 
-import playlist, song
+import playlist, song, util
 
 def run():
 	""" this is where we start execution """
@@ -41,7 +41,8 @@
 
 	def __enqueue(self, id):
 		s = self.lists[playlist.LIST_DEFAULT][id]
-		print "Enqueuing song: %d. %s (%d)" % (id, s["title"], s["time"])
+		print "Enqueuing song: %d. %s (%s)" % (id, s["title"],
+				util.strtime(s["time"]))
 		self.lists[playlist.LIST_PRIO].enqueue(s)
 
 	def __cmd(self, txt):
@@ -65,8 +66,12 @@
 				listid = playlist.LIST_PRIO
 
 			for s in self.lists[listid]:
-				print "%d. %s (%d)" % (i, s["title"], s["time"])
+				print "%d. %s (%s)" % (i, s["title"],
+						util.strtime(s["time"]))
 				i += 1
+		elif cmd == "lists":
+			print "#0 LIST_PRIO"
+			print "#1 LIST_DEFAULT"
 		else:
 			print "Invalid command \"%s\"" % (cmd,)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vixm/util.py	Fri Aug 18 20:32:00 2006 -0400
@@ -0,0 +1,14 @@
+def strtime(t):
+	ms = t % 1000
+	t /= 1000
+
+	s = t % 60
+	t /= 60
+
+	ret = "%02d.%03d" % (s, ms)
+
+	if t != 0:
+		m = t
+		ret = "%d:%s" % (m, ret)
+	
+	return ret