weechat script (récupérer une musique qui joue)

master
karchnu 2015-01-26 00:26:05 +01:00
parent a1b12e63a9
commit fca19a877f
2 changed files with 42 additions and 5 deletions

View File

@ -3,7 +3,7 @@ use strict;
use warnings;
use v5.14;
die "usage : ./$0 website_list.txt" if @ARGV != 1;
die "usage : cat website_list.txt | ./$0 > page.html" if @ARGV != 0;
my @tab;
my %dom;
@ -43,14 +43,14 @@ sub test_ipv6 {
my @var = split "\n", $ret;
for(@var) {
chomp $ret;
next unless /:/;
say $ret;
chomp;
say; # print the IPv6
# we try to reach the website's server
my $retping =
`/bin/ping6 -i 0.5 -c 2 $ret | grep ' 0% packet loss'`;
`/bin/ping6 -i 0.5 -c 2 $_ | grep ' 0% packet loss'`;
chomp $retping;
if(length $retping) {
@ -66,6 +66,7 @@ sub check_reachability {
say '<!-- ';
for(keys %dom) {
chomp;
test_ipv6 $_;
}
say '--!>';

36
perl/song.pl Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/perl -w
use v5.14;
use Modern::Perl;
my $name = "song";
my $info_perso = "Philippe (karchnu) Pittoli karchnu+travail (at) karchnu.fr";
my $version = "0.1";
my $licence = "GPL3";
my $description = "Permet de savoir quelle est la musique qui tourne.";
weechat::register($name, $info_perso, $version, $licence, $description, "", "");
weechat::print("", "Bonjour, du script perl !");
sub song {
my ( $data, $buffer, $args ) = @_;
my @args = split /\s+/, $args;
my $ip = "portable";
my $port = "6600";
$ip = $args[1] if(@args >= 2);
$port = $args[2] if(@args >= 3);
my $sortie = `mpc current -p $port -h $ip -f "%title% - %album% : %time%"`;
weechat::print(weechat::current_buffer(), "[cursong]\t$sortie");
}
weechat::hook_command("song", "description de mon filtre",
"current [host [port]]",
"song current [host [port]]",
"current"
, "song", "");