1 contributor
<?php
//Set $DEBUG to 1 at the end of the file to enable JSON debug
function get_fipradio_tags() {
$metadata = array();
$jsondata=file_get_contents("http://www.fipradio.fr/sites/default/files/import_si/si_titre_antenne/FIP_player_current.json");
$array_json = json_decode($jsondata,TRUE);
$fipradio_artist = "An Error Occured";
$fipradio_title = "An Error Occured";
$fipradio_url = "";
if( isset($array_json["current"]["song"]) ) {
$fipradio_title=$array_json["current"]["song"]["titre"];
if( isset($array_json["current"]["song"]["interpreteMorceau"]) ) {
$fipradio_artist=$array_json["current"]["song"]["interpreteMorceau"];
}
$fipradio_url=$array_json["current"]["song"]["visuel"]["small"];
}
$metadata[0]=$fipradio_artist;
$metadata[1]=$fipradio_title;
$metadata[2]=$fipradio_url;
return $metadata;
}
function get_lemouv_tags() {
$metadata = array();
//~ $jsondata=file_get_contents("http://www.lemouv.fr/sites/default/files/direct.json");
$jsondata=file_get_contents("http://www.mouv.fr/sites/default/files/import_si/si_titre_antenne/leMouv_player_current.json");
//~ echo "[$jsondata]<br>\n";
$array_json = json_decode($jsondata,TRUE);
//~ $lemouv_title=$array_json["rf_titre_antenne"]["titre"];
//~ $lemouv_artist=$array_json["rf_titre_antenne"]["interprete"];
//~ $lemouv_url=$array_json["rf_titre_antenne"]["image"];
$lemouv_title=$array_json["current"]["emission"]["titre"];
$lemouv_artist=$array_json["current"]["emission"]["lien"];
$lemouv_url=$array_json["current"]["emission"]["visuel"]["small"];
//~ echo "[DEBUG] lemouv_title : [$lemouv_title]<br>\n";
//~ echo "[DEBUG] lemouv_artist : [$lemouv_artist]<br>\n";
//~ echo "[DEBUG] lemouv_url : [$lemouv_url]<br>\n";
if( 0 == strcmp("null",$lemouv_title) )
{
$lemouv_title = "An Error Occured";
}
if( 0 == strcmp("null",$lemouv_artist) )
{
$lemouv_artist = "An Error Occured";
}
if( 0 == strcmp("null",$lemouv_url) )
{
$lemouv_url = "";
}
$metadata[0]=$lemouv_artist;
$metadata[1]=$lemouv_title;
$metadata[2]=$lemouv_url;
return $metadata;
}
function get_fculture_tags() {
$metadata = array();
$epochLocal = time();
$jsondata=file_get_contents("http://www.franceculture.fr/programmes?xmlHttpRequest=1");
$array_json = json_decode($jsondata,TRUE);
$i = 0;
$fculture_artist="An Error Occured";
$fculture_title="An Error Occured";
$metadata[0]=$fculture_artist;
$metadata[1]=$fculture_title;
while( isset($array_json[$i]) ) {
$time_start=$array_json[$i]["start"];
$time_stop=$array_json[$i]["end"];
if( ( $time_start <= $epochLocal ) &&
( $time_stop >= $epochLocal ) ) {
if( isset($array_json[$i]["surtitle"])) {
$fculture_artist=$array_json[$i]["surtitle"];
}
if( isset($array_json[$i]["surtitle"])) {
$fculture_title=$array_json[$i]["title"];
}
$metadata[0]=$fculture_artist;
$metadata[1]=$fculture_title;
}
$i++;
}
return $metadata;
}
function get_finter_tags() {
$metadata = array();
$epochts=time();
$epochLocal = $epochts;
$modSeconds=$epochts % 3600;
$modHours = $epochts / 3600 % 24;
$epochts=$epochts - $modHours*3600 - $modSeconds - 7200;
$finter_artist="An Error Occured";
$finter_title="An Error Occured";
//$jsondata=file_get_contents("http://www.franceinter.fr/sites/default/files/conducteur/direct_$epochts.json");
$jsondata=false;
if( false === $jsondata ) {
$metadata[0]=$finter_artist;
$metadata[1]=$finter_title;
return $metadata;
}
$array_json = json_decode($jsondata,TRUE);
$i = 0;
while( isset($array_json[$i]) ) {
$time_start=$array_json[$i]["date_debut"];
$time_stop=$array_json[$i]["date_fin"];
if( ( $time_start <= $epochLocal ) &&
( $time_stop >= $epochLocal ) ) {
$finter_title=$array_json[$i]["titre_diffusion"];
$finter_artist=$array_json[$i]["titre_emission"];
$metadata[0]=$finter_artist;
$metadata[1]=$finter_title;
}
$i++;
}
return $metadata;
}
function get_fmusique_tags() {
$metadata = array();
/*
$epochts=time();
//~ echo "[DEBUG] epochts_org : $epochts<br>\n";
$modSeconds=$epochts % 3600;
$epochts=$epochts + 7*3600 + 3600 - $modSeconds;
//~ echo "[DEBUG] epochts : $epochts<br>\n";
$jsondata=file_get_contents("http://www.francemusique.fr/sites/default/files/lecteur_commun_json/reecoute-$epochts.json");
$array_json = json_decode($jsondata,TRUE);
$fmusique_title=$array_json["diffusions"][0]["title_diff"];
$fmusique_artist=$array_json["diffusions"][0]["title_emission"];
*/
$fmusique_artist = "An Error Occured";
$fmusique_title = "An Error Occured";
$metadata[0]=$fmusique_artist;
$metadata[1]=$fmusique_title;
return $metadata;
}
function get_classic21_tags() {
$currDate = time();
$fake_json_data=file_get_contents("http://np.maradio.be/qp/v3/events?rpId=2&serviceNameSize=200&nameSize=200&artistNameSize=200&descriptionSize=200&callback=radioplayer.playing.receive&_=".$currDate );
$pos_start = strlen("radioplayer.playing.receive(");
$pos_end = strlen( $fake_json_data ) - 1;
$jsondata = substr($fake_json_data, $pos_start, $pos_end - $pos_start );
$array_json = json_decode($jsondata,TRUE);
$classic21_artist = "An Error Occured";
$classic21_title = "An Error Occured";
$classic21_url = "";
if( isset($array_json["results"]["now"]["name"]) ) {
$classic21_title=$array_json["results"]["now"]["name"];
}
if( isset($array_json["results"]["now"]["artistName"]) ) {
$classic21_artist=$array_json["results"]["now"]["artistName"];
}
$classic21_url=$array_json["results"]["now"]["imageUrl"];
$metadata[0]=$classic21_artist;
$metadata[1]=$classic21_title;
$metadata[2]=$classic21_url;
return $metadata;
}
function get_lgr_rock_url() {
$SEARCHSUB='<img class="border_gris" src="http://www.lagrosseradio.com/artiste/images/';
$htmldata = file_get_contents("http://www.lagrosseradio.com/_include/ajax_global.php?type_page=0&top_good=-5");
$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
if( false !== $pos_start ) {
$SEARCHSUB='" width="80" height="80"';
$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start );
//30 = strlen('<img class="border_gris" src="');
$url = substr($htmldata, $pos_start+30, $pos_stop - $pos_start - 30 );
return $url;
}
return "";
}
function get_lgr_metal_url() {
$SEARCHSUB='<img class="border_gris" src="http://www.lagrosseradio.com/artiste/images/';
$htmldata = file_get_contents("http://www.lagrosseradio.com/_include/ajax_global.php?type_page=0&top_good=-5");
$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
if( false !== $pos_start ) {
$SEARCHSUB='<img class="border_gris" src="http://www.lagrosseradio.com/artiste/images/art_pochettes/';
$pos_start2 = strpos($htmldata, $SEARCHSUB, $pos_start+strlen($SEARCHSUB) );
if( false !== $pos_start2 ) {
$SEARCHSUB='" width="80" height="80"';
$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start2 );
//30 = strlen('<img class="border_gris" src="');
$url = substr($htmldata, $pos_start2+30, $pos_stop - $pos_start2 - 30 );
return $url;
}
}
return "";
}
function get_lgr_reggae_url() {
$SEARCHSUB='<img class="border_gris" src="http://www.lagrosseradio.com/artiste/images/';
$htmldata = file_get_contents("http://www.lagrosseradio.com/_include/ajax_global.php?type_page=0&top_good=-5");
$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
if( false !== $pos_start ) {
$pos_start2 = strpos($htmldata, $SEARCHSUB, $pos_start+strlen($SEARCHSUB) );
if( false !== $pos_start2 ) {
$pos_start3 = strpos($htmldata, $SEARCHSUB, $pos_start2+strlen($SEARCHSUB) );
if( false !== $pos_start3 ) {
$SEARCHSUB='" width="80" height="80"';
$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start3 );
//30 = strlen('<img class="border_gris" src="');
$url = substr($htmldata, $pos_start3+30, $pos_stop - $pos_start3 - 30 );
return $url;
}
}
}
return "";
}
function get_radio_nova_tags() {
$metadata = array();
$radio_nova_artist = "An Error Occured";
$radio_nova_title = "An Error Occured";
$radio_nova_url = "";
$jsondata=file_get_contents("http://www.novaplanet.com/radionova/ontheair");
$array_json = json_decode($jsondata,TRUE);
$htmldata=$array_json['track']['markup'];
//title
$SEARCHSUB='<div class="title">';
//19 = strlen($SEARCHSUB);
$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
if( false !== $pos_start ) {
$SEARCHSUB='</div>';
$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start );
$radio_nova_title = substr($htmldata, $pos_start+19, $pos_stop - $pos_start - 19 );
}
//artist
$SEARCHSUB='<div class="artist">';
//20 = strlen($SEARCHSUB);
$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
if( false !== $pos_start ) {
$SEARCHSUB='</div>';
$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start );
$radio_nova_artist = substr($htmldata, $pos_start+20, $pos_stop - $pos_start - 20 );
$pattern = '<a href';
if (preg_match("/<a href/", $radio_nova_artist)) {
$SEARCHSUB='> ';
$pos_start = strpos($radio_nova_artist, $SEARCHSUB, 0 );
if( false !== $pos_start ) {
$SEARCHSUB=' </a>';
$pos_stop = strpos($radio_nova_artist, $SEARCHSUB, $pos_start );
$radio_nova_artist = substr($radio_nova_artist, $pos_start+7, $pos_stop - $pos_start - 7 );
}
}
echo "<br>\n";
}
//url
$SEARCHSUB='<img src="';
//10 = strlen($SEARCHSUB);
$pos_start = strpos($htmldata, $SEARCHSUB, 0 );
if( false !== $pos_start ) {
$SEARCHSUB = '" alt="" title="" width="84"';
$pos_stop = strpos($htmldata, $SEARCHSUB, $pos_start );
$radio_nova_url = substr($htmldata, $pos_start+10, $pos_stop - $pos_start - 10 );
}
$metadata[0]=$radio_nova_artist;
$metadata[1]=$radio_nova_title;
$metadata[2]=$radio_nova_url;
return $metadata;
}
$DEBUG=0;
if( $DEBUG != 0 )
{
$tags = array();
$tags = get_fipradio_tags();
echo "[DEBUG] fipradio<br>\n";
echo "[DEBUG] artist : $tags[0]<br>\n";
echo "[DEBUG] title : $tags[1]<br>\n";
echo "[DEBUG] url : $tags[2]<br>\n";
echo "<br>\n";
$tags = get_lemouv_tags();
echo "[DEBUG] lemouv<br>\n";
echo "[DEBUG] artist : $tags[0]<br>\n";
echo "[DEBUG] title : $tags[1]<br>\n";
echo "[DEBUG] url : $tags[2]<br>\n";
echo "<br>\n";
$tags = get_fculture_tags();
echo "[DEBUG] fculture<br>\n";
echo "[DEBUG] artist : $tags[0]<br>\n";
echo "[DEBUG] title : $tags[1]<br>\n";
echo "<br>\n";
$tags = get_finter_tags();
echo "[DEBUG] finter<br>\n";
echo "[DEBUG] artist : $tags[0]<br>\n";
echo "[DEBUG] title : $tags[1]<br>\n";
echo "<br>\n";
$tags = get_fmusique_tags();
echo "[DEBUG] fmusique<br>\n";
echo "[DEBUG] artist : $tags[0]<br>\n";
echo "[DEBUG] title : $tags[1]<br>\n";
echo "<br>\n";
$tags = get_classic21_tags();
echo "[DEBUG] classic21<br>\n";
echo "[DEBUG] artist : $tags[0]<br>\n";
echo "[DEBUG] title : $tags[1]<br>\n";
echo "<br>\n";
$url = get_lgr_rock_url();
echo "[DEBUG] lgrrock : $url<br>\n";
echo "<br>\n";
$url = get_lgr_metal_url();
echo "[DEBUG] lgrmetal : $url<br>\n";
echo "<br>\n";
$url = get_lgr_reggae_url();
echo "[DEBUG] lgrreggae : $url<br>\n";
echo "<br>\n";
$tags = get_radio_nova_tags();
echo "[DEBUG] radio_nova<br>\n";
echo "[DEBUG] artist : $tags[0]<br>\n";
echo "[DEBUG] title : $tags[1]<br>\n";
echo "[DEBUG] url : $tags[2]<br>\n";
echo time();
}
?>