.
I've found alot of new music artists from listening over the past few days , ok, it's only been 2 days.
KEXP provides an 'up-to-the-minute'
of what they have played within the hour.
I wanted a little more info on the artists than what they were giving me so I threw together a little script to
access Google's DB and return the top 6 results on the band's name.
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use HTML::TableExtract;
use SOAP::Lite;
use CGI;
my ($cgi, $ua, $request, $response, $html, $body, $ts, $row, $Boogle,
+$out);
my $GoogleKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$cgi = CGI->new();
$Boogle = \&google;
$ua = LWP::UserAgent->new;
$ua->proxy('http', ''); # enter proxy if needs be / and set it for Soa
+p too ...
$request = HTTP::Request->new('GET', 'http://140.142.17.178/playdisp
+.asp');
$response = $ua->request($request);
$html = $response->as_string;
$body = new HTML::TableExtract(
headers => [('Time','Artist','Song title','Album title','Label','C
+omments' )] )
-> parse($html);
print $cgi->header,
$cgi->start_html({-title=>'KEXP PLAYLIST',-style=>{src=>'playlis
+t.css'}}),
$cgi->start_table({-border=>0,-width=>900,-cellpadding=>4, -ce
+llspacing=>1});
print $cgi->Tr({-class=>'head'},$cgi->td(['Time','Artist','Song','Albu
+m','6 Related links from Google']));
foreach $ts ($body->table_states) {
foreach $row ($ts->rows) {
my ($Time,$Artist,$Song,$Album,$Label,$Comments) = @$row;
print $cgi->Tr({-class=>'body'},
$cgi->td([$Time,$Artist,$Song,$Album,$Boogle->($Artist)]))
+ if length($Time) > 3; # some rows are empty
}
}
sub google {
my $param = shift;
my @params = ($GoogleKey,$param, 0, 6, 0, '', 0, '', 'latin1', 'latin
+1');
my $result = SOAP::Lite -> service("file:GoogleSearch.wsdl") -> doGoo
+gleSearch(@params);
$out = join "\n\t", map( { qq{ • <a href="$_->{URL}">} . ($_->
+{title} || $_->{URL}) . qq{</a> <br />} } @{$result->{resultElements}
+} );
return $out;
}
#ps - don't be surprised if you get no playlist at the top of the hour
# they tend to be about one min behind the actual play-time.
#
#
# <silent11> can I reference a sub via a scalar?
# <cluka> Sure. If you have a sub named routine,
# you can reference it via $s = \&routine. Then call like $s->(args)