Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. __module_name__ = "xchat-clementine"
  2. __module_version__ = "1.0"
  3. __module_description__ = "Get NP information from Clementine"
  4. from dbus import Bus, DBusException
  5. import xchat
  6. bus = Bus(Bus.TYPE_SESSION)
  7. def get_clem():
  8.     try:
  9.         return bus.get_object('org.mpris.clementine', '/Player')
  10.     except DBusException:
  11.         print "\x02Either Clementine is not running or you have something wrong with your D-Bus setup."
  12.         return None
  13.  
  14. def command_np(word, word_eol, userdata):
  15.     clem = get_clem()
  16. #    clemtl = bus.get_object('org.mpris.clementine', '/TrackList')
  17. #    clemgl = clemtl.GetLength()
  18.     clemp = bus.get_object('org.mpris.clementine', '/Player')
  19.     clemmd = clemp.GetMetadata()
  20.     if clem:
  21.         pos = clem.PositionGet()
  22.         xchat.command("me playing on Clementine: " + unicode(clemmd['artist']).encode('utf-8') + " - " + unicode(clemmd['title']).encode('utf-8'))
  23.     return xchat.EAT_ALL
  24.  
  25. xchat.hook_command("NP",    command_np,                 help="Displays current playing song.")
  26. print "xchat-clementine plugin loaded"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement