All pastes #137904 Raw Edit

xchat-xmms script

public text v1 · immutable
#137904 ·published 2006-08-18 19:41 UTC
rendered paste body
#!/usr/local/bin/perl -w

# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# This script requires the Xmms::Remote module, use the following commands to install 
# Xmms::Remote                   perl -MCPAN -e shell 
# once you have done that do     install Xmms::Remote  

# commands: /mp3 - display the currently playing track
#           /mp3auto - display the currently playing track and each subsequent track
#           /mp3auto - toggle auto display on/off
#           /mp3skip - skip forward to next track
#           /mp3pause - pause/unpause track

# for comments, suggestions, improvements etc contact me
# on irc.chatnet.org (nick gordy) 


# Thanks for your interest.


use Xmms::Remote ();

IRC::register ("XMMS-thing", "0.1", "", "");
IRC::print ("XMMS-thing loaded");
IRC::add_command_handler("mp3", "mp3_bullshit");
IRC::add_command_handler("mp3auto", "auto");
IRC::add_command_handler("mp3skip", "skip");
IRC::add_command_handler("mp3pause", "pause");

$remote = Xmms::Remote->new;


sub mp3_bullshit {
if ($remote->is_playing) {
$title = $remote->get_playlist_title;
$time = $remote->get_playlist_timestr."s";
$time =~ s/:/m/;
@info = $remote->get_info;
$kbs = $info[0]/1000;
#utf8::decode($title);
#utf8::decode($time);
#utf8::decode($kbs);
#utf8::decode($info);
#chomp($title);
IRC::command("/me is playing \cC09 $title $time \cC14 $kbs kbit \cC09 $info[1] Hz");
#IRC::command("/say NP: \cC09 $title $time $kps \cC14 kbit/s \cC09 $info[1] \cC14 Hz");
}
return 1;
}

sub mp3_auto_bullshit {
if ($auto eq "on") {
if ($title ne $remote->get_playlist_title) {
mp3_bullshit();
} 
IRC::add_timeout_handler(5000, mp3_auto_bullshit);
return 1;
}
}

sub skip {
$remote->playlist_next;
return 1;
}

sub pause {
$remote->pause;
return 1;
}


sub auto {
unless ($auto) {
$auto = "on";
} else {
$auto = "";
}
mp3_auto_bullshit();
return 1;
}