__module_name__ = "amarok now-playing"
__module_version__ = "0.3"
__module_description__ = "Display current playing song in amarok"
import xchat
import commands
import dbus
bus = 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, b$
else:
output = 'Now Playing: Silence'
xchat.command('say %s' % (output))
return xchat.EAT_ALL
xchat.hook_command('amarok', amarok_cb, help='/amarok Sends playing song info to channel')