#!perl
use strict;
use LWP::Simple;
my $url = 'http://www.kcrw.com/';
my $sleep_time = 120;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;
my $playlist = 'playlist.txt';
# What do you want to find out about
my $start = "";
my $stop1 = "<\/a> by ";
my $stop2 = "<\/a> at";
my @playlist;
my $last_song;
while ($hour < 14) { # only until 2p central
die "Couldn't get $url" unless (my $content = get $url);
# search the $content for the $kw
$content =~ m/$start(.*)$stop1(.*)$stop2/i;
if ($1 ne $last_song) {
my %song = ('SONG' => $1, 'SINGER' => $2);
push(@playlist, \%song);
$last_song = $1;
print "Now playing: '$1' by $2\n";
open PL, ">>$playlist" or die "Cannot open $playlist: $!";
print PL "$1|$2\n";
close PL;
}
sleep $sleep_time;
}