youtube-api

Know if a video Youtube is unavailable with the API


Via the Youtube API, how can I detect if a video Youtube is unavailable (ex : https://www.youtube.com/watch?v=5nRZlcB2jPY) ?

Thanks


Solution

  • 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
    }