YouTube iOS SDK: correct GTLQueryYouTube parameter

2019-03-01 15:22发布

I'm trying to find the right GTLQueryYouTube parameters to filter out videos which can't be played on mobile (in an iOS UIWebView). The videoEmbeddable and videoSyndicated params are too restrictive (they filter out all VEVO videos).

In our iOS app, we search for YouTube videos via GTLQueryYouTube, leaving the videoEmbeddable and videoSyndicated parameters blank.

This returns Vevo videos which are generally playable in the UIWebView. For example "Rihanna - Diamonds" (lWA2pjMjpBs) is playable. It can't be played in an embedded view.

Some videos, however can't be played. For example "Lana Del Rey - Gods and Monsters" (3BwfuFuYOWE) can't be played in the UIWebView. The YouTube page loads, but instead of playing the video I see an error "The content owner has not made this video available on mobile."

We want to filter out these non-playable videos when searching. The GTLQueryYouTube API only supports filtering for "videoEmbeddable" and "videoSyndicated", neither of which correctly filter out the Lana Del Rey video, but leave in the Rihanna video.

It seems like there's a missing filter parameter to filter out these types of videos. Inspecting the metadata doesn't reveal any noticeable difference between the Rihanna and Lana Del Rey videos.

Ideas?

标签: youtube-api
2条回答
唯我独甜
2楼-- · 2019-03-01 15:41

One possible solution (admittedly, not very elegant) is to make two GTLQueryYouTube calls:

  1. videoSyndicated off (or set to all): search for the keyword "VEVO" in the description field of GTLYouTubeSearchResultSnippet, return top search result

  2. videoSyndicated on (set to true): best search result (with appropriate filters of your choice).

If the first query returns a null result, then you assume that there is no VEVO video, and you use the next best playable video (2).

查看更多
Evening l夕情丶
3楼-- · 2019-03-01 15:44

In general there is no way to determine all playback restrictions using the API, unfortunately. We have a guide for API v2 here: http://apiblog.youtube.com/2011/12/understanding-playback-restrictions.html but no similar resource for v3 yet.

I'd recommend using the (videoEmbeddable and videoSyndicated) search restricts since this is what they're designed for. One approach is to take the user to m.youtube.com for playback of videos that are restricted from 3rd party apps. Alternatively, you can try to approach the content owner and persuade them to change the config of the content (since this is something YouTube enforces but does not configure).

About the videos you have listed specifically:

  1. lWA2pjMjpBs has autoplay disabled which may explain the problem you are seeing: http://gdata.youtube.com/feeds/api/videos/lWA2pjMjpBs?v=2&prettyprint=true. We don't return the autoplay restrict in v3 responses yet but will follow up with the team on that.
  2. 3BwfuFuYOWE has syndication disabled. In v2 you can see it here: http://gdata.youtube.com/feeds/api/videos/3BwfuFuYOWE?v=2&prettyprint=true, but in v3 we only expose it via a search restrict. I'll follow up with the team on this as well so it is easier to see that in the videos.list response.
查看更多
登录 后发表回答