<?php
$spotify1="https://itunes.apple.com/search?term=";
$spotify2=" - ";
$spotify3="&limit=1";
$fp = fopen($STATS_FILE,'r');
if(!$fp) { die("Unable to connect to Icecast server."); }
$stats_file_contents = '';
while(!feof($fp)) { $stats_file_contents .= fread($fp,1024); }
fclose($fp);
$radio_info = array();
$radio_info['genre'] = '';
$radio_info['listeners'] = '';
$radio_info['now_playing'] = '';
$temp = array();
$search_for = "<td\s[^>]*class=\"streamdata\">(.*)<\/td>";
$search_td = array('<td class="streamdata">','</td>');
if(preg_match_all("/$search_for/siU",$stats_file_contents,$matches)) {
foreach($matches[0] as $match) {
$to_push = str_replace($search_td,'',$match);
$to_push = trim($to_push);
array_push($temp,$to_push);
}
}
$radio_info['listeners'] = $temp[4];
$radio_info['genre'] = $temp[6];
//$radio_info['now_playing'] = $temp[8];
//$radio_info['now_playing'] = $temp[8];
$radio_info['info']['now_playing'] = $temp[8];
$x = explode(" - ",$temp[8]);
$artist1 = $x[0];
$song1 = $x[1];
$artist1 = str_replace('&', 'and', $artist1);
$song1 = str_replace('&', 'and', $song1);
$ttt =" - ";
$title = $artist1.$ttt.$song1;
$img640_url= "https://i.deep1.ru/playingnow/logo_default.png";
$img300_url= "https://i.deep1.ru/playingnow/logo_default.png";
$img64_url= "https://i.deep1.ru/playingnow/logo_default.png";
echo $spotify_url=$spotify1.$artist1.$spotify2.$song1.$spotify3 ;
echo $spotify_url = str_replace(' ', '+', $spotify_url);
//$spotify_url = "https://itunes.apple.com/search?term=Kylie+Minogue";
$ch = curl_init($spotify_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$spotify = curl_exec($ch);
curl_close($ch);
$obj = json_decode($spotify);
//$total = $obj->resultCount->results;
//$img640_url = $obj->resultCount[0]->results[1]->artworkUrl100;
echo $img640_url;
preferences:
39.34 ms | 402 KiB | 5 Q