Is there a way with v3 of the YouTube API to check if a video has an age restriction on it? Looking at the documentation I've been unable to confirm this.
I found something related to this,check
https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id={VIDEO_ID}&key={YOUR_API_KEY}
replace VIDEO_ID with the id of video you want to check.
API Response:
{
"kind": "youtube#videoListResponse",
"etag": "\"mPrpS7Nrk6Ggi_P7VJ8-KsEOiIw/el3Y0P65UwM366CJD3POX-W4y0c\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"mPrpS7Nrk6Ggi_P7VJ8-KsEOiIw/Rn64PVwC0Uhr4xp41vDOqygjJ9c\"",
"id": "VIDEO_ID",
"contentDetails": {
"duration": "PT10M6S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": false,
"contentRating": {
"ytRating": "ytAgeRestricted"
}
}
}
]
}
Check the ytRating, it has value ytAgeRestricted, means the video is age restricted.
From Youtube-API docs:
contentDetails.contentRating.ytRating : string
A rating that YouTube uses to identify age-restricted content.
Valid values for this property are: ytAgeRestricted
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