Posted by Csigaa on Sat 2 Aug 14:27
report spam | download | new post
- """
- xchat_mplayer by Csigaa
- Prints 'NICK is playing FILENAME [MPlayer version]' action to the actual channel.
- Initial release, tested only on Linux, but should work also on other *NIX
- Contact: csigaa@gmail.com
- License: Beer-ware (thx to phk) ;p
- ----------------------------------------------------------------------------
- "THE BEER-WARE LICENSE" (Revision 42):
- Csigaa wrote this file. As long as you retain this notice you
- can do whatever you want with this stuff. If we meet some day, and you think
- this stuff is worth it, you can buy me a beer in return
- ----------------------------------------------------------------------------
- """
- __module_name__ = "xchat_mplayer"
- __module_version__ = "0.1"
- __module_description__ = "MPlayer 'now playing' script for XChat by Csigaa"
- import xchat
- import commands
- import re
- def getPid(progname):
- # Get the PID from ps output
- cmd = 'ps -C '+progname
- pid = re.compile('\d+\s').findall(commands.getoutput(cmd))[0]
- return pid
- def getFilename():
- # Get the video file name (identified by naming pattern) from lsof output
- cmd = 'lsof -F n -p '+getPid('mplayer')
- lines = re.compile('\.*\\n').split(commands.getoutput(cmd))
- i = 0
- path = []
- while (i<len(lines)):
- if re.compile('.*(avi|mpg|mkv|ogg|ogm|wmv|iso)$',re.I).match(lines[i]):
- path = re.compile('\.*/\.*').split(lines[i])
- i+=1
- return path[len(path)-1]
- def getVersion():
- return re.compile(r'^MPlayer\s\d[.]\d+\w{0,4}-\d[.]\d[.]\d').findall(commands.getoutput('mplayer'))[0]
- def mplayer_msg(world,world_eol,userdata):
- try:
- xchat.command('me is playing '+getFilename()+' ['+getVersion()+']')
- return xchat.EAT_ALL
- except:
- return xchat.EAT_ALL
- xchat.hook_command('mplayer',mplayer_msg)
- xchat.prnt('MPlayer nowplay script loaded.')
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.