Youtube get_video not working

I used http://www.youtube.com/get_video?video_id=ID&t=SIGNATURE&fmt=18 replaced

ID and SIGNATURE with corresponding values. But I don’t see the save or load window,

Instead, an empty window.

I am on a Macintosh platform with a Safari browser. Help evaluate.

+2
source share
4 answers

The easiest way to capture information on YouTube videos is to get a source from http://youtube.com/get_video_info?video_id=XXXXXXXX

I will use PHP as an example of processing this data. Using PHP parse_str () , you can assign the entire string variable to a beautiful array of video information:

 $content = file_get_contents("http://youtube.com/get_video_info?video_id=".$id); parse_str($content, $ytarr); 

Then all information is stored in $ ytarr . The variables of interest will be fmt_list and fmt_map (which appear to contain the same afaik thing). This variable contains a list of available video formats according to the diagram here: http://en.wikipedia.org/wiki/Youtube#Quality_and_codecs

Assuming that you know which of these formats you want to download, you can use the fmt_url_map variable (or $ ytarr ['fmt_url_map'] in this example) to access the list of links in the desired format.

You can download videos of any format using these links, but they depend on the limited bandwidth of youtube (youtube uses the optimal streaming speed to save bandwidth), so downloading will not be as fast as you could imagine. This makes me think that these links are best used for streaming and not for downloading, but I don't know any alternative.

+16
source

The Internet is full of broken examples, so here is a script for anyone who needs it. Something is wrong with flv files. Their links deliver .txt files, but that's good with webm and mp4. I need this for pr0n sites too hehehe

 <?php //$debug = true; if(empty($debug)) $debug = false; if(empty($_GET['id'])) die('no id'); if(!preg_match('/^[A-Z0-9-_]+$/i', $_GET['id'])) die('invalid character in id'); else $id = $_GET['id']; if(empty($_GET['type'])) $type = 'mp4'; else if(!preg_match('/^[AZ]+$/i', $_GET['type'])) die('invalid character in type'); else $type = strtolower($_GET['type']); $url = 'http://youtube.com/get_video_info?video_id='; $key = 'url_encoded_fmt_stream_map'; $content = file_get_contents($url.$id); parse_str($content, $result); if($debug) { echo $url.$id.'<br/>'; echo $key.'<br/>'; echo $type.'<br/>'; echo '<pre>'; print_r($result); echo '</pre>'; } else { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="videofile.'.$type.'"'); } $type = 'type=video/'.$type; $files = explode(',url=', $result[$key]); $files[0] = substr($files[0], 4); for($i=0; $i<count($files); $i++) { $file = urldecode($files[$i]); $found = strpos($file, $type) > -1; if ($debug) { if ($found) echo '[THIS]'; echo '<a href="'.$file.'">'.$file.'</a><br/><br/>'; } else { if ($found) { $file = explode('; codecs=', $file); @readfile($file[0]); break; } } } ?> 
+6
source

youtube changed the request used to get the FLV file. Now it looks like

http://v2.lscache3.c.youtube.com/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0dYSVZMTl9FSkNNOF9ORlJF&909090909090909090909090909090.90&90&90&90&90&90&90&90&90&90&90&&&&&&&&&&&&&&&& for tree text; -factor & itag = 34 & ipbits = 0 & burst = 40 & sver = 3 & expire = 1294610400 & key = yt1 & signature = 9C4D194A7F85F0171771486714D3F061ED2924F6.98D10BB190123CADCA3CDF993174D47F893289562a = 1 factor

you can easily get all parameters except oc ie% 2Coc% 3AU0dYSVZMTl9FSkNNOF9ORlJF parameter from the answer, still looking for a way to get it.

youtube blocks the link to the browser, so you cannot use it on the server. if you look in the source code of the youtube page, you will find something similar to the above address, but without the oc parameter, if you copy it from the Firebug network panel or chrome resources, it will load the FLV movie as a “video game”.

+4
source

you are trying:

 $id = "111_fGEdIvs"; //the youtube video ID //$id = $_GET['id']; //$format = $_GET['fmt']; //the MIME type of the video. eg video/mp4, video/webm, etc. parse_str(file_get_contents("http://youtube.com/get_video_info?video_id=".$id),$info); //decode the data $streams = $info['url_encoded_fmt_stream_map']; //the video location info $streams = explode(',',$streams); parse_str(urldecode($streams[0]),$data); //In this example I am downloading only the first video $url=$data['url']; $sig=$data['signature']; unset($data['type']); unset($data['url']); unset($data['sig']); $urlPlay= str_replace('%2C', ',' ,$url.'&'.http_build_query($data).'&signature='.$sig); echo '<iframe class="youtube-player" type="text/html" width="640" height="385" src="'.$urlPlay.'" allowfullscreen frameborder="0" ></iframe>'; 
+1
source

Source: https://habr.com/ru/post/1335546/


All Articles