mpd now playing plugin for XChat
anomit | July 6, 2008It is 3 in the morning. Don't expect me to blabber much. Windows users, please fuck off at this point. Just give the file a py extension and move it to ~/.xchat2 so that it loads automatically at startup. Use /show to tell everyone in the channel you are playing [insert an emo band name here] and proceed to cut your wrist or let everyone know you are a real emo with the legwarmers and all. OK ENOUGH.
__module_name__ = "mpd-np"
__module_version__ = "0.1"
__module_description__ = "mpd now playing"
def playing(word, word_eol, userdata):
mpd=socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
host='127.0.0.1'
port=6600
mpd.connect((host,port))
#welcome msg could be used to extract mpd version information
welcome=mpd.recv(1024)
mpd.send('currentsong\r\n')
#get all the info about current track being played
data=mpd.recv(4096)
#I wont be explaining any REs
artist=re.findall(r'Artist[:]\s[\S ]+',data)[0].split(':')[1]
title=re.findall(r'Title[:]\s[\S ]+',data)[0].split(':')[1]
msg='Now playing:'+artist+'-'+title
xchat.command('me '+msg)
data=""
mpd.close()
return xchat.EAT_ALL
#hooks into the show xchat command
xchat.hook_command("show",playing)
Reports of idiotic behavior go into the comments.







Why don't you use something like Github to share your
Rohit Arondekar | July 6, 2008Why don't you use something like Github to share your code ?
@Rohit: Good idea! Checking it out.
anomit | July 6, 2008@Rohit: Good idea! Checking it out.