From e2930ee2dd05f1a32e0ec982cd56491b2b76e698 Mon Sep 17 00:00:00 2001 From: Grischa Brockhaus Date: Sat, 18 Feb 2012 21:45:59 +0100 Subject: [PATCH] oembed plugin - New: dotsub.com video service. podomatic podcast service --- serendipity_event_oembed/ChangeLog | 4 + .../customs/PodomaticProvider.class.php | 101 ++++++++++++++++++ serendipity_event_oembed/oembed/providers.xml | 10 ++ .../serendipity_event_oembed.php | 3 +- 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 serendipity_event_oembed/oembed/customs/PodomaticProvider.class.php diff --git a/serendipity_event_oembed/ChangeLog b/serendipity_event_oembed/ChangeLog index 73a24678..313d42b3 100644 --- a/serendipity_event_oembed/ChangeLog +++ b/serendipity_event_oembed/ChangeLog @@ -1,3 +1,7 @@ +Version 1.07 (brockhaus) +----------------------- +* New: dotsub.com video service. podomatic podcast service + Version 1.06 (brockhaus) ----------------------- * New AudioBoo resolver supporting the 3 different players of AudioBoo (configurable wich). diff --git a/serendipity_event_oembed/oembed/customs/PodomaticProvider.class.php b/serendipity_event_oembed/oembed/customs/PodomaticProvider.class.php new file mode 100644 index 00000000..546e7f8c --- /dev/null +++ b/serendipity_event_oembed/oembed/customs/PodomaticProvider.class.php @@ -0,0 +1,101 @@ + + * Podomatic Minicasts + * http://minicasts.podomatic.com/play/* + * PodomaticProvider + * +* + * @author Grischa Brockhaus + * + */ +class PodomaticProvider extends EmbedProvider { + + /** + * This is the main function calling the Posterous postly API and converting it into a OEmbed object + * @param string $url post.ly url + * @return OEmbed the embed object + */ + public function getEmbed($url){ + // http://minicasts.podomatic.com/play/1620677/2976197 + if(preg_match("/minicasts\.podomatic\.com\/play\/(\d+)\/(\d+)/",$url,$matches)){ + $boo_id=$matches[2]; + } + if (empty($boo_id)) return null; + $width = 440; + $height = 205; + $player = ""; + $oembed = new RichEmbed(); + $oembed->type='rich'; + $oembed->html = $player; + $oembed->width="$width"; + $oembed->height="$height"; + $oembed->url=$url; + $oembed->version='1.0'; + $oembed->provider_name="Podomatic Minicast"; + $oembed->provider_url="http://www.podomatic.com"; + $oembed->title = 'Podomatic Minicast'; + + return $oembed; + } + + // === here comes the regular stuff for providers, what is very similar in any custom provider ========= + private function provideXML($url){ + $string=""; + $oembed = $this->getEmbed($url); + if (isset($oembed)) { + 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){ + $oembed = $this->getEmbed($url); + if (isset($oembed)) return json_encode($this->getEmbed($url)); + else return null; + } + private function provideSerialized($url){ + $oembed = $this->getEmbed($url); + if (isset($oembed)) return serialize($this->getEmbed($url)); + else return null; + } + 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 match($url) { + return preg_match("/minicasts\.podomatic\.com\/play\/(\d+)\/(\d+)/",$url); + } + + /** + * Constructor + * Enter description here ... + * @param simplexml $config holds the entry in the providers.xml for this Provider. You can add more parameters parsed here + */ + public function __construct($config){ + parent::__construct("http://minicasts.podomatic.com/play",""); + } +} \ No newline at end of file diff --git a/serendipity_event_oembed/oembed/providers.xml b/serendipity_event_oembed/oembed/providers.xml index d8aca518..abfe577f 100644 --- a/serendipity_event_oembed/oembed/providers.xml +++ b/serendipity_event_oembed/oembed/providers.xml @@ -34,6 +34,11 @@ http://*.photobucket.com/(albums|groups)/* http://photobucket.com/oembed + + DotSub.com + http://dotsub.com/view//* + http://dotsub.com/services/oembed/ + Official.fm (tracks and playlist) @@ -131,6 +136,11 @@ http://(audio)?boo.fm/boos/* AudioBooProvider + + Podomatic Minicasts + http://minicasts.podomatic.com/play/* + PodomaticProvider + diff --git a/serendipity_event_oembed/serendipity_event_oembed.php b/serendipity_event_oembed/serendipity_event_oembed.php index dc026e99..a1440860 100644 --- a/serendipity_event_oembed/serendipity_event_oembed.php +++ b/serendipity_event_oembed/serendipity_event_oembed.php @@ -30,7 +30,7 @@ class serendipity_event_oembed extends serendipity_event $propbag->add('description', PLUGIN_EVENT_OEMBED_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Grischa Brockhaus'); - $propbag->add('version', '1.06'); + $propbag->add('version', '1.07'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -199,6 +199,7 @@ class serendipity_event_oembed extends serendipity_event catch (ErrorException $e) { // Timeout in most cases //return $e; + //print_r($e); } } return $obj;