Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 29th, 2010  |  syntax: Python  |  size: 1.05 KB  |  hits: 336  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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"