0
votes

I want to filter out non-embeddable videos from Youtube Playlist API like I do in search API.

I am using videoEmbeddable=true for search api like "https://www.googleapis.com/youtube/v3/search?part=snippet&q=(searchText)&type=video&maxResults=20&videoEmbeddable=true&key=(YTApiKey)" and it's working fine.

But how do I do the same in Playlist API?

"https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,status&maxResults=50&playlistId=(id)key=(YTApiKey)".

The param videoEmbeddable=true doesn't seem to work on playlistItems API.

Please help & thanks in advance.

2

2 Answers

2
votes

It can be done with some extra steps. As noted, PlaylistItems does not accept that parameter and does not contain the embeddable data in the status part, so we have to make an additional call to Videos:List for it.

  1. Grab all the Video IDs from your call to PlayListItems.
  2. Use them in a call to Videos:List with the part 'status', up to 50 video IDs at a time.

Example for 3 video IDs:

GET https://www.googleapis.com/youtube/v3/videos?part=status&id=Ks-_Mh1QhMc%2Cc0KYU2j0TM4%2CeIho2S0ZahI&key={YOUR_API_KEY}
  1. Then check each item's status for the embeddable field set to true.

    "status": { "uploadStatus": "processed", "privacyStatus": "public", "license": "youtube", "embeddable": true, "publicStatsViewable": true }

0
votes

I don't think it can be done, since playlists are collection of videos and some of the videos in the collection might be embeddable and some might be for instance.

After getting playlists from the API you could make queries for videos contained in the playlist to see if a given video is embeddable or not...