X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=ItemAddEmbedVideo.inc;h=bfb8daab44028f339ca27a5d45fcf621bc1b8829;hb=f7553a85847b1a40cf9d348ebbc2d27956fa8ac1;hp=b2a4539dcd45e107c56f12fda9fee21381eb3462;hpb=f720567c446bf1a136c8b5bec303801931f5ae76;p=embedvideo%2F.git diff --git a/ItemAddEmbedVideo.inc b/ItemAddEmbedVideo.inc index b2a4539..bfb8daa 100644 --- a/ItemAddEmbedVideo.inc +++ b/ItemAddEmbedVideo.inc @@ -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(); @@ -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); @@ -329,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); @@ -370,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) { @@ -420,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) { @@ -473,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) { @@ -531,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) { @@ -581,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) { @@ -630,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); @@ -658,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("/</","<",$description); @@ -688,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) { @@ -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("/</","<",$description); @@ -749,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) { @@ -787,18 +798,19 @@ class ItemAddEmbedVideo extends ItemAddPlugin { } /* Format the description to hold a reference to the embedded video */ - $description = ''; $description.= ''; - $description.= ''; - $description.= ''; - $description.= ''; - + $description.= ''; + $description.= ''; + $description.= ''; + $description.= ''; + /* ********************************** * Embed a remote .swf file @@ -841,11 +853,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]; @@ -1011,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); }