<?php
class MediaSites_CBSNews
{
public static function buildEmbed($mediaKey, array $site)
{
// CAPTURE WEB PAGE
$pageHtml = file_get_contents('http://www.cbsnews.com/video/watch/?id=' . $mediaKey);
// ISOLATE THE VIDEOID IN THE SOURCE
if(preg_match('/[^\w]CBSVideo\.setVideoId\("(?P<videoid>[^"]+)"\);/siU', $pageHtml, $match))
{
// DEFINE GENERIC EMBED HTML WITH REPLACEMENT VARIABLES __VIDEOID__ AND __MEDIAKEY__
$embedHtml = '<embed src="http://cnettv.cnet.com/av/video/cbsnews/atlantis2/cbsnews_player_embed.swf" scale="noscale" salign="lt" type="application/x-shockwave-flash" background="#333333" width="425" height="279" allowFullScreen="true" allowScriptAccess="always" FlashVars="si=254&&contentValue=__VIDEOID__&shareUrl=http://www.cbsnews.com/video/watch/?id=__MEDIAKEY__" />';
// MAKE THE REPLACEMENTS
$finalHtml = str_replace(array('__VIDEOID__', '__MEDIAKEY__'), array($match['videoid'], $mediaKey), $embedHtml);
// RETURN THE FINISHED HTML
return $finalHtml;
}
// RETURN NOTHING IF NO MATCH
return '';
}
}