The religious community that I’m in delves into media. In fact we have a website that showcases video and audio materials for free.
We use the ever popular video/media flash player made by Longtail Video to stream our mp3 and video files to be distributed and seen by people in the web.
As we host our mp3 files in mypodcast.com, the rss feed that is delivered my the site isn’t exactly compatible with the player – so I had to parse the rss feed and re encode it into an rss feed that the longtail player recognizes.
In order to not reinvent the wheel in reading rss feeds, I used the ever popular open source (BSD-licensed) php feed reader, simplepie.
Below this page is the quick and dirty code that I used. I hope this will help you get started in the world of podcasting!
<?
require_once('simplepie.inc');
$feed = new SimplePie(‘http://host/rss.xml’);
set_cache_location($_SERVER['DOCUMENT_ROOT'] . ‘/cache/’);
$feed->handle_content_type();
?>
rss feed name
get_items() as $item)
{
$title = $item->get_title();
$date = $item->get_date();
if ($enclosure = $item->get_enclosure())
{
$media = $enclosure->get_link();
$length = $enclosure->get_duration(true);
}
$subtitle = $item->subtitle;
$description = $item->get_description();
//print_r($enclosure);
$desc = explode(“”,”",$image);
echo ”
$title
$author
“;
}
?>
Heywatch is a cool video encoding web service that is being used by different clients like Sony, Fotolia, Kickapps, MTv, among others for their video conversion needs.
One nice thing about this service is that it has a REST based API that is simple to implement in php. However, the documentation that comes with heywatch shows only how to access the API using PEAR – this becomes a disadvantage if your shared hosted webhost doesn’t have PEAR installed. I also personally think that using PEAR just to call this api is basically overkill.
Why not use curl instead? I basically changed the PEAR functions in the API documentation to that of php curl functions (which are basically native and available in practically all shared php webhosting)
<?
$video_url = "http://osaddict.com/files/elephantsdream-480-h264-st-aac.mov";
$format_id = "1086"; // 1086 for flash h264, 31 for flash flv
$ftp = "ftp://username:password@ftphost.com";
$ping_after_encode = "http://host/heywatch/success.php?myvideoid=5&myuserid=1";
$ping_if_error = "http://host/heywatch/error.php";
$ch = curl_init();
$your_username = "";
$your_password = "";
$video_url,"format_id"=>$format_id,"automatic_encode"=>"true","ftp_directive"=>$ftp,"title"=>"My Video Title","keep_video_size"=>"true");
curl_setopt($ch, CURLOPT_USERPWD, $your_username.':'.$your_password);
curl_setopt($ch, CURLOPT_POSTFIELDS,$arr);
$data = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
exit;
} else {
curl_close($ch);
}
header(“Content-Type: text/xml;charset=UTF-8″);
header(“Pragma: no-cache”);
echo $data;
?>
What this code does is to download a video, convert it to h264 flash format, then upload it to a select ftp host in just one step (success.php and error.php are ping functions where the developer is notified if conversion was successful or not).
One thing to take note is that heywatch doesn’t like special characters in the ftp url, if you place such characters in the $ftp variable, heywatch upload fails.
Have fun!


