X-Git-Url: http://git.pippins.net/embedvideo/.git/static/git-logo.png?a=blobdiff_plain;f=ItemAddEmbedVideo.inc;h=7ef877ed842a6e270f241eb722ba105c0764ed13;hb=1528ab8803b189ef5118fe23c11dc93bd2b37954;hp=ac7b1cf05dde317810575fc2f0820a8e02d77503;hpb=bbe9d512174553b9b410742bb82c69ffa67911f5;p=embedvideo%2F.git diff --git a/ItemAddEmbedVideo.inc b/ItemAddEmbedVideo.inc index ac7b1cf..7ef877e 100644 --- a/ItemAddEmbedVideo.inc +++ b/ItemAddEmbedVideo.inc @@ -71,6 +71,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { global $width, $height, $externalFlvPlayer, $externalFlvPlayerVars; global $flvThumbnail, $useRemoteSize, $autoStart; global $watermarkVideos, $watermarkImage, $watermarkAlignment; + global $unsupported_url; /* Find out what value our parameters should have by looking to see if they * are defined in our overrides section or default section. If they are not @@ -169,6 +170,9 @@ class ItemAddEmbedVideo extends ItemAddPlugin { $gallery2_flv_thumbnail = "modules/embedvideo/images/G2video_thumbnail.jpg"; $gallery2_video_watermark = "modules/embedvideo/images/G2video_watermark1.png"; $gallery2_flv_player = "modules/flashvideo/lib/G2flv.swf"; + + /* Unsupported URLs */ + $unsupported_url=0; /* Store the passed URL in a shorter local variable */ $url = $form['webPage']['URL']; @@ -187,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); @@ -194,7 +200,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { /* If extra params were given, handle them here */ if(strcmp($extra_params,"")) { - /* Handle the HD format information */ + /* Handle the high quality format information */ if(preg_match("/fmt=(\d+)/",$extra_params,$matches)) { $extra_params="&ap=%2526fmt%3D".$matches[1]; } @@ -325,10 +331,11 @@ class ItemAddEmbedVideo extends ItemAddPlugin { } /* Extract the thumbnail URL from the webpage contents */ - preg_match('/"; + + /* Extract the summary from the webpage contents */ + $summary="Unknown"; + if(preg_match('/(.+?)<\/title>/i', $contents, $matches)) { + $title=$matches[1]; + } + + /* + * Set the thumbnail to some generic jpg image, + * since we can't extract it from a generic website. + * 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('/()/', $contents, $matches)) { + $description=$matches[1]; + if(!strcmp($useRemoteSize,"false")) { + $description=preg_replace("/width=\"\d+\"/","width=\"".$width."\"",$description); + $description=preg_replace("/height=\"\d+\"/","height=\"".$height."\"",$description); + } + $description=preg_replace("/src=\"\//","src=\"".$site."\/",$description); + } else { + $unsupported_url=1; + } + } + /* ********************************** * Unsupported URL to embed ********************************** */ - } else { + if($unsupported_url == 1) { return array(GalleryCoreApi::error(ERROR_UNSUPPORTED_FILE_TYPE,__FILE__,__LINE__, "Unable to embed video from: $url"),null,null); }