rendered paste body#!/usr/bin/perl
# pls.pl
# tries connecting to a radio stream until it receives a SIGINT
#
use strict;
use warnings;
die("usage: \n\t./pls.pl file.pls\n") unless @ARGV == 1;
my $cmd = "/usr/bin/mplayer";
my @server = ();
open(F,"<$ARGV[0]") || die("can't open playlist: $!\n");
while(<F>) {
/^File\d{1,2}=(.*)$/;
push(@server, $1) unless !defined($1);
}
close(F);
foreach my $url (@server) {
print("$url\n");
system "$cmd $url >/dev/null 2>&1";
die("caught deadly signal, exiting...\n") if($? == 2);
}