Fixed google video thumbnail parsing pattern
[embedvideo/.git] / ItemAddEmbedVideo.inc
index 7ef877ed842a6e270f241eb722ba105c0764ed13..bfb8daab44028f339ca27a5d45fcf621bc1b8829 100644 (file)
@@ -118,7 +118,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
           /* Store other string constants we'll use later */
          
           /* youtube */
-          $youtubeUrlPattern="youtube.com";
+          $youtubeUrlPattern="youtube";
           $youtubeApiUrl="http://gdata.youtube.com/feeds/api/";
           $youtubeThumbnailUrl="http://img.youtube.com/vi/";
           /* We can't extract the server size from youtube */
@@ -126,43 +126,43 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
           $youtubeHeight="350";
 
           /* google */
-          $googleUrlPattern="video.google.com";
+          $googleUrlPattern="video.google";
           $googlePlayer="http://video.google.com/googleplayer.swf";
           /* We can't extract the server size from google video */
           $googleWidth="400";
           $googleHeight="326";
           
           /* yahoo */
-          $yahooUrlPattern="video.yahoo.com";
+          $yahooUrlPattern="video.yahoo";
           $yahooThumbnailUrl="http://thmg01.video.search.yahoo.com/image/";
           
           /* metacafe */
-          $metacafeUrlPattern="metacafe.com";
+          $metacafeUrlPattern="metacafe";
           $metacafeThumbnailUrl="http://www.metacafe.com/thumb/";
 
           /* revver */
-          $revverUrlPattern="revver.com";
+          $revverUrlPattern="revver";
           $revverThumbnailUrl="http://frame.revver.com/frame/120x90/";
 
           /* dailymotion */
-          $dailymotionUrlPattern="dailymotion.com";
+          $dailymotionUrlPattern="dailymotion";
           $dailymotionThumbnailUrl="http://www.dailymotion.com/thumbnail/160x120/video/";
 
           /* divshare */
-          $divshareUrlPattern="divshare.com";
+          $divshareUrlPattern="divshare";
           $divshareThumbnailUrl="http://www.divshare.com/direct/video_thumb/";
 
           /* stickam */
-          $stickamUrlPattern="stickam.com";
+          $stickamUrlPattern="stickam";
           $stickamThumbnailUrl="http://static.stickam.com/";
 
           /* myspace */
-          $myspaceUrlPattern="vids.myspace.com";
-          $myspaceUrlPattern2="myspacetv.com";
+          $myspaceUrlPattern="vids.myspace";
+          $myspaceUrlPattern2="myspacetv";
           $myspaceThumbnailUrl="http://mediaservices.myspace.com/services/rss.ashx?type=video&videoID=";
 
           /* vimeo */
-          $vimeoUrlPattern="www.vimeo.com";
+          $vimeoUrlPattern="vimeo.com";
           
           /* Gallery2 specific paths and variables */
           $urlGenerator =& $gallery->getUrlGenerator();
@@ -331,7 +331,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
               }
 
               /* Extract the thumbnail URL from the webpage contents */
