Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTube embed gives "restricted from playback on certain sites" error despite API metadata indicating otherwise

I am trying to have my client application filter out videos that do not allow embedding. My understanding here is that there is no way to limit the feed (i.e. format=5 is insufficient) to do this and that I must check the properties of the entry myself, for the <yt:accessControl> tag and the <app:control> and <yt:state> tags.

This isn't working for me.

For example, this video: https://www.youtube.com/watch?v=waxat-_tRH8

doesn't embed: https://www.youtube.com/embed/waxat-_tRH8

even though the API returned data indicates (as far as I can tell) that it should be able to embed: https://gdata.youtube.com/feeds/api/videos/waxat-_tRH8?v=2

The entry does not contain any <yt:noembed> tag (see prior question) and the <media:restriction type='country' relationship='deny'>ME DE RS</media:restriction> does not explain this since I am in the US (see prior question) (see prior question).

What am I missing here?

EDIT: The embed link above works in my web browser, but not in my client app's WebView....!?

like image 605
justin k. Avatar asked Nov 15 '12 22:11

justin k.


People also ask

Why is my embedded YouTube video not playing?

Other things you can try: Reload the video at a later point in time or immediately. Update the Adobe Flash Player. Upgrade your browser. Delete cache and cookies.

What does video embed restricted for this domain mean?

Embed restrictions effectively restrict video content from being loaded outside of the whitelisted web domains, IP addresses, and/or geo locations by country. If embed restrictions are enabled, only embed codes accessed from whitelisted domains, IP addresses and/or regions will successfully load the video content.


2 Answers

Certain videos have a domain-level whitelist or blacklist applied to them. This is done at the discretion of the content owner.

If there is a whitelist or a blacklist, and the domain of the embedding site can't be determined (perhaps because of there not being a real referring domain in the case of your native application), then the default behavior is to block playback.

This blog post has a bit more detail as well: http://youtube-eng.blogspot.co.uk/2011/12/understanding-playback-restrictions_28.html

like image 112
Jeff Posnick Avatar answered Oct 15 '22 16:10

Jeff Posnick


As Jeff Posnick pointed out, some videos have blacklists. If you try and request a video with a blacklist from an app and not a web page, you will see this error message:

"This video contains content from ___. It is restricted from playback on certain sites."

It's likely your app is NOT blacklisted, and that you're being blacklisted incorrectly. To fix this, you need to supply your Youtube API request with an origin (as atulkhatri pointed out).

In your request header for the Youtube video, set Referer to the domain in which you intend to be making the call from, (for ex. the domain of your app's corresponding website). If you don't have a domain, you could easily write some other domain, and that might work too.

  • For Android (Java), you can see an example here.

  • For iOS, look above

  • For React Native, you can use the origin prop on the component to your domain (origin is mentioned in the docs but doesn't tell you much about it).

  • Here is another example of the same issue in a browser when an extension blocked the Referer header from being sent for good measure.

This answer works for the V3 API of Youtube.

like image 21
Jake Avatar answered Oct 15 '22 18:10

Jake