ocarina/html/controls.py
Bryan Schumaker 9dadf082b4 Added uptime to web controls
Asking for the uptime control will return how long ocarina has been
running.
2010-12-27 12:40:40 -05:00

38 lines
776 B
Python

# Bryan Schumaker (11/18/2010)
import libsaria.audio
import libsaria.sources
import ocarina
controls = libsaria.controls
play = controls.play
pause = controls.pause
stop = controls.stop
next = controls.next
attrs = libsaria.sources.get_attrs
def to_html(wfile, args):
action = args["a"]
ret = False
if action == "play":
ret = play()
elif action == "pause":
ret = pause()
elif action == "stop":
ret = stop()
elif action == "next":
ret = next()
elif action == "version":
ret = ocarina.__vers__
elif action == "uptime":
ret = ocarina.now() - ocarina.__start__
elif action == "title":
ret = attrs("title")
elif action == "album":
ret = "from %s" % attrs("album")
elif action == "artist":
ret = "by %s" % attrs("artist")
wfile.write(str(ret))