comparison contrib/xchat-audacious.py @ 2740:a67712c75069 trunk

[svn] - add an xchat script which wraps our DBus API using dbus-python.
author nenolod
date Fri, 11 May 2007 17:20:46 -0700
parents
children 96e7c0385973
comparison
equal deleted inserted replaced
2739:953001c668ae 2740:a67712c75069
1 #
2 # X-Chat Audacious for Audacious 1.4 and later
3 # This uses the native Audacious D-Bus interface.
4 #
5 # To consider later:
6 # - support org.freedesktop.MediaPlayer (MPRIS)?
7 #
8
9 __module_name__ = "xchat-audacious"
10 __module_version__ = "1.0"
11 __module_description__ = "Get NP information from Audacious"
12
13 from dbus import Bus, Interface
14 import xchat
15
16 # connect to DBus
17 bus = Bus(Bus.TYPE_SESSION)
18
19 def command_np(word, word_eol, userdata):
20 aud = bus.get_object('org.atheme.audacious', '/org/atheme/audacious')
21
22 # this seems to be best, probably isn't!
23 length = "stream"
24 if aud.SongLength(aud.Position()) > 0:
25 length = "%d:%02d" % (aud.SongLength(aud.Position()) / 60,
26 aud.SongLength(aud.Position()) % 60)
27
28 xchat.command("SAY [%s | %d:%02d/%s]" % (
29 aud.SongTitle(aud.Position()),
30 aud.Time() / 1000 / 60, aud.Time() / 1000 % 60,
31 length))
32
33 return xchat.EAT_ALL
34
35 xchat.hook_command("NP", command_np, help="Displays current playing song.")