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

ID and SIGNATURE with the proper values. But I don't get see any save or download window, 

instead A blank window.

I am in Macintosh platform with Safari browser. Help Appreciated.

Answer: 
Easiest way to grab information on a youtube video is to get the source from `http://youtube.com/get_video_info?video_id=XXXXXXXX`

I will use PHP as an example of handling this data. Using PHP's [parse\_str()](http://php.net/manual/en/function.parse-str.php) you can assign all variable of the string to a nice array of video info:

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

```

Then all the info is stored into **$ytarr**. Variables of interest would be "fmt\_list" and "fmt\_map" (which appear to contain the same thing afaik). This variable contains a list of available video formats in accordance to the chart here: <http://en.wikipedia.org/wiki/Youtube#Quality_and_codecs>

Assuming you know which of those formats you wish to download, you can then use the "fmt\_url\_map" variable (or **$ytarr['fmt\_url\_map']** in this example) to access the list of links to the desired format.

You can download videos of any format using those links, but they are subject to youtube's limited bandwidth (the optimal streaming speed youtube uses to save on bandwidth) so therefore the downloads won't be quite as fast as you would imagine. This leads me to believe that these links are best used for streaming rather than downloading, but I'm not aware of any alternative.
The internet is full of not working examples so here's a script for anyone who needs. Something is wrong with the flv files. Their links deliver .txt files but it's good with webm and mp4. I need that for the 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('/^[A-Z]+$/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;
            }
        }   
    }
?>  

```