From f01953cf7ccebaf4fbf1eb31e47eea79414954e4 Mon Sep 17 00:00:00 2001 From: Grischa Brockhaus Date: Tue, 20 Dec 2011 12:12:21 +0100 Subject: [PATCH] Supports youtube https now directly. --- serendipity_event_oembed/ChangeLog | 3 +- .../oembed/YouTubeProvider.class.php | 80 ------------------- serendipity_event_oembed/oembed/providers.xml | 10 +-- 3 files changed, 4 insertions(+), 89 deletions(-) delete mode 100644 serendipity_event_oembed/oembed/YouTubeProvider.class.php diff --git a/serendipity_event_oembed/ChangeLog b/serendipity_event_oembed/ChangeLog index 465b18cf..cc46365f 100644 --- a/serendipity_event_oembed/ChangeLog +++ b/serendipity_event_oembed/ChangeLog @@ -3,7 +3,8 @@ Version 1.01 (brockhaus) * Added "generic providers" embed.ly and oohembed.com. * Removed the depending definitions in providers.xml * New providers via noembed: GitHub Commit, GitHub Gist and Beer Advocate (Yeah!) ;D -* Reverted Smarty Security Disabling (tested with 1.6/1.7 blogs +* Reverted Smarty Security Disabling (tested with 1.6/1.7 blogs) +* Supports youtube https now directly. Version 1.00 (brockhaus) ----------------------- diff --git a/serendipity_event_oembed/oembed/YouTubeProvider.class.php b/serendipity_event_oembed/oembed/YouTubeProvider.class.php deleted file mode 100644 index d7797a0b..00000000 --- a/serendipity_event_oembed/oembed/YouTubeProvider.class.php +++ /dev/null @@ -1,80 +0,0 @@ -type='video'; - $myEmbed->version='1.0'; - $myEmbed->provider_name="Youtube"; - $myEmbed->provider_url="http://youtube.com"; - $myEmbed->resource_url=$url; - $xml = new DOMDocument; - if(@($xml->load('http://gdata.youtube.com/feeds/api/videos/'.$video_id))) { - @$guid = $xml->getElementsByTagName("guid")->item(0)->nodeValue; - $link = str_replace("http://www.youtube.com/watch?v=","http://bergengocia.net/indavideobombyoutubemashup/view.php?id=",$guid); - $myEmbed->title =$xml->getElementsByTagName("title")->item(0)->nodeValue; - $myEmbed->description =$xml->getElementsByTagNameNS("*","description")->item(0)->nodeValue; - $myEmbed->author_name =$xml->getElementsByTagName("author")->item(0)->getElementsByTagName("name")->item(0)->nodeValue; - $myEmbed->author_url =$xml->getElementsByTagName("author")->item(0)->getElementsByTagName("uri")->item(0)->nodeValue; - $myEmbed->thumbnail_url =$xml->getElementsByTagNameNS("*","thumbnail")->item(0)->getAttribute("url"); - $myEmbed->thumbnail_width =$xml->getElementsByTagNameNS("*","thumbnail")->item(0)->getAttribute("width"); - $myEmbed->thumbnail_height =$xml->getElementsByTagNameNS("*","thumbnail")->item(0)->getAttribute("height"); - $med_content_url=$xml->getElementsByTagNameNS("http://search.yahoo.com/mrss/","content")->item(0)->getAttribute("url"); - $myEmbed->html= - ''."\n". - ' '."\n". - ' '."\n". - ' '."\n". - ''; // according to http://code.google.com/apis/youtube/developers_guide_protocol.html#Displaying_information_about_a_video - $myEmbed->width="425"; - $myEmbed->height="350"; // same as in the html - //$myEmbed->duration=$xml->getElementsByTagNameNS($xml->lookupNamespaceURI("*"),"content")->item(0)->getAttribute("duration"); - //$time = floor($duration / 60) . ":" . $duration % 60; - return $myEmbed; - } else throw new Exception404("xxx"); - } - private function provideXML($url){ - $string=""; - foreach($this->getEmbed($url) as $key=>$value){ - if(isset($value)&& $value!="") $string.=" <".$key.">".$value."\n"; - } - $string="\n".$string.""; - return $string; - } - private function provideObject($url){ - return $this->getEmbed($url); - } - private function provideJSON($url){ - return json_encode($this->getEmbed($url)); - } - private function provideSerialized($url){ - return serialize($this->getEmbed($url)); - } - public function provide($url,$format="json"){ - if($format=="xml"){ - return $this->provideXML($url); - } else if ($format=="object"){ - return $this->provideObject($url); - } else if ($format=="serialized"){ - return $this->provideSerialized($url); - } else { - return $this->provideJSON($url);; - } - } - - - public function __construct($config,$maxwidth=null, $maxheight=null){ - parent::__construct("http://youtube.com","", $maxwidth, $maxheight); - } -} diff --git a/serendipity_event_oembed/oembed/providers.xml b/serendipity_event_oembed/oembed/providers.xml index eff69a84..57e92b37 100644 --- a/serendipity_event_oembed/oembed/providers.xml +++ b/serendipity_event_oembed/oembed/providers.xml @@ -20,20 +20,14 @@ http://*.vimeo.com/* http://vimeo.com/api/oembed.{format} - Youtube - http://*.youtube.com/* + https?://*.youtube.com/* http://www.youtube.com/oembed Youtube short link - http://*.youtu.be/* + https?://*.youtu.be/* http://www.youtube.com/oembed