#	VLC Announce v 1.0
#
#	Howto (VLC settings):
#	1. Open VLC's preferences
#	2. Interface > Control Interfaces preference page, tick the "File Logging" option.
#	3. Interface > Control Interfaces > Logging" page, enter "/tmp/vlc_log.txt" as the log filename. You can choose #          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.
#
#	Hacked by Poka64 for his own needs, credits goes out to pawz@westnet.com.au for the original script 
#	(Announce.pl v1.0 http://www.linuxirc.com/download/Announce.tgz)
#
#	I removed the Itunes part of the script, seemed unnecessary to include that part when using this script on linux

IRC::register("VLC announce","1.0","","");
IRC::print("::VLC announce v1.0:: [Loaded]");
IRC::add_command_handler("vlc","vlc_announce");
IRC::print "Commands: ";
IRC::print " /vlc : Announce your current song or movie name on IRC. ";

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 ("/me spielt grade $song");
	return 1;
}

