All pastes #8946 Raw Edit

Xchat MPD announce

public python v1 · immutable
#8946 ·published 2005-04-06 17:24 UTC
rendered paste body
import xchat,mpdclient# Jon Temple [toran] <jtemple@coin.org># 04.05.2005# Released under the GPL## prints the song currently being played by # MPD (http://musicpd.org). In the future it# will hopefully be able to control MPD.## current bugs: it apparently sends the command # to the server too, at this point, which is # kind of annoying. Other than that it works fine. __module_name__ = "mpd"__module_version__ = "0.1"__module_description__ = "Gives xchat access to various functions related to the MPD music player."#shows if the script got loadedprint "xchat_mpd-0.1 loaded."def mpd_announce(word, word_eol, userdata):  try:                                                                                  #see if mpd is running    c = mpdclient.MpdController(host='localhost',port=6600)  except Traceback:    print 'MPD does not appear to be running. Make sure MPD is running on port 6600, and then try again.'  if len(word) > 1:                                                                     #check to see if it got run w/ variable    print 'Sorry, mpd-announce does not support any commands at this point. Usage: "/mpd"'  else:    c = mpdclient.MpdController(host='localhost',port=6600)                             #get song info    song = c.getCurrentSong()    z = c.getSongPosition()    progress = str(z[2])    # print 'Currently playing: ' + song.artist + ' - ' + song.title + ' [' + progress[:4] + '%]'    xchat.command('say Currently playing: ' + song.artist + ' - ' + song.title + ' [' + progress[:4] + '%]') #print it to xchatxchat.hook_command("MPD", mpd_announce, help='/MPD displays song currently played by MPD') #get command from xchat