Can't Download from youtube - url

I have a script that downloads mp4 files from youtube. What it does is to generate link of the form http://youtube.com/get_video?video_id=*VIDEO_ID*&&t=*THE_TOKEN*=&fmt=18&asv=2, but it doesn't work anymore (noticed it today). What do you think?

Instead of trying to use get_video to get the video, try parsing fmt_url_map (format-url map) instead.
You should be able to find the fmt_url_map in the same place you found the token (like in the flashvars of the YouTube flash video player or inside the YouTube page somewhere). If you can't find it, send a request to http://www.youtube.com/get_video_info?video_id=VIDEO_ID and you should get a really long result that is in the format of name=value&name=value&... Find "fmt_url_map" inside this result (search through the result for a string that starts with "&fmt_url_map=" and ends with "&").
After you get this value (you may have to url-decode it), it will be something like (without the line breaks):
22|http://blah.youtube.com/videoplayback?blah,
35|http://blah.youtube.com/videoplayback?blah,
...
where each comma-separated entry starts with the fmt value (22 or 35 in the example), followed by a pipe character, which is then followed by the URL where you can use to download the video in that format. (This URL is client-specific, so a URL for a certain client most likely won't work with another client due to YouTube checking IPs. Also, the URLs do expire after a while.)
For a list of the different fmt values, see: http://en.wikipedia.org/wiki/YouTube#Quality_and_formats and show the "Comarison of YouTube media encoding options". NOTE: not all formats may be available for all videos.
Deprecated: won't work anymore!

If you want to download to a server you can use youtube-dl which still works.

Well it seems like they have removed the fmt option. See http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs.

I've created a node.js server that can stream YouTube videos directly to the client and it works. See https://github.com/licson0729/node-YouTubeStreamer for details.

Related

Closed Captions in YouTube as JSON

Is there a way to get closed captions in a youtube clip as json ? I read passing "alt=json" should work, but it doesn't seem to. Any idea ? Also does the CC also work when it is done via translation ? For example
curl "http://www.youtube.com/api/timedtext?v=V6Tsrg_EQMw&lang=en" doesn't return anything (though the clip does have CC)
There currently is no supported API for retrieving closed caption tracks for arbitrary videos. (You might be able to reverse-engineer some methods of getting that data, but it's not supported and I can't encourage doing that.)
The officially supported methods for working with captions are for v2 of the YouTube Data API and are documented at https://developers.google.com/youtube/2.0/developers_guide_protocol_captions
Only an authenticated request as the owner of a given video will expose the list of caption tracks and allow you to download them in .srt or .sub format (not JSON).
I would expect that at some point there will be methods for interacting with captions in v3 of the API, but unfortunately I don't have any specific information to share about when that might happen.
Use youtube-dl to download the captions (as either srt, ass, vtt, or lrc).
Use TranscribeFiles' Online Captions & Subtitles Converter to convert to any of 11 different json schemas.

How to get video download link from youtube?

I searched far and wide and came up with nothing.
Ok, that is not completely true, there are in fact tons of solutions on the Internet (even here on stackoverflow) on how to get a download link for youtube video, but not a single one of them is working anymore, since youtube seems keep changing things all the time.
What I want to do, is to write a PHP script which will be able to download video from specified youtube page and then save it on the server in flv or mp4 format.
I can get some video information by downloading this: http://www.youtube.com/get_video_info?&video_id=VIDEO_ID
But thats about it, no matter what I do, I just cannot figure out how find the link pointing to the video download.
I tried to use this link: http://youtube.com/get_video?video_id=VIDEO_ID&t=TOKEN&fmt=18&asv=2 from one more recent solution I found, but either there is something missing in it, or it's completely outdated already too.
So how can I dig out some working link for direct video download from youtube?
There has to be some way to do it, since there are some web pages out there which provide this service.
Thank you for any advices.
I prefer RealPlayer to download videos from youtube and other video sharing sites like metacafe, funnyordie and others. You're able to download in both mp4 or flv format, save them, and view them whenever you'd like.. even if you're not online which is great for travel. http://www.real.com/realdownloader

Youtube upload api duplicated video (get the right ID)

When a video is duplicated (let's say v = GgVH5fXXYSE) , is there a way i can find the videoid of the "good" one (the one that should work) with the duplicated id.
(so with GgVH5fXXYSE i could find eNqZgEgOfsw)
Thanks!
Unfortunately, there's no way to get this information. It's come up as a feature request a number of times in the past, and there are technical reasons why this can't be exposed in the YouTube Data API response.
If you have APP, that solely uploads file to particular (authorized) youtube account(s), then you can get it done using following method. Maintain a hash of all input files and while uploading file, check ,if you have old file having same hash as current file upload, and that old file was uploaded successfully, then don't upload that file and use youtube link = old file's ( having same hash as current file) youtube link.

Retrieving a YouTube Disco playlist

YouTube has this cool thing that creates a "smart playlist" from some starting keywords. I would like to programmatically access the playlist. I've found the YouTube data API but it doesn't discuss the "disco" feature.
One of the answers below suggests using
http://www.youtube.com/disco?action_search=1&query=XXXXXXXXX
that will return some JSON with the first video to be played, and a list property. Unfortunately, the list is a 32-character hex string, whereas normal playlist ID's are 16-character hex strings. This means that the standard data API to retrieve the full playlist doesn't work.
Any suggestions?
First, I must say I I never used youtube data API, so I don't know how useful below information will be.
Let me use an example:
I wanted to create Smashing Pumpkins. I typed the artist name and clicked the "Disco!" button. Using Fiddler2 I figured out the requested url was:
www.youtube.com/disco?action_search=1&query=smashing%20pumpkins
Notice, that spaces are replaced with %20. As a response i got simple JSON response:
{"url": "\/watch?v=bhMz7x1ZaGM\u0026feature=disco\u0026playnext=1\u0026list=MLGxdCwVVULXe5-F4X_zm6wnblRsnXoPJS"}
It was a link to the first song of freshly generated Smashing Pumpkins playlist, which address was list=MLGxdCwVVULXe5-F4X_zm6wnblRsnXoPJS. All you have to do know is replacing \u0026 with & and you get a valid link.
I assume the rest magic you want to do is available via official youtube data API.
I hope my research will help you.
EDIT
Well, it looks like this playlist generated by youtube/disco is not the same type of playlist that users can generate and that is available via API. The list ID is longer than usuall and when you click "More info about playlist" you are redirected to artists profile. Based on this two facts, i guess it's impossible to retrive generated lists via API. Sorry.
#Randomblue, how exactly do you want to retrieve this playlist?
You can use the 32 char hex in this url to get a page detailing the playlist
https://www.youtube.com/playlist?list={HEX}
or in an embed playlist iframe, like this:
<iframe width="853" height="480" src="//www.youtube.com/embed/videoseries?list={HEX}" frameborder="0" allowfullscreen></iframe>

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

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}}

Resources