Determine whether a YouTube video cannot be embedded in a specific site - youtube

This YouTube video can be embedded into most sites (e.g., Stackoverflow), but it cannot be embedded into Rap Genius. You can try it yourself by pasting the embed code in to Rap Genius with firebug. You'll see this:
I need a way to detect whether a video is specifically blocked from Rap Genius.
Note that this is different from checking whether a video cannot be embedded anywhere – i.e., if you GET http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q=_kmeFXjjGfk, you'll see that in the JSON response, data.items[0].accessControl.embed == 'allowed'
One clue: before the video starts playing, the player makes a request to a URL that looks like this:
http://www.youtube.com/get_video_info?video_id=_kmeFXjjGfk&el=embedded&ps=default&eurl=http%3A%2F%2Frapgenius%2Ecom&hl=en_US
Which, when curled, gives this response:
status=fail&errorcode=150&reason=This+video+contains+content+from+UMG%2C+who+has+blocked+it+from+display+on+this+website.%3Cbr%2F%3E%3Cu%3E%3Ca+href%3D%27http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_kmeFXjjGfk%26feature%3Dplayer_embedded%27+target%3D%27_blank%27%3EWatch+on+YouTube%3C%2Fa%3E%3C%2Fu%3E&fslarge=1
So maybe I can just query this URL? Will this work in all cases? Is there an "official" way of doing this?

I had the error:
This video contains content from XXX
I noticed I was using https when requesting the page containing the embedded video. Switching back to http seems to have fixed the problem.

You have all the info in http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q=_kmeFXjjGfk
"status":{"value":"restricted","reason":"limitedSyndication"},"restrictions":[{"type":"country","relationship":"deny","countries":"DE"}]
March 19, 2013 -- Response is now quite different than that given above:
{"apiVersion":"2.1","data":{"updated":"2013-03-19T14:47:14.533Z","totalItems":0,"startIndex":1,"itemsPerPage":25}}

Related

Video Embeddable On Some Sites But Not Others

So I'm using the YouTube API to search for videos. With my search I'm including the following parameters: type = video, videoEmbeddable = true, videoSyndicated = true. But results that I'm getting can't be played on my site still. An example call I'm doing would be
https://www.googleapis.com/youtube/v3/search?part=snippet&q=Yellow+Claw&maxResults=25&type=video&videoSyndicated=true&videoEmbeddable=true&videoCategoryId=10&key=
But the results still give me an error when embedding stating that
This video contains content from ____. It is restricted from playback from certain sites or applications.
The part that really throws me off is that I've seen the exact same video embedded on another site.
Is there some sort of setting that I don't know about that needs to be changed? Is this call incorrect and is there something that I'm missing?
If you check this blog, it may help you identify which part of your code need to be fix or some changes.
There were 5 specified areas that you need to check, mainly
yt:accessControl
Geo Restrictions
yt:state
Rentals
Other Restrictions not Currently Exposed via the API
Check your codes base the restriction set by the YouTube API. For further reference, check this SO post.

For YouTube video, how to automatically display interactive transcript?

YouTube supports interactive-transcripts, using both machine-generated and user-uploaded transcripts. This is very useful for hearings, lectures, speeches, and educational videos where a visitor might want to read along or jump around. For example in this video:
https://www.youtube.com/watch?v=IY3U2GXhz44
The visitor can click on "...More" and then "Transcript" to view the interactive-transcript.
How does a video owner make that hidden feature automatically open for visitors? I cannot find any documented method for doing that through the API for either embed or linked videos. Is there an undocumented method in the API, or a URL parameter like "&action-panel-transcript=true" that works the way I'd expect it to?
As for url parameter, you can try adding &cc_load_policy=1 behind the rel=0 if it's an embedded video or &yt:cc=on at the end of the url if it's a link to the video.
Source: https://www.makeuseof.com/tag/force-subtitles-embedded-youtube-video/

Extract video id of preceding youtube advertisement

