Mercurial > vixm
view vixm/control.py @ 47:1ae315a49009 pure
Removed references to XMMS
author | Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 06 Nov 2006 05:25:05 -0500 |
parents | f56aeafb05b1 |
children |
line wrap: on
line source
# control.py - user interface command functions # # Copyright (C) 2006 Josef "Jeff" Sipek <jeffpc@josefsipek.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import os import playlist, util def cmd_quit(ui, start, stop, args): """q[!] - quit Quits the program. The optional '!' forces the termination regardless of any unsaved work""" ui.play.shutdown = True def cmd_number(ui, start, stop, args): """[range]n [playlistid] - print the addressed lines The lines are printed along with the line/song numbers. See also: 'l'""" do_list(ui, start, stop, True, args) def cmd_list(ui, start, stop, args): """[range]l [playlistid] - print the addressed lines See also: 'n'""" do_list(ui, start, stop, False, args) def cmd_enqueue(ui, start, stop, args): """a [songid] - appends/enqueues a song A song at songid position in LIST_DEFAULT is appended to the end of the LIST_PRIO playlist. Duplicates are _NOT_ eliminated.""" try: id = int(args[0])-1 if (id < 0) or \ (id >= len(ui.lists[playlist.LIST_DEFAULT])): raise ValueError except ValueError: print "Invalid song id" return s = ui.lists[playlist.LIST_DEFAULT][id] print "Enqueuing song: %s (%s)" % (str(s), util.strtime(s["time"])) ui.lists[playlist.LIST_PRIO].enqueue(s) def cmd_dequeue(ui, start, stop, args): """[range]d - delete/dequeue addressed songs Songs in range are removed from the LIST_PRIO playlist. They still remain in the LIST_DEFAULT at their original locations.""" l = ui.lists[playlist.LIST_PRIO] max = len(l) if not max: return start = util.fixupint(start, max) stop = util.fixupint(stop, max) for i in range(start-1, stop): s = l[start-1] print "Dequeuing song: %s (%s)" % (str(s), util.strtime(s["time"])) l.dequeue(s) def cmd_help(ui, start, stop, args): """h - this help screen""" keys = args[0].keys() keys.sort() for c in keys: text = args[0][c][0].__doc__.split("\n")[0:2] text = "\n".join(text) print " %s" % (text,) def do_list(ui, start, stop, number, args): # get the list id from the argument or default to # LIST_PRIO try: if args[1]: listid = int(args[1]) else: listid = playlist.LIST_PRIO if listid < 0 or listid >= len(ui.lists): raise ValueError except ValueError, e: print "Invalid list number" raise e max = len(ui.lists[listid]) if not max: return start = util.fixupint(start, max) stop = util.fixupint(stop, max) # starting number should be less than the ending # number, as well as positive; ending number should # be less than or equal to the size of the playlist if start > stop or \ start < 1 or \ stop > max: raise ValueError i = 1 pfx = "" for s in ui.lists[listid]: if i < start or i > stop: i += 1 continue if number: pfx = "%d. " % (i,) print "%s%s (%s)" % (pfx, str(s), util.strtime(s["time"])) i += 1 def cmd_play(ui, start, stop, args): """x - Direct control: play""" print "Play not implemented" def cmd_pause(ui, start, stop, args): """c - Direct control: pause""" print "Pause not implemented" def cmd_stop(ui, start, stop, args): """v - Direct control: stop""" print "Stop not implemented" def cmd_prev(ui, start, stop, args): """z - Direct control: previous song""" print "Previous song not implemented" def cmd_next(ui, start, stop, args): """b - Direct control: next song""" ui.play.play_next(ui.lists) def cmd_shell(ui, start, stop, args): """![command] - Execute a shell command""" if args[0]: os.system(args[0]) print "!" def cmd_location(ui, start, stop, args): """= - Display information about currently playing song""" current = ui.play.current if not current: return current_time = 0 pos = ui.lists[playlist.LIST_DEFAULT].index(current) print "%d. %s (%s/%s)" % (pos+1, str(current), util.strtime(current_time), util.strtime(current["time"]))