Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use YouTube API to check if a video is restricted?

When embedding this YouTube video for example, we get This video contains content from... who has blocked it from display on the website error message.

How can I use the API to find if a video is blocked or not?

The nearest parameters I found are status and contentDetails:

GET https://www.googleapis.com/youtube/v3/videos?part=status&id=dYQ2IyMuPes&key={YOUR_API_KEY}

Which returns no indication about the restriction:

   "contentDetails": {
    "duration": "PT2M",
    "dimension": "2d",
    "definition": "hd",
    "caption": "false",
    "licensedContent": true,
    "projection": "rectangular"
   },
   "status": {
    "uploadStatus": "processed",
    "privacyStatus": "public",
    "license": "youtube",
    "embeddable": true,
    "publicStatsViewable": false
   }
like image 894
Ronen Teva Avatar asked Oct 29 '22 22:10

Ronen Teva


1 Answers

Check if it is restricted in the region contentDetails.regionRestriction or age-restricted content contentDetails.contentRating or content claimed by partner contentDetails.licensedContent? I am just speculating here too.

Edit: You can use this to check if it is embeddable too status.embeddable.

like image 188
Stranger26 Avatar answered Jan 02 '23 21:01

Stranger26