[FLUG] Script per irssi
- From: legion <blashyrkh@xxxxxxxxx>
- To: fanolug <fanolug@xxxxxxxxxxxxx>
- Date: Thu, 26 Dec 2002 18:09:27 +0100
Mailing List del Fortunae LUG
=============================
se usate irssi per chattare e mp3blaster per ascoltare la musica,questo
è lo script che fa per voi. se no tornate a fare quello che facevate,non
ve ne puo fregare di meno. Lo trovate su irssi.org.
Cmq è la prima cosa veramente utile (per me) che faccio quindi ora
spiego tutto (se lo fa gecco col coso dei betacosi..) :
premessa - il tutto si basa sul fatto che mp3blaster se avviato con
l'opzione "-f file" scrive le info in realtime in un file in questo
modo:
path Amorphis_-_01_-_Better_Unborn.ogg
status playing
title Better Unborn
artist Amorphis
album Elegy
format MPEG 1 layer 0
bitrate 128
samplerate 44100
length 352
next Amorphis_-_02_-_Against_Widows.ogg
se la tag ID3 del file manca certe righe non ci sono(title,artist e album)
codice:
#ste robe qui servono per irssi
use Irssi;
use vars qw($VERSION %IRSSI);
use strict;
$VERSION = '1.00';
%IRSSI = (
authors => 'legion',
contact => 'blashyrkh@xxxxxxxxx',
name => 'irssiBlaster',
description => 'Display the song played by mp3blaster',
license => 'GPL',
url => 'http://irssi.org/',
changed => 'Wed Dec 25 22:37:34 CET 2002',
command => '/np',
);
sub cmd_blaster {
# questo specifica qual'è il file con le info,si specifica con un /set in irssi
my $infofile = Irssi::settings_get_str('mp3blaster_infos_path');
#apre il file
open (FILE, $infofile);
#fa un array con elementi le righe del file
my @all = <FILE>;
#greppa le righe che iniziano con artist title (se ci sono) e path (che c'è per
forza)
my @artist = grep (/^artist/, @all);
my @title = grep (/^title/, @all);
my @name = grep (/^path/, @all);
#se ci sono artist e title..
if (@artist && @title) {
#qui elimina "artist" e "title" dalle righe
foreach $a (@artist) { @artist[$a] =~ s/artist //; }
chomp (@artist);
foreach $a (@title) { @title[$a] =~ s/title //; }
chomp (@title);
#setta cosa viene printato in irssi
my $gh = "n.p: @artist - @title";
#qui bo non so bene a cosa serve,ma deve andare cosi per funzioanare :)
my ($data, $server, $witem) = @_;
#qui printa il tutto,come /me blabla o come notice del client a seconda se si è
in un canale o no
#codice palesemente copiato da altri script
if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq
"QUERY"))
{ $witem->command("me $gh"); }
else { Irssi::print("$gh", MSGLEVEL_CRAP); }
}
#se non c'è artist e title (cioè se non c'è la tag) printa il nome del file
direttamente..
elsif (@name) {
#qui toglie "path",l'estensione del file e trasforma le _ in spazi (che è +
bello da vedere)
foreach $a (@name) { @name[$a] =~ s/path //; }
foreach $a (@name) { @name[$a] =~ s/.mp3//gi; }
foreach $a (@name) { @name[$a] =~ s/.ogg//gi; }
foreach $a (@name) { @name[$a] =~ s/_/ /g; }
chomp (@name);
#come prima
my $gh = "n.p: @name";
my ($data, $server, $witem) = @_;
if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq
"QUERY"))
{ $witem->command("me $gh"); }
else { Irssi::print("$gh", MSGLEVEL_CRAP); }
}
#qui se non riesce a leggere niente nel file spiega cosa tocca fare
else { Irssi::print("%RERROR:%n%9 $infofile %_is not a valid info file!
Make sure %9mp3blaster -f $infofile %_is running\nFor change: /set
mp3blaster_infos_path\nHint: put %9alias mp3blaster='mp3blaster -f $infofile'%_
in your ~/.bashrc :) enjoy!", MSGLEVEL_CLIENTCRAP); }
#chiude
close (FILE);
}
#registra il comando /np e il setting /set mp3blaster_infos_path
Irssi::command_bind('np', 'cmd_blaster');
Irssi::settings_add_str('misc', 'mp3blaster_infos_path', '.infoz');
--
vabbè il risultato è questo:
18:07 * legion n.p: Amorphis - Better Unborn
:)
-
Born to loose, live to linux
-- Motorhead - 1977
--
<simon> oh andiamo a beccare delle donne?
Other related posts:
- » [FLUG] Script per irssi