# # Announce.pl v 1.0 # by pawz # (email: pawz@westnet.com.au) # # Use or modify at will, just don't claim it as yours without making significant changes # # X-Chat perl script for announcing song (and movie) titles from VLC and iTunes # # NOTE: This REQUIRES that you turn on VLC's logging feature. To do this, open VLC's preferences, and under the # "Interface > Control Interfaces" preference page, tick the "File Logging" option. Then under the # "Interface > Control Interfaces > Logging" page, enter "/tmp/vlc_log.txt" as the log filename. You can choose a # different name or location if you wish, but if you do, change the path definition to it in the function below. # You may have to choose the "Add Interface > Debug Logging" menu option (under the VLC menu) if VLC hasn't already # turned it on via the preferences change. # IRC::register("Announce","1.0","",""); IRC::print("::Announce v1.0:: [Loaded]"); IRC::add_command_handler("itunes","itunes_announce"); IRC::add_command_handler("vlc","vlc_announce"); IRC::print "Commands: "; IRC::print " /itunes : Announce your current track name on IRC. "; IRC::print " /vlc : Announce your current song or movie name on IRC. "; sub itunes_announce { # this bit is split over multiple lines for readability $parta = "/applescript -o tell application \"iTunes\" to return \"np: [ \002\" "; $partb = "& artist of current track & \" (\" & album of current track & \") - \" & name of current track & \" \002] \""; $partc = $parta . $partb; IRC::command("$partc"); return 1; } sub vlc_announce { $LOGFILE = "/tmp/vlc_log.txt"; $songsplayed = `grep "successfully opened" $LOGFILE | tail -1`; $songsplayed =~ /.+\`(.+)\'.+/s; $lastsong = $1; $lastsong =~ /.+\/(.+)\/(.+)\.\w/; $album = $1; $song = $2; IRC::command ("np: [ ($album) $song ]"); return 1; }