All pastes #238563 Raw Edit

irssi+quod script

public text v1 · immutable
·published 2006-11-05 01:11 UTC
rendered paste body
use Irssi;
use Irssi::TextUI;
use vars qw($VERSION %IRSSI);

$VERSION = '0.1';
%IRSSI = (
	description	=> 'Quod Libet now playing script, LaTeX look.',
	changed		=> '20:10EST Saturday 04/11/06',
);



sub get_info {

	open (FILE, '/home/ryan/.quodlibet/current');
	@all = <FILE>;
	close (FILE);

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

	@artist = grep (/artist/, @all);
	@title = grep (/title/, @all);
	@format = grep (/format/, @all);
    @bitrate = grep(/bitrate/, @all);
    $artist = $artist[0];
    $title = $title[0];
    $format = $format[0];
    $bitrate = $bitrate[0];
    $artist =~ s/artist=//;
    $title =~ s/title=//;
    $format =~ s/~format=//;
    $bitrate =~ s/~#bitrate=//;
    $artist =~ s/\n//;
    $title =~ s/\n//;
    $format =~ s/\n//;
    $bitrate = int($bitrate / 1024);
    $bitrate .= "kbps";
    if($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")){
        if($title){
            if($format eq 'MP3') {
                $witem->command("ME \0037\\np\0036[$format,\ $bitrate]{$artist\ -\ $title}");
            }
            else {
                $witem->command("ME \0037\\np\0036[$format]{$artist\ -\ $title}");
            }
        }
    }
}

Irssi::command_bind('amp', 'get_info');