Created
October 21, 2011 16:58
-
-
Save protospork/1304319 to your computer and use it in GitHub Desktop.
MPC now playing for irssi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#this doesn't work for me in cygwin irssi 0.8.15-2, but it works for others | |
use LWP; | |
use Irssi; | |
use vars qw{$VERSION %IRSSI}; | |
$VERSION = 0.01; | |
%IRSSI = ( | |
authors => 'protospork', | |
name => 'MPC', | |
description => 'MPC Now Playing', | |
license => 'I don\'t care' | |
); | |
Irssi::command_bind('MPC', \&now_playing); | |
sub now_playing { | |
my ($data, $server, $item) = @_; | |
my $page = LWP::UserAgent->new()->get('http://localhost:13579/status.html'); | |
return unless $page->is_success; | |
my $text = $page->decoded_content; | |
$text =~ s/^OnStatus\('|'\)$//g; | |
my @info = split /'?,\s*'?/, $text; | |
my $filesize = sprintf "%.2f", ((stat($info[-1]))[7] / 1048576); | |
Irssi::active_win->command('/say np: '.$info[0].' || '.$info[1].': '.$info[3].'/'.$info[5].' || Size: '.$filesize.'MB'); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment