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

自作多情 提交于 2019-12-04 08:29:10

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.

Be sure to have the "part" set correctly. It's a required field and you probably have "snippet there" and you need "contentDetails". (or "snippet,contentDetails" for both)

Example:

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


{
 "kind": "youtube#videoListResponse",
 "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/Xn7P-qyclepPOIFp9Bn69FdtR-4\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {

   "kind": "youtube#video",
   "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/_vu8XkjotVqxtJKQ2peTcRK8TYE\"",
   "id": "OoKpYXTmYak",
   "contentDetails": {
    "duration": "PT1M41S",
    "dimension": "2d",
    "definition": "hd",
    "caption": "false",
    "licensedContent": true,
    "regionRestriction": {
     "allowed": [
      "ES",
      "US"
     ]
    },
    "projection": "rectangular"
   }
  }
 ]
}

This is allowed in the US and Spain only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!