(.+?)<\/div>/i', $contents, $matches);
+ $summary=$matches[1];
+
+ /* Extract the title from the webpage contents */
+ preg_match('/
/i', $contents, $matches);
+ $title=htmlentities($matches[1], ENT_QUOTES, "UTF-8");
+
+ /* Build the thumbnail URL from the item_id */
+ $thumbnail=$dailymotionThumbnailUrl.$item_id;
+
+ /* Format the description to hold a reference to the embedded video */
+ if(preg_match('/Embeddable Player:.+?value="(.+?)"/', $contents, $matches)) {
+ $description=$matches[1];
+ $description=preg_replace("/"/","'",$description);
+ $description=preg_replace("/</","<",$description);
+ $description=preg_replace("/>/",">",$description);
+ if(!strcmp($useRemoteSize,"false")) {
+ $description=preg_replace("/width=\"\d+\"/","width=\"".$width."\"",$description);
+ $description=preg_replace("/height=\"\d+\"/","height=\"".$height."\"",$description);
+ }
+ } else {
+ return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
+ "Unable to extract embedded video information from url: $url"),NULL,NULL);
+ }
+
+ /*
+ **********************************
+ * Embed a DivShare Video
+ **********************************
+ */
+ } else if(preg_match("/$divshareUrlPattern/",$url)) {
+
+ /* Make sure we can extract a itemID */
+ if(preg_match("/\/download\/(.+)/",$url,$matches)) {
+ $item_id = $matches[1];
+ $item_id=preg_replace("/\/$/","",$item_id);
+ } else {
+ return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER,__FILE__,__LINE__,
+ "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 */
+ list ($successfullyCopied, $contents, $response, $headers) =
+ GalleryCoreApi::fetchWebPage($url, $extraHeaders);
+ if (!$successfullyCopied) {
+ return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
+ "Unable to get video information at url: $url - $response"),NULL,NULL);
+ }
+
+ /* Extract the summary from the webpage contents */
+ //preg_match('/
/i', $contents, $matches);
+ //$summary=$matches[1];
+ // Right now, the description is a plug for divshare, nothing user specific about it
+ $summary="";
+
+ /* Extract the title from the webpage contents */
+ preg_match('/
(.+?) - Divshare<\/title>/i', $contents, $matches);
+ $title=$matches[1];
+
+ /* Build the thumbnail URL from the item_id */
+ $thumbnail=$divshareThumbnailUrl.$item_id;
+
+ /* Format the description to hold a reference to the embedded video */
+ if(preg_match('/(";
- $description.= "
$summary";
+ /* Grab the contents of the webpage used to display the video on video.google.com */
+ list ($successfullyCopied, $contents, $response, $headers) =
+ GalleryCoreApi::fetchWebPage($url, $extraHeaders);
+ if (!$successfullyCopied) {
+ return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
+ "Unable to get video information at url: $url - $response"),NULL,NULL);
+ }
- /*
+ /* Extract the summary from the webpage contents */
+ preg_match('/class="description" id="vid_description">(.+?)<\/div>/i', $contents, $matches);
+ $summary=$matches[1];
+
+ /* Extract the title from the webpage contents */
+ preg_match('/(.+?)<\/h1>/i', $contents, $matches);
+ $title=$matches[1];
+
+ /* Build the thumbnail URL from the item_id */
+ $video_info_url=$myspaceThumbnailUrl.$video_id;
+ list ($successfullyCopied, $video_info, $response, $headers) =
+ GalleryCoreApi::fetchWebPage($video_info_url, $extraHeaders);
+ if (!$successfullyCopied) {
+ return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
+ "Unable to get video information at url: $url - $response"),NULL,NULL);
+ }
+ 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);
+ }
+
+ /* Format the description to hold a reference to the embedded video */
+ if(preg_match('/(<embed src.+?\/embed>)/', $contents, $matches)) {
+ $description=$matches[1];
+ $description=preg_replace("/"/","'",$description);
+ $description=preg_replace("/</","<",$description);
+ $description=preg_replace("/>/",">",$description);
+ if(!strcmp($useRemoteSize,"false")) {
+ $description=preg_replace("/width='\d+'/","width='".$width."'",$description);
+ $description=preg_replace("/height='\d+'/","height='".$height."'",$description);
+ }
+ } else {
+ return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
+ "Unable to extract embedded video information from url: $url"),NULL,NULL);
+ }
+
+ /*
**********************************
* Embed a remote .swf file
**********************************
@@ -589,19 +950,34 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
$fileName = preg_replace("/'/","",$fileName);
$fileName = preg_replace("/\"/","",$fileName);
$fileName = preg_replace("/\d+;/","",$fileName);
+
+ /* Wordwrap the description or summary as appropriate */
+ $description_summary = $summary;
+
+ if(strcmp($wordwrapSummary,"0")) {
+ $summary = wordwrap($summary,$wordwrapSummary,"
",FALSE);
+ }
+
+ if(strcmp($wordwrapDescription,"0")) {
+ $description_summary = wordwrap($description_summary,$wordwrapDescription,"
",FALSE);
+ }
+
+ /* Tack on the summary to the end of the description */
+ $description.= "
$description_summary";
/* General debug output */
if(!strcmp($debugOutput,"true")) {
- print "Item Parameters
";
- print "url: $url
";
- print "title: $title
";
- print "thumbnailUrl:
\n".$summary."";
- print "description:
$description
";
- print "thumbnail: $tmpFile
";
- print "mimeType: $mimeType
";
- print "fileName: $fileName
";
- print "width: $width
";
- print "height: $height
";
+ print "\nItem Parameters
\n";
+ print "url: $url
\n";
+ print "title: $title
\n";
+ print "thumbnailUrl: $thumbnail
\n";
+ print "summary: $summary
\n";
+ print "description: $description
\n";
+ print "thumbnail: $tmpFile
\n";
+ print "mimeType: $mimeType
\n";
+ print "fileName: $fileName
\n";
+ print "width: $width
\n";
+ print "height: $height
\n";
print "
";
}
@@ -647,9 +1023,9 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
}
}
if(!strcmp($debugOutput,"true")) {
- print "Thumbnail Resize
";
- print "$debugString";
- print "
";
+ print "\nThumbnail Resize
\n";
+ print "$debugString\n";
+ print "
\n";
}
/* Watermark the video thumbnail image if indicated by our parameter */
@@ -744,14 +1120,14 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
/* General debug output */
if(!strcmp($debugOutput,"true")) {
- print "Watermark Operation
";
- print "watermarkImage: $watermarkImage
";
- print "watermarkTmpImage: $watermark
";
- print "watermarkMimeType: $watermarkMimeType
";
- print "watermarkWidth: $watermarkWidth
";
- print "watermarkHeight: $watermarkHeight
";
- print "watermarkedWidth: $thumbnailWidth
";
- print "watermarkedHeight: $thumbnailHeight
";
+ print "\nWatermark Operation
\n";
+ print "watermarkImage: $watermarkImage
\n";
+ print "watermarkTmpImage: $watermark
\n";
+ print "watermarkMimeType: $watermarkMimeType
\n";
+ print "watermarkWidth: $watermarkWidth
\n";
+ print "watermarkHeight: $watermarkHeight
\n";
+ print "watermarkedWidth: $thumbnailWidth
\n";
+ print "watermarkedHeight: $thumbnailHeight
\n";
}
/* Apply the watermark image to the thumbnail */
@@ -769,7 +1145,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
}
if(!strcmp($debugOutput,"true")) {
- print "watermarked Image: $tmpFile
";
+ print "\nwatermarked Image: $tmpFile
";
print "
";
}
@@ -796,7 +1172,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
'warnings' => array());
if(!strcmp($debugOutput,"true")) {
- print "
Video Successfully Added to your Gallery Album
";
+ print "\n
Video Successfully Added to your Gallery Album
";
}
}