How do I filter videos from YouTube Data API v3 that are restricted from mobile playback without filtering out Vevo too?

有些话、适合烂在心里 提交于 2019-12-03 09:19:45

问题


I'm creating an Android app using the YouTube Data API v3. So far so good until I realized that a great many videos do not play.

I get "Content from holder is blocked in your country on copyright grounds"....

I googled and it seems the way to deal with this is to use the version 3 YouTube.Search.List object and to set:

search.setVideoSyndicated("true");

Unfortunately this is far too restrictive. All Vevo videos and who knows what else disappear from the results even though those played fine.

I already have search.setVideoEmbeddable("true") so that is not a variable of interest in this equation.

Now I should add I have poured over the documentation and ended up finding this:

https://developers.google.com/youtube/2.0/developers_guide_protocol_partial?csw=1#Retrieving_Videos_for_Mobile_Playback

... which says:

Retrieving videos for playback on mobile devices

To ensure that an API response only contains videos that are suitable for playback on a mobile device, set the fields parameter to the following value. Note that the hash character (#) that appears in the parameter value must be escaped (%23).

fields=entry[link/@rel='http://gdata.youtube.com/schemas/2007%23mobile']

If you are developing an application for mobile devices, you may also want to specify the mobile projection in API requests.

....

Ok... so even though this is only applicable(?) for API version 2.0 I figured, "what the hey... I'm a curious guy..." and I created the following test URL and ran it through Firefox to view the XML payload.

https://gdata.youtube.com/feeds/mobile/videos?q=RIHANNA&max-results=50&fields=entry[link/@rel=%27http://gdata.youtube.com/schemas/2007%23mobile%27]

Well... this does work. Note the "/mobile/" is known as "projection" in the documentation and would normally be "/api/" in the common endpoint.

Now when I say, "this does work" that means I get XML back that does indeed filter out the videos that were getting the "blocked on copyright grounds" playback error.

However a search on P!NK or Rihanna or (insert pop artist du jour here) yields AWFUL results.

My headache worsens: YouTube's official mobile app for Android does INDEED display YouTube Vevo stuff as when I do not set syndicated to true AND they do not display all the myriad videos blocked in my country on copyright grounds.

Now I am in the Big Apple USA so let's not take the "your country" stuff to imply I am in some unfortunate burg.

So in a nutshell something is rotten in the YouTube Data API when attempting to create an acceptable mobile UX or I am missing something. I hope it is the latter and someone can tell me how to use YT Data API v3 to get Vevo (the baby) and lose the six zillion "blocked in your country on copyright grounds" (bathwater) results.

This issue seems to be long standing but also a "niche" area and it simply makes no sense that Google would tell their API developer community to use the syndicated attribute which removes all content from their partners like Vevo who seem to want their content played on mobile. The player API for Android does show ads for these so it is a monetized revenue stream after all.

Anybody here can enlighten me as to what I am missing from this equation or is this just something no one at Google is aware of or deems high enough priority to remedy? I am new to version 3 of the API so maybe I'm just ignorant of something key.

来源:https://stackoverflow.com/questions/21176722/how-do-i-filter-videos-from-youtube-data-api-v3-that-are-restricted-from-mobile

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