From 46e1538c4e6375a1cc5b5a84c339777df1dc69a0 Mon Sep 17 00:00:00 2001 From: "Alan J. Pippin" Date: Tue, 23 Sep 2008 23:00:54 -0600 Subject: [PATCH] Improved error message when URL pattern doesn't match supported types. Loosened URL pattern matching, dropping "www." and ".com" expectations. Fixed stickam video embedding parser. Realized new vimeo webpage format makes them impossible to embed now. --- ItemAddEmbedVideo.inc | 40 ++++++++++++++++----------------- module.inc | 2 +- templates/ItemAddEmbedVideo.tpl | 1 - 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/ItemAddEmbedVideo.inc b/ItemAddEmbedVideo.inc index 6fd4281..d598ee2 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,39 +126,39 @@ 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 */ @@ -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("/</","<",$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) { @@ -1023,7 +1023,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); } diff --git a/module.inc b/module.inc index 7754d2d..d8fd9d2 100644 --- a/module.inc +++ b/module.inc @@ -33,7 +33,7 @@ class EmbedVideoModule extends GalleryModule { $this->setId('embedvideo'); $this->setName($gallery->i18n('Embed Video')); $this->setDescription($gallery->i18n('Add embedded videos from the web')); - $this->setVersion('1.1.1'); + $this->setVersion('1.1.2'); $this->setGroup('import', $gallery->i18n('Import')); $this->setCallbacks('getSiteAdminViews'); $this->setRequiredCoreApi(array(7, 3)); diff --git a/templates/ItemAddEmbedVideo.tpl b/templates/ItemAddEmbedVideo.tpl index 1ea2807..43d0e73 100644 --- a/templates/ItemAddEmbedVideo.tpl +++ b/templates/ItemAddEmbedVideo.tpl @@ -31,7 +31,6 @@ Stickam: http://www.stickham.com/editMediaComment.do?method=load&mId=xxxxxxxxx
Myspace1: http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=xxxxxxxx
Myspace2: http://myspacetv.com/index.cfm?fuseaction=vids.individual&videoid=xxxxxxxx
- Vimeo: http://www.vimeo.com/xxxxxx
Generic: Any webpage with an '<object ... <embed ...' style video on its page

Supported File Types:
-- 2.34.1