__module_name__ = "xchat-clementine" __module_version__ = "1.0" __module_description__ = "Get NP information from Clementine" from dbus import Bus, DBusException import xchat bus = Bus(Bus.TYPE_SESSION) def get_clem(): try: return bus.get_object('org.mpris.clementine', '/Player') except DBusException: print "\x02Either Clementine is not running or you have something wrong with your D-Bus setup." return None def command_np(word, word_eol, userdata): clem = get_clem() # clemtl = bus.get_object('org.mpris.clementine', '/TrackList') # clemgl = clemtl.GetLength() clemp = bus.get_object('org.mpris.clementine', '/Player') clemmd = clemp.GetMetadata() if clem: pos = clem.PositionGet() xchat.command("me playing on Clementine: " + unicode(clemmd['artist']).encode('utf-8') + " - " + unicode(clemmd['title']).encode('utf-8')) return xchat.EAT_ALL xchat.hook_command("NP", command_np, help="Displays current playing song.") print "xchat-clementine plugin loaded"