get your top 10 list !!!

To get this week’s top ten from the web, you can first ask billboard using topten.ksh:
#!/bin/ksh
echo “—- getting bilboard’s heatseeker”
curl
158/433
“http://206.130.124.43//htmlsite/html_top.php?id=23&CALL_URL=http%3A//www.billboard.com/bbcom/charts/chart_display.jsp%3Fg%3DSingles%26f%3DHot%2 BDance%2BClub%2BPlay”
> /tmp/bb-hs.txt
cat /tmp/bb-hs.txt | sed -e ‘s/<[^>][^>]*>//g’ -e ‘/^ *$/d;s// /g;s/Featuring//g;s/ the //g’ | tr -s ‘ ‘ | grep “|”|
grep -iv billboard| cut -d ” ” -f4-9 > terms.txt
The top ten list is parsed and ends up as a text only list in “terms.txt”. We now proceed to search and
download the files both from filestube and skreemr, we use a PHP script called mysearch.php to look for files
in filestube(remembver to use your own key for filestube instead of XXXXXXXX):
#!/usr/bin/php
<?php
// Correct English grammar…
$argc > 1 x y z $plural = ‘s’ : $plural = ”;
// Display the number of arguments received
//fwrite(STDOUT, “Got $argc argument$pluraln”);
$args=””;
// Write out the contents of the $argv array
foreach ( $argv as $key => $value ) {
// fwrite(STDOUT,”$key => $valuen”);
if($key!=0){
if($key>1){
$args=”{$args}%20{$value}”;
}else{
$args=”{$value}”;
}
}
}
//print “args are:”;
159/433
//print $args;
$url=”http://api.filestube.com/? key=XXXXXXXXXXXXXXXXXXXXXXX&phrase=$args&extension=mp3&page=1″;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$result = curl_exec($ch) ;
print curl_error($ch);
curl_close($ch);
$document = new DOMDocument(‘1.0’, ‘UTF-8’);
$document->loadXML($result);
$answer = $document->getElementsByTagName(‘answer’)->item(0);
if($answer!=null) {
$hasResults = $answer->getElementsByTagName(‘hasResults’)->item(0);
if($hasResults->nodeValue == 1)
{
$hits = $answer->getElementsByTagName(‘hits’);
foreach($hits as $hit)
{
$name = $hit->getElementsByTagName(‘name’)->item(0)->nodeValue;
$extension = $hit->getElementsByTagName(‘extension’)->item(0)->nodeValue;
$desc = $hit->getElementsByTagName(‘description’)->item(0)->nodeValue;
$size = $hit->getElementsByTagName(‘size’)->item(0)->nodeValue;
$address = $hit->getElementsByTagName(‘address’)->item(0) ->nodeValue;
$details = $hit->getElementsByTagName(‘details’)->item(0) ->nodeValue;
$added = $hit->getElementsByTagName(‘added’)->item(0)->nodeValue;
$related = $hit->getElementsByTagName(‘related’)->item(0) ->nodeValue;
$counter=$hit->getAttribute(‘id’);
print “$name | “;
print ” $address nr”;
}
}
else {
print ‘0 resultsnr’;
}
}
else {
$error = $document->get ElementsByTagName(‘error’)->item (0);
if($error!=null){
$message = $error->getElementsByTagName(‘message’)->item(0)->nodeValue;
print ‘Message: ‘.$message.”nr”;
}
}
//——————————-SECOND PAGE!!!
$url=”http://api.filestube.com/? key=XXXXXXXXXXXXXXXXXXXXXXX
&phrase=$args&extension=mp3&page=2″;
$ch = curl_init();
160/433
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$result = curl_exec($ch) ;
print curl_error($ch);
curl_close($ch);
$document = new DOMDocument(‘1.0’, ‘UTF-8’);
$document->loadXML($result);
$answer = $document->getElementsByTagName(‘answer’)->item(0);
if($answer!=null) {
$hasResults = $answer->getElementsByTagName(‘hasResults’)->item(0);
if($hasResults->nodeValue == 1)
{
$hits = $answer->getElementsByTagName(‘hits’);
foreach($hits as $hit)
{
$name = $hit->getElementsByTagName(‘name’)->item(0)->nodeValue;
$extension = $hit->getElementsByTagName(‘extension’)->item(0)->nodeValue;
$desc = $hit->getElementsByTagName(‘description’)->item(0)->nodeValue;
$size = $hit->getElementsByTagName(‘size’)->item(0)->nodeValue;
$address = $hit->getElementsByTagName(‘address’)->item(0) ->nodeValue;
$details = $hit->getElementsByTagName(‘details’)->item(0) ->nodeValue;
$added = $hit->getElementsByTagName(‘added’)->item(0)->nodeValue;
$related = $hit->getElementsByTagName(‘related’)->item(0) ->nodeValue;
$counter=$hit->getAttribute(‘id’);
print “$name | “;
print ” $address nr”;
}
}
else {
print ‘0 resultsnr’;
}
}
else {
$error = $document->get ElementsByTagName(‘error’)->item (0);
if($error!=null){
$message = $error->getElementsByTagName(‘message’)->item(0)->nodeValue;
print ‘Message: ‘.$message.”nr”;
}
}
?>
Then we direct all the show with get.ksh:
#!/bin/ksh
#### Get the files from FilesTube
(cat terms.txt| while read line;do
./mysearch.php `echo $line | awk ‘{ print $1 ” ” $2 }’`| grep -i `echo $line | awk ‘{ print $3 }’` | head -1
done) >/tmp/results.txt
(cat /tmp/results.txt | while read result;do
curl “`echo $result | awk -F’|’ ‘{ print $2 }’| sed ‘s/ //g’`” | egrep ‘src.*mp3’ | awk -F”src=”” ‘{ print $2 }’ | awk ‘{
161/433
print $1 }’ | sed ‘s/”//g’
done) | while read url;do
wget -P /200gb/AUTODOWNLOADS “$url”
done
rm /tmp/results. txt
#### Or get them from skreemr
(cat terms.txt| while read line;do
st=`echo $line | awk ‘{ print $1 “+” $2 “+” $3 }’`
wget -P /200gb/AUTODOWNLOADS `curl “http://skreemr. com/results.jsp? q=$st” | egrep ‘href.*mp3’ | awk
-F”href=” ‘{ print $2 }’ | head -1 | sed ‘s/”//g’`
done)
The order of execution is: first “topten.ksh”, to get the list, then “get.ksh” to get the tracks.
Enjoy
162/433

Leave a Reply

Your email address will not be published. Required fields are marked *