2
votes

Is there any way to filter country restricted video from PlaylistItems using YouTube API V3?

Basically I am displaying a list of videos from a playlist in the android app but in the playlist some of the videos are restricted for some countries so I want to exclude those videos from the list.

Please note that I want to exclude video from PlaylistItems.

1
as per documentation youtube only provides that regionCode restriction for search list .. for more details .. developers.google.com/youtube/v3/docs/search/listMadhav Anadkat

1 Answers

0
votes

Although the PlayListItems API call doesn't allow what you want, you can still do a Videos:List call for the contentDetails on each video ID before playing it. If the contentDetails section has regionRestrictions, you can check those for the regions you wish to exclude.

Example call: https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=[VIDEO_ID]&key=[API_KEY]

It will look something like this for you to parse:

"contentDetails": { "duration": "PT4M4S", "dimension": "2d", "definition": "hd", "caption": "true", "licensedContent": true, "regionRestriction": { "blocked": [ "PK", "IN", "BT", "BD", "NP", "LK" ] },