Hi, I’ve a big table with thousands of mp3 links. Sice these links come from an old database, many of them are old and expired. Here is a function that I’ve included in my Minibots Class. The function uses checkdnsrr to verify the domain and then uses curl to fetch the mp3 file and verify the mime type. I’ve used checkdnsrr first because it seems faster.
function checkMp3($url) { if (!function_exists("curl_init")) die("getHttpResponseCode needs CURL module, please install CURL on your php."); $a = parse_url($url); if(checkdnsrr(str_replace("www.","",$a['host']),"A") || checkdnsrr(str_replace("www.","",$a['host']))) { $ch = @curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $results = explode("\n", trim(curl_exec($ch))); $mime = ""; foreach($results as $line) { if (strtok($line, ':') == 'Content-Type') { $parts = explode(":", $line); $mime = trim($parts[1]); } } return $mime=="audio/mpeg"; } else { return false; } }