#
# pyql - show what's currently playing in Quod Libet
#
# Quod Libet needs to be running of course!
#
# This is a lame python version of QLCtrl http://ruined.us/projects/qlctrl/
# Unlike QLCtrl this script does not do any error checking whatsoever (yet)
#
# (c) Lasse Pommerenke, housetier@gmail.com
# written with pida: http://pida.berlios.de/index.php/Main_Page
#
# History:
# 0.1 initial release, seems to work on my pc
# 0.2 less user editing required, thanks to piman in #quodlibet on oftc
# 0.3 add try..except
#
import os
current_file_name = os.path.expanduser('~/.quodlibet/current')
# except for programming mistakes you shouldn't need to edit anything below this# line
import xchat
import re
__module_name__ = "pyql"
__module_version__ = "0.2"
__module_description__ = "shows what's playing in quod libet"
def np_handler(foo1, foo2, foo3):
try:
f = open(current_file_name)
data = f.read()
f.close()
list1 = data.split("\n")
list2 = [foo for foo in list1 if re.search("^(artist|title|length)=.*", foo)]
dict = {}
for foo in list2:
k, v = foo.split("=")
dict[k] = v
xchat.command("me \\np[%s]: %s - %s" % (dict["length"], dict["artist"], dict["title"]))
except:
return xchat.EAT_ALL
return xchat.EAT_ALL
xchat.hook_command("np", np_handler, help="its too simple for help!")