np-1.1.phps

<?
// irssi: /alias ad /exec - -out cat /home/fisk/.song.txt
// ATTN: touch /home/fisk/.song.txt && chmod 666 /home/fisk/.song.txt
// http://users.jyu.fi/~ltnevala/nowplaying/
$dump = '/home/fisk/.song.txt';

$info = $_POST['Song'][0];

if($info['SongLength']) {
    $info['SongLength'] = urldecode($info['SongLength']);
    if(substr($info['SongLength'],0,3) == '00:') {
        $info['SongLength'] = substr($info['SongLength'],3);
        if($info['SongLength']{0} == 0) {
            $info['SongLength'] = substr($info['SongLength'],1);
        }
    }
    $extra[] = $info['SongLength'];
}
if($info['Bitrate']) {
    $extra[] = $info['Bitrate'].'kbps';
}
if($info['Genre']) {
    $extra[] = urldecode($info['Genre']);
}
$extra = join('/',$extra);

file_put_contents($dump,'np: '.urldecode($info['Artist']).' - '.urldecode($info['Title']).(isset($extra)?' ('.$extra.')':''));


?>