Via the Youtube API, how can I detect if a video Youtube is unavailable (ex : https://www.youtube.com/watch?v=5nRZlcB2jPY) ?
Thanks
The only thing you have to do is to paste the ID of any YouTube-video in the input field under the empty iframe below and then click on 'Check'. You'll instantly know whether or not the video is available for embedding.
If you consistently can't get a video to play, it's probably a problem with JavaScript or Flash, technologies that YouTube uses to make its site work. If you have JavaScript disabled, you won't be able to watch any YouTube videos. To see videos, go into your browser settings and allow JavaScript to run on YouTube.
This is also partially possible without API. Let's say you want to see if the following video is available:
https://www.youtube.com/watch?v=esDJPiGu5x0
The ID of the video is shown as the GET parameter v
. Use this one to request the following thumbnail:
https://img.youtube.com/vi/esDJPiGu5x0/0.jpg
If the content of the response has a length of 0 and/or the http response code by youtube.com is 404
, then the video is not available anymore.
You would make an API call for the video status.
https://www.googleapis.com/youtube/v3/videos?id=VIDEOID&part=status&key=APIKEY
Then check the uploadStatus in the json result:
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With