How to create a podcast from YouTube

For a while YouTube has been making its videos available as downloadable MP4 files. Here is how you can change a regular YouTube RSS feed into an MP4 video podcast.

You will need a server or webspace that supports PHP. Create a PHP file containing the following:

<?php
if ($_GET["source"]=="youtube") {
if ($_GET["user"]!="") {
$url = "http://gdata.youtube.com/feeds/base/users/".$_GET["user"]."/uploads?alt=rss&v=2&orderby=published";
} else if ($_GET["q"]!="") {
$url = "http://gdata.youtube.com/feeds/base/videos?q=".urlencode($_GET["q"])."&alt=rss&v=2&orderby=published";
}
}
if ($url!="") {
$xml = file_get_contents($url);
$items = explode("<item>",$xml);
$output = $items[0];
for ($i=1;$i<count($items);$i++) {
$tmp = explode("http://www.youtube.com/watch?v=",$items[$i]);
$tmp = explode("\"",$tmp[1]);
$tmp = $tmp[0];
$output.= "<item><enclosure url=\"http://www.youtubemp4.com/video/".$tmp.".mp4\" type=\"video/mp4\"/>".$items[$i];
}
echo $output;
}
?>

Video podcast of a certain YouTube user:

http://your.file.name?source=youtube&user=USERNAME

Video podcast based on a search on YouTube:

http://your.file.name?source=youtube&q=SEARCH+THIS

This script makes use of a site named youtubemp4.com which spits out the MP4 file of any given YouTube video.