Guys, I have a question about whether something can be done or not, and if so, how:

Basically, I have been converting standard YouTube URLs in to a URL that will provide an .MP4 file. It's quite simple, as this blog post explains. Here is the JavaScript that this uses:

Code JavaScript:
if(document.location.href.match(/http:\/\/[a-zA-Z\.]*youtube\.com\/watch/)){
    document.location.href='http://www.youtube.com/get_video?fmt='+(isHDAvailable?'22':'18')+'&video_id='+swfArgs['video_id']+'
&t='+swfArgs['t']}

I have done some more work with this in PHP and come up with this:

Code PHP:
<?php
    /*
    Get YouTube MP4 URL from URL
    */
 
    $yt        = $_GET['yt'];
 
    if (eregi('([url]http://[a-zA-Z\.]*youtube\.com/watch[/url])', $yt)){    // Ensure provided URL is of valid format
        if (function_exists('curl_init')){
            $c = curl_init();
            curl_setopt ($c, CURLOPT_URL, $_GET['yt']);
            curl_setopt ($c, CURLOPT_VERBOSE, 0);
            curl_setopt ($c, CURLOPT_RETURNTRANSFER, 1);
            $content = curl_exec($c);
            if (curl_errno($c) <> 0) {
                echo 'Error reading page';
                echo curl_error($c);
                curl_close($c);
            }
            curl_close($c);
        } else {
            $content = file_get_contents($yt);
        }
 
        $pattern     = '<meta name="title" content="(.?)*">';
        preg_match($pattern, $content, $matches);
        $name        = substr($matches[0], 27, -1);
 
        preg_match('~var swfArgs = {(.*?)}~', $content, $match);
        $json = json_decode('{' . $match[1] . '}');
 
        $id        = $json->video_id;
        $t        = $json->t;
        $time    = $json->l;
 
        preg_match('~var isHDAvailable = (.*?);~', $content, $match);
 
        $isHDAvailable    = $match[1];
 
        if ($isHDAvailable == 'true'){
            $fmt    = 22;
        } else {
            $fmt    = 18;
        }
 
        echo "http://www.youtube.com/get_video?fmt=$fmt&video_id=$id&t=$t";
 
    } else {
        echo 'ERROR: Invalid URL Sent';
    }

This is probably far from the best way to do it, but it works. BUT, there is a problem now, as of yesterday, and I need to find a solution. Basically, the process goes something like this (the URLs expire BTW):

Original YouTube URL:
http://www.youtube.com/watch?v=fXSovfzyx28

Generated URL:
http://www.youtube.com/get_video?fmt=22&video_id=fXSovfzyx28&t=vjVQa1PpcFMjQlXllJCeP5DiV7QYy1m9UITV1iO3JkI=

Redirects to:
http://74.125.4.157/videoplayback?id=7d74a8bdfcf2c76f&itag=22&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag&ip=MY_IP_ADDRESS&signature=10BB16DCC90489488F341AFA99746AD4E2F834DA .C92D9B4C27F848E914CAC0AE80EAFD67FA8B1470&sver=3&expire=1238940802&key=yt1&ipbits=0

Recently it seems that YouTube have started to restrict access to the video to the IP of the machine that requested it. This means that if you make the JavaScript above in to a link and drag it to your shortcut bar that you can click it on the YouTube page and you will be prompted to download the video. It also means that if I run my script on my machine that I get a working URL, which I can use in other places on the web to allow me to download it, but nobody else can use it. Changing the IP is not good enough.

A solution? Well I figure that if I can have a file that acts as a proxy on my server, that requests the file, so my web server's IP is recorded, and then streams the video through, then anyone will be able to watch the video. But is this feasible, and if so, how do I do it?

Many thanks for your help guys