-              preg_match('/thumbnail: \'(http:\/\/.*?\/ThumbnailServer2.+?)\'/i',
+              preg_match('/\'(http:\/\/.*?\/ThumbnailServer2.+?)\'/i',
                          $contents, $matches);
               $thumbnail=$matches[1];
               $thumbnail=preg_replace("/\\\\x26/","&",$thumbnail);
@@ -372,7 +372,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                                "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 */
+              /* Grab the contents of the webpage used to display the video */
               list ($successfullyCopied, $contents, $response, $headers) =
                 GalleryCoreApi::fetchWebPage($url, $extraHeaders);
               if (!$successfullyCopied) {
@@ -422,7 +422,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                                "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 */
+              /* Grab the contents of the webpage used to display the video */
               list ($successfullyCopied, $contents, $response, $headers) =
                 GalleryCoreApi::fetchWebPage($url, $extraHeaders);
               if (!$successfullyCopied) {
@@ -475,7 +475,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                                "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 */
+              /* Grab the contents of the webpage used to display the video */
               list ($successfullyCopied, $contents, $response, $headers) =
                 GalleryCoreApi::fetchWebPage($url, $extraHeaders);
               if (!$successfullyCopied) {
@@ -533,7 +533,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                                "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 */
+              /* Grab the contents of the webpage used to display the video */
               list ($successfullyCopied, $contents, $response, $headers) =
                 GalleryCoreApi::fetchWebPage($url, $extraHeaders);
               if (!$successfullyCopied) {
@@ -583,7 +583,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                                "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 */
+              /* Grab the contents of the webpage used to display the video */
               list ($successfullyCopied, $contents, $response, $headers) =
                 GalleryCoreApi::fetchWebPage($url, $extraHeaders);
               if (!$successfullyCopied) {
@@ -632,7 +632,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                                "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 */
+              /* Grab the contents of the webpage used to display the video */
               $url=preg_replace("/&/","&",$url);
               list ($successfullyCopied, $contents, $response, $headers) =
                 GalleryCoreApi::fetchWebPage($url, $extraHeaders);
@@ -660,7 +660,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
               }
 
               /* Format the description to hold a reference to the embedded video */
-              if(preg_match('/input type.+?'.$item_id.'.+?value="(.+?)"/', $contents, $matches)) { 
+              if(preg_match('/readonly value="(.+?)"/', $contents, $matches)) { 
                 $description=$matches[1];
                 $description=preg_replace("/"/","'",$description);
                 $description=preg_replace("/&lt;/","<",$description);
@@ -690,7 +690,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                                "Unable to extract video id from url: $url"),null,null);
               }
 
-              /* Grab the contents of the webpage used to display the video on video.google.com */
+              /* Grab the contents of the webpage used to display the video */
               list ($successfullyCopied, $contents, $response, $headers) =
                 GalleryCoreApi::fetchWebPage($url, $extraHeaders);
               if (!$successfullyCopied) {
@@ -760,7 +760,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                                "Unable to extract video id from url: $url"),null,null);
               }
 
-              /* Grab the contents of the webpage used to display the video on video.google.com */
+              /* Grab the contents of the webpage used to display the video */
               list ($successfullyCopied, $contents, $response, $headers) =
                 GalleryCoreApi::fetchWebPage($url, $extraHeaders);
               if (!$successfullyCopied) {
@@ -798,18 +798,19 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
               }
 
               /* Format the description to hold a reference to the embedded video */
-              $description = '<object type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'"';
-              $description.= 'data="http://www.vimeo.com/moogaloop.swf?clip_id='.$video_id;
-              $description.= '&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1'.$autoStartStr;
-              $description.= '&amp;show_byline=1&amp;show_portrait=0&amp;color=">';
-              $description.= '<param name="quality" value="best" />';
+              $description = '<object width="'.$width.'" height="'.$height.'">';
               $description.= '<param name="allowfullscreen" value="true" />';
-              $description.= '<param name="scale" value="showAll" />';
-              $description.= '<param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id='.$video_id;
-              $description.= '&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1'.$autoStartStr;
-              $description.= '&amp;show_byline=1&amp;show_portrait=0&amp;color=" />';
-              $description.= '</object>';
-              
+              $description.= '<param name="allowscriptaccess" value="always" />';
+              $description.= '<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='.$video_id;
+              $description.= '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;'.$autoStartStr;
+              $description.= 'show_portrait=0&amp;color=&amp;fullscreen=1"/ >';
+              $description.= '<embed src="http://vimeo.com/moogaloop.swf?clip_id='.$video_id;
+              $description.= '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;'.$autoStartStr;
+              $description.= 'show_portrait=0&amp;color=&amp;fullscreen=1"';
+              $description.= 'type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always"';
+              $description.= 'width="'.$width.'" height="'.$height.'">';
+              $description.= '</embed></object>';
+                              
           /*
            **********************************
            * Embed a remote .swf file
@@ -1023,7 +1024,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
            */   
           if($unsupported_url == 1) {
               return array(GalleryCoreApi::error(ERROR_UNSUPPORTED_FILE_TYPE,__FILE__,__LINE__,
-                           "Unable to embed video from: $url"),null,null);
+                           "The URL you have supplied is unsupported (check the list of supported URLs, they must match exactly). You tried to embed a video from this url: $url"),null,null);
           }