/var/lib/liguidsoap/queue.py is in liguidsoap 1.1.1-7.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | #!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import gobject
import socket
import re
import urllib
from client import LiqClient
from widgets import View
class LiqQueue(gtk.VPaned):
def __init__(self,host='localhost',port=1234,op='request'):
gtk.VPaned.__init__(self)
self.show()
# Connect to liquidsoap
self.op = op
self.tel = LiqClient(host,port)
# Fast metadata view: short metadata, right click to see more (TODO)
self.list = View([['rid' , 40],
['2nd_queue_pos', 80],
['skip' , False],
['artist' ,'120'],
['title' ,'120'],
# Right-align URI because the end is more informative
# than the beginning
['initial_uri','250', {'xalign':1.0}]],
self.queue())
self.list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
[('text/uri-list',0,0)],
gtk.gdk.ACTION_COPY)
self.list.connect("drag_data_received",self.drag)
self.list.connect("row_activated",self.row_activated)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
scroll.add(self.list)
# The list is ready, pack it to the top region
# together with a help label
box = gtk.VBox()
lbl = gtk.Label()
lbl.set_markup("\
<b>Enqueue</b> files by drag-n-dropping from your file manager or \
using the file chooser below.\n\
<b>Remove/restore</b> scheduled files by double-clicking.")
box.pack_start(scroll,fill=True,expand=True)
box.pack_start(lbl,fill=True,expand=False)
self.pack1(box,resize=True)
lbl.show()
self.list.show()
scroll.show()
box.show()
fsel = gtk.FileChooserWidget()
fsel.connect("file_activated", lambda s: self.selected(s))
exp = gtk.Expander("File chooser")
exp.add(fsel)
self.pack2(exp,resize=False)
fsel.show()
exp.show()
gobject.timeout_add(1000,self.update)
def selected(self,file):
self.tel.command(self.op+".push "+file.get_filename())
def drag(self,w,context,x,y,data,info,time):
if data and data.format == 8:
for e in data.data.split('\r\n')[:-1]:
self.tel.command(self.op+".push "+urllib.unquote(e))
context.finish(gtk.TRUE, gtk.FALSE, time)
def row_activated(self,view,path,column):
rid = view.get_model().get_value(view.get_model().get_iter(path),0)
skip = view.get_model().get_value(view.get_model().get_iter(path),2)
if skip:
self.tel.command(self.op+".consider "+str(rid))
else:
self.tel.command(self.op+".ignore "+str(rid))
def queue(self):
a = filter(lambda x: x!='',
re.compile('(\d+)\s*').split(self.tel.command(self.op+".queue")))
a = [ self.tel.metadata('request.metadata '+e)[0] for e in a ]
return a
def update(self):
self.list.setModel(self.queue())
return 1
import getopt
import sys
if __name__ == "__main__":
try:
opts, args = getopt.gnu_getopt(sys.argv[1:],"h:p:o:",
['host=','port=','operator='])
except:
# TODO real help
print 'Options are --operator=s --host=s --port=s and -ohp shortcuts'
sys.exit()
op='request'
host='localhost'
port=1234
for o , a in opts:
if o in ('-p', '--port'):
port=int(a)
if o in ('-o', '--operator'):
op=a
if o in ('-h', '--host'):
host=a
try:
win = gtk.Window()
win.set_border_width(10)
win.connect("delete_event", lambda w,e: False)
win.connect("destroy", lambda w: gtk.main_quit ())
win.set_title(host+':'+str(port)+' -- Request '+op)
win.resize(700,300)
print "Double click on request to toggle skip flag"
win.add(LiqQueue(host,port,op))
win.show()
gtk.main()
except socket.error, x:
print "Couln't connect to "+host+':'+str(port)+'!'
|