+
+ /*
+ **********************************
+ * 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";