array( 'header'=>array("Referer: ".$referer.PHP_EOL), 'timeout' => 5 ) ) ); /////////////////////////// // LOAD RADIO PAGE INTO PARSER $ontheair = file_get_contents($radiourl); // JSON CONTENT $ontheair = utf8_encode($ontheair); $obj = json_decode($ontheair, true); // GET TRACK INFO: ADAPT WITH DATA STRUCTURE // ADPAPT HERE $current = $obj['data']['now']['playing_item']; // GET TRACK INFO if ( $current ) { // ADPAPT HERE $artist = ucwords(strtolower($current['title'])); $title = ucwords(strtolower($current['subtitle'])); if ( $debug != 0 ) $ERR .= "\nTITRE = ".print_r($title, true); if ( $debug != 0 ) $ERR .= "\nARTISTE = ".print_r($artist, true); } /////////////////////////// // PREPARE COPY COMMAND $cmd = $RADIO.'|'.$artist.'|'.$title; /////////////////////////// // DEBUG OR PROD if($debug == 1) { print_r($obj); print_r($cmd); } else { if( $artist != "" && $title != "" ) { // TODO Clean strings?! if (! exec('grep '.escapeshellarg($cmd).' /tmp/ytdl.list')) { file_put_contents("/tmp/youtube-dl.log", "ARTIST: ".$artist.". SONG: ".$title, FILE_APPEND); file_put_contents("/tmp/ytdl.list","$cmd\n", FILE_APPEND); } else { file_put_contents("/tmp/youtube-dl.log", "ALREADY THERE!", FILE_APPEND); file_put_contents("/tmp/ytdl.list","||".PHP_EOL, FILE_APPEND); } } else { file_put_contents("/tmp/youtube-dl.log", "NO TRACK. TRY PODCAST!", FILE_APPEND); file_put_contents("/tmp/ytdl.list","||".PHP_EOL, FILE_APPEND); } } ?>