I'm trying to find a way to be (almost) sure that an URL is real video file.
I've of course check get_headers to check if URL exist and header content type :
function get_http_response_code($theURL)
{
$headers = get_headers($theURL);
return substr($headers[0], 9, 3);
}
function isURLExists($url)
{
if(intval(get_http_response_code($url)) < 400)
{
return true;
}
return false;
}
function isFileVideo($url)
{
$headers = get_headers( $url );
$video_exist = implode(',',$headers);
if (strpos($video_exist, 'video') !== false)
{
return true;
}
else
{
return false;
}
}
Maybe i answer to myself, but maybe there are other more robust solution ( for video type mainly) . Don't know if it's possible, but could i just download the file metadatas first and return the file related to this test ?
Thanks a lot !