Answer the question
In order to leave comments, you need to log in
How to check for broken links on YouTube videos?
Greetings
There are a lot of videos from video hosting sites on the site. Some of them exist, and some do not, have been removed or are not available. How can you check the availability of videos to do something with them - remove them from the code, for example? Maybe there are some programs or scripts? Checking manually is a long, unreasonable process, and over time, some of the videos may become inaccessible. How to automate the process?
Answer the question
In order to leave comments, you need to log in
More or less like this:
$url = 'http://www.youtube.com/get_video_info';
$params = [
'video_id' => '{%YOUTUBE_VIDEO_ID%}',
];
$response = file_get_contents($url . '?' . http_build_query($params));
// www.youtube.com/get_video_info?video_id={%YOUTUBE_VIDEO_ID%}
parse_str($response, $response);
switch ($response['status']) {
case 'ok':
echo 'OK';
break;
case 'fail':
echo 'FAIL';
break;
default:
echo 'UNKNOWN';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question