New release 1.1.1:
[embedvideo/.git] / ItemAddEmbedVideo.inc
index b2a4539dcd45e107c56f12fda9fee21381eb3462..7ef877ed842a6e270f241eb722ba105c0764ed13 100644 (file)
@@ -191,6 +191,8 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                   $extra_params = $matches[2];
               } else if (preg_match("/watch\?v=(.*)/",$url,$matches)) {
                   $video_id = $matches[1];
+              } else if (preg_match("/v\/(.*)/",$url,$matches)) {
+                  $video_id = $matches[1];
               } else {
                   return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER,__FILE__,__LINE__,
                                "Unable to extract video id from url: $url"),null,null);
@@ -715,12 +717,21 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
               if(preg_match('/thumbnail url="(.+?)"/',$video_info, $matches)) {
                 $thumbnail = $matches[1];
               } else {
-                return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
-                       "Unable to extract thumbnail information from url: $url"),NULL,NULL);
+                 /*
+                  * Set the thumbnail to some generic jpg image,
+                  * since we can't extract it from the site.
+                  * If no parameter is set, set it to a default value.
+                  */
+                if(preg_match("/\w+/", $flvThumbnail)) {
+                  $thumbnail = $flvThumbnail;
+                } else {
+                  $thumbnail = $gallery2_url.$gallery2_flv_thumbnail;
+                }
               }
 
               /* Format the description to hold a reference to the embedded video */
-              if(preg_match('/(<embed src.+?\/embed>)/', $contents, $matches)) { 
+              if(preg_match('/(<embed src.+?\/embed>)/', $contents, $matches) ||
+                 preg_match('/(<embed src.+?\/object>)/', $contents, $matches)) { 
                 $description=$matches[1];
                 $description=preg_replace("/"/","'",$description);
                 $description=preg_replace("/&lt;/","<",$description);
@@ -841,11 +852,12 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
               
           /*
            **********************************
-           * Embed a remote .flv file
+           * Embed a remote .flv or .mp4 file
            **********************************
             */
-          } else if(preg_match("/.*\/(.+?)\.flv/i",$url,$matches)) {
-
+          } else if(preg_match("/.*\/(.+?)\.flv/i",$url,$matches) ||
+                    preg_match("/.*\/(.+?)\.mp4/i",$url,$matches)) {
+            
               /* Set the title and summary to the name of the file */
               $title = $matches[1];
               $summary = $matches[1];