All pastes #773702 Raw Edit

amarok.py

public python v1 · immutable
·published 2007-11-14 18:57 UTC
rendered paste body
__module_name__ = "amarok now-playing"__module_version__ = "0.1"__module_description__ = "Display current playing song in amarok"import xchatimport commandsimport dbusbus = dbus.SessionBus()def amarok_cb(word, word_eol, userdata):	try:		if commands.getstatusoutput('dcop amarok player')[0] == 0 and len(commands.getstatusoutput('dcop amarok player title')[1]):			playing = 1		else:			playing = 0	except:		playing = 0	if len(word) > 1 and word[1] == 'next' and playing > 0:		commands.getstatusoutput('dcop amarok player next')		return xchat.EAT_ALL	if playing > 0:		title = commands.getstatusoutput('dcop amarok player title')[1]		artist = commands.getstatusoutput('dcop amarok player artist')[1]		album = commands.getstatusoutput('dcop amarok player album')[1]		year = commands.getstatusoutput('dcop amarok player year')[1]		bitrate = commands.getstatusoutput('dcop amarok player bitrate')[1]		duration_show = commands.getstatusoutput('dcop amarok player totalTime')[1]		elapsed_show = commands.getstatusoutput('dcop amarok player currentTime')[1]		output = 'Now Playing: \x0304%s\x03 by \x0303%s\x03 from \x0302%s\x03 year: \x0305%s\x03 bitrate: \x0306%s\x03 (\x0307%s/%s\x03)' % (title, artist, album, year, bitrate, elapsed_show, duration_show)	else:		output = 'Now Playing: Silence'	xchat.command('say %s' % (output))	return xchat.EAT_ALLxchat.hook_command('amarok', amarok_cb, help='/amarok Sends playing song info to channel')