I'm writing a script that does stuff with the youtube advertisment videos that people have to watch before the actual videos. (These ad-vids at the start are just simple youtube videos from the brand's channel)
I've searched the whole source code and scripts, but I can't find the video id of those ads anywhere. It must be somewhere, but it seems to be hidden well.
Anybody got an idea where to look?
I did some research on your case.
The video id of the ad video is definitively not part of the initial source code, as you already figured out. Youtube makes an ajax-Request to the http://googleads.g.doubleclick.net/ API to get information about related ad videos.
If you take a look into the source code, you can see a lot of javascript that is related to the google ads part. By looking into the code, you can find URL routes to the API. See screenshot, it is just an excerpt:
But unfortunately you cannot simply copy the url and make a remote-call to it. By doing so, you get a 400 Bad Request response.
As i figured out, there are missing params, which are dynamically added by youtube's javascript.
If you compare the request, that is actually made by youtube, you can see that there are more params sent:
compared to the request, that is directly copied from source code:
The result of the working request looks like this:
I tried several ways to make the invalid API request work, but have not found a way. Debugging the javascript is not that easy, because its obfuscated and minified. But additionally the variables are scoped within the function. So anyways, you would not have access to them.
If you make a javascript breakpoint right before the XHR request, you can see the actual API request:
But it is within the Local scope, without access to it.
Later on, there is even a second request to the youtube data API to fetch information about the ad video
In my opinion, there are only two ways to get the video, both require javascript to run.
Look into the source code AFTER Javascript has run. Then you can get the id directly from your markup:
Hook onto the Ajax Requests and grab the data directly from your network traffic.

Why the link get from youtube get_video_info doesn't work for download?

I test with browser with the link I get from "http://www.youtube.com/get_video_info?&video_id=xx" to see if it is be able to download.
After remove some parameters from original link, some works but some still don't.
I read some post here but most of are pretty old. A lot of change since then.
I wonder if there are somebody working on this recently.
The purpose I need this is because my youtube view program need a better quality video to display.
This is link doesn't work:
http://r17---sn-tt17rn7e.c.youtube.com/videoplayback?fexp=902529%2C932000%2C906383%2C902000%2C919512%2C929903%2C931202%2C900821%2C900823%2C931203%2C931401%2C908529%2C919373%2C930803%2C906836%2C920201%2C929602%2C930101%2C930603%2C900824%2C910223&ipbits=8&expire=1364854787&sver=3&mt=1364829200&newshard=yes&id=26c94a41dba396f5&key=yt1&upn=GrcnDUPfreQ&cp=U0hVSVhQUl9NUUNONV9QSlZIOm9BbnVkMTJzOXE5&sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire&ip=173.248.214.165&itag=34&ms=au&source=youtube&mv=m&signature=9593596F58B377FAA4C8F5A4516C7F53CE473340.507CA2EA250CEED2E2B2377FD70EE1A0478EE322&type=video/mp4; codecs="avc1.42001E, mp4a.40.2"&itag=18&
What wrong with it? I removed fallback_path and replace sig with signature.
The working link is for webm. This is for h264. Both have the same kind of parameters.
And this is working now.
http://r17---sn-tt17rn7e.c.youtube.com/videoplayback?fexp=909708%2C912514%2C930802%2C932400%2C916624%2C931009%2C932000%2C906383%2C902000%2C919512%2C929903%2C931202%2C900821%2C900823%2C931203%2C931401%2C908529%2C930807%2C919373%2C906836%2C920201%2C929602%2C930101%2C930603%2C900824%2C910223&ms=au&itag=44&mt=1364825784&ipbits=8&cp=U0hVSVhQT19NUUNONV9QSlNCOlp5ZGoyMXJ3emlq&ip=173.248.214.165&upn=ohH0s8EjPyo&newshard=yes&source=youtube&ratebypass=yes&mv=m&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&id=26c94a41dba396f5&expire=1364851187&key=yt1&sver=3&signature=798EED35782B846D2B0EA190A17E837A0DBA18EA.AD56BCF6365AAD974C18F09F352F9422084C50AC&type=video/webm; codecs="vp8.0, vorbis"&quality=large,itag=35&
That's not a supported method of interacting with YouTube. You need to use one of the official YouTube Player mechanisms to display YouTube videos.
Please familiarize yourself with the YouTube API Terms of Service if you have any more questions.

xcode 4 stream video check

i am unable to solve this problem and i can´t find any solution elsewhere. I am playing the streaming video from url. But want to check if the url contains any video. Does anyone know how? To be clear i do not want to download the video and then play it. And yes i am checking the internet connection before, so i know if thre is internet or no. Is there any possible way how to check this? i just have URL with String ...i tried it with connection, but the page is connectablebut is blank with no content....:(
Thanks a lot for answer!=)
Now your question didn't say what kind of video you're trying to view, but my guess for the reason the video is blank with no content would be because your iPhone (or simulator) doesn't know how to play video with the encoding that the page contains.
Also, what kind of URL are you using? does it start with the standard http:// scheme, or is it something else like rtmp:// or rtsp:// or audio:// or?
If the URL starts with only http://, the only way that I can think of to check for a video stream is to download the html source from that page and scan through it looking for stream protocols (such as the ones I've listed above).

Resources