Advertisement
SteelGolem

SteelGolem's VLC NP spammer

Feb 5th, 2012
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. # usage:
  2. #   type /np to spam the filename in the current channel
  3. #   - uses /action (or /me) to spam with
  4.  
  5. __module_name__ = "SteelGolem's VLC NP spammer"
  6. __module_version__ = "1.1.1"
  7. __module_description__ = "VLC Now Playing spammer"
  8.  
  9. print "\0034" + __module_name__, __module_version__, "has been loaded\003"
  10. print "\0034Type \"/np\" to spam the filename of whatever's playing in VLC in chat."
  11.  
  12. import xchat, commands
  13.  
  14. def command_np(word, word_eol, userdata):
  15.     pid = commands.getoutput("ps --no-headers -C vlc | awk '{print $1}'")
  16.     procentry = commands.getoutput("ls -l /proc/" + pid + "/fd | egrep '.mkv|.avi|.mpg|.mp3|.wmv|.mp4|.flac'")
  17.     splitparts = procentry.split('/')
  18.     filename = splitparts[len(splitparts)-1]
  19.     if filename == "":
  20.         print "\0034SG VLC NP error: unknown file type, or nothing loaded\003"
  21.     elif filename == "fd: not found":
  22.         print "\0034SG VLC NP error: unknown error, document"
  23.     elif filename == "fd: No such file or directory":
  24.         print "\0034SG VLC NP error: VLC not running\003"
  25.     else:
  26.         xchat.command("action np: " + filename)
  27.     return xchat.EAT_ALL
  28.  
  29. xchat.hook_command("NP", command_np, help="Displays filename of whatever's playing in VLC.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement