All pastes #128270 Raw Edit

Saivert

public text v1 · immutable
#128270 ·published 2006-08-12 21:17 UTC
rendered paste body
#!/usr/bin/perl
#
# FooBar2000 Now playing script
# Requires foo_write_http component installed in FooBar2000
# Simplified some code (LWP::UserAgent), thx Tech <3 4 evah!
#

use strict;
use warnings;
use lib '/usr/local/lib/perl5/site_perl/5.6.2/';
use Irssi;
use Irssi::Irc;
use LWP::UserAgent;
#use Data::Dumper;

sub fb2k_cursong{

	my ($data, $server, $witem) = @_;


	if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")) {

		my $ua = new LWP::UserAgent;
    		$ua->timeout(10);
		$ua->agent("Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.5) Saivert parser/1.0");
		my $res = $ua->get("http://home.saivert.com:4800/");
 
		if ($res->is_success) {
			my $content = $res->content;
			$witem->command("SAY $content");
		} else {
			Irssi::print("fb2k.pl: Could not get songinfo");
		}

	}

}

Irssi::command_bind('np', 'fb2k_cursong');