$flvThumbnail = $this->getParameter($ItemAddEmbedVideo, 'flvThumbnail');
/* Store other string constants we'll use later */
+
+ /* youtube */
$youtubeUrlPattern="youtube.com";
$youtubeApiUrl="http://www.youtube.com/api2_rest";
+
+ /* google */
$googleUrlPattern="video.google.com";
$googlePlayer="http://video.google.com/googleplayer.swf";
+
+ /* yahoo */
+ $yahooUrlPattern="video.yahoo.com";
+ $yahooThumbnailUrl="http://thmg01.video.search.yahoo.com/image/";
+
+ /* metacafe */
+ $metacafeUrlPattern="metacafe.com";
+ $metacafeThumbnailUrl="http://www.metacafe.com/thumb/";
/* Gallery2 specific paths and variables */
$urlGenerator =& $gallery->getUrlGenerator();
$description.= 'src="'.$googlePlayer.'?docId='.$doc_id.'"> ';
$description.= '</embed>';
$description.= "<br>$summary";
+
+ /*
+ **********************************
+ * Embed a Yahoo Video
+ **********************************
+ */
+ } else if(preg_match("/$yahooUrlPattern/",$url)) {
+
+ /* Make sure we can extract a vidID */
+ if(preg_match("/vid=(.*)/",$url,$matches)) {
+ $vid_id = $matches[1];
+ } else {
+ return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER,__FILE__,__LINE__,
+ "Unable to extract vid id from url: $url"),null,null);
+ }
+
+ /* Grab the contents of the webpage used to display the video on video.google.com */
+ list ($successfullyCopied, $contents, $response, $headers) =
+ GalleryCoreApi::fetchWebPage($url, $extraHeaders);
+ if (!$successfullyCopied) {
+ return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
+ "Unable to get video information at url: $url - $response"),NULL,NULL);
+ }
+
+ /* Extract the summary from the webpage contents */
+ preg_match('/Description:<\/em><p>(.+?)<\/p>/', $contents, $matches);
+ $summary=$matches[1];
+
+ /* Extract the title from the webpage contents */
+ $title="Unknown";
+ if(preg_match('/<title>(.+?)\s+- Yahoo! Video<\/title>/i', $contents, $matches)) {
+ $title=$matches[1];
+ } else if(preg_match('/<title>(.+?)<\/title>/i', $contents, $matches)) {
+ $title=$matches[1];
+ }
+
+ /* Build the thumbnail URL from the vid_id */
+ $thumbnail=$yahooThumbnailUrl.$vid_id."_01";
+
+ /* Format the description to hold a reference to the embedded video */
+ preg_match('/(<embed src.+?<\/embed>)/', $contents, $matches);
+ $description=$matches[1];
+ $description=preg_replace("/width='\d+'/","width='".$width."'",$description);
+ $description=preg_replace("/height='\d+'/","height='".$height."'",$description);
+ $description.= "<br>$summary";
+
+ /*
+ **********************************
+ * Embed a MetaCafe Video
+ **********************************
+ */
+ } else if(preg_match("/$metacafeUrlPattern/",$url)) {
+
+ /* Make sure we can extract a itemID */
+ if(preg_match("/\/watch\/(.+?)\/(.+?)/",$url,$matches)) {
+ $item_id = $matches[1];
+ } else {
+ return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER,__FILE__,__LINE__,
+ "Unable to extract item id from url: $url"),null,null);
+ }
+
+ /* Grab the contents of the webpage used to display the video on video.google.com */
+ list ($successfullyCopied, $contents, $response, $headers) =
+ GalleryCoreApi::fetchWebPage($url, $extraHeaders);
+ if (!$successfullyCopied) {
+ return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
+ "Unable to get video information at url: $url - $response"),NULL,NULL);
+ }
+
+ /* Extract the summary from the webpage contents */
+ preg_match('/<meta name="description" content="(.+?)" \/>/i', $contents, $matches);
+ $summary=$matches[1];
+
+ /* Extract the title from the webpage contents */
+ preg_match('/<title>(.+?)<\/title>/i', $contents, $matches);
+ $title=$matches[1];
+
+ /* Build the thumbnail URL from the item_id */
+ $thumbnail=$metacafeThumbnailUrl.$item_id.".jpg";
+
+ /* Format the description to hold a reference to the embedded video */
+ preg_match('/(embed src.+?\/embed)/', $contents, $matches);
+ $description="<".$matches[1];
+ $description=preg_replace("/"/","'",$description);
+ $description=preg_replace("/width='\d+'/","width='".$width."'",$description);
+ $description=preg_replace("/height='\d+'/","height='".$height."'",$description);
+ $description.= "</embed>";
+ $description.= "<br>$summary";
/*
**********************************
/* General debug output */
if(!strcmp($debugOutput,"true")) {
+ print "title: $title <br>";
print "<p><a href=\"".$title."\" target=\"_blank\">";
print "<img src=\"".$thumbnail."\">\n</a>".$summary."</p>";
print "<p>$description</p>";