stream.pl



NAME

stream.pl <radio>


DESCRIPTION

Listen to streaming <radio>, 'list' for a list of radios.


COPYRIGHT

Copyright 2013 Etienne LEMEE <coding AT etilem DOT net>

This piece of code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


#!/usr/bin/perl -w

@ARGV > 0 or die << "USAGE";
usage: $0 <radio>
listen to streaming <radio>, 'list' for a list of radios.
USAGE

my $sta = shift @ARGV;

my $pla = "mplayer -really-quiet";

my %str = qw(
jungle	http://stream2.jungletrain.net:8000
nova	http://broadcast.infomaniak.net/radionova-high.mp3
inter	http://mp3.live.tv-radio.com/franceinter/all/franceinterhautdebit.mp3
);

if ($sta eq 'list') {
    printf ("%s\t=> %s\n", $_, $str{$_}) for (sort keys %str);
}
elsif ($str{$sta}) {
    system (sprintf ("%s %s 2>/dev/null", $pla, $str{$sta}));
}
else {
    print "No stream found, 'list' for a list.\n";
}