]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Metacafe and Giss.tv support.
authorSem <sembrestels@riseup.net>
Wed, 9 Nov 2011 22:26:27 +0000 (23:26 +0100)
committerSem <sembrestels@riseup.net>
Wed, 9 Nov 2011 22:26:27 +0000 (23:26 +0100)
lib/videolist.php
views/default/videolist/watch/gisstv.php [new file with mode: 0644]
views/default/videolist/watch/metacafe.php

index c62109b77336fd986e8d197532c5dcfb491d56cf..bb114b29882e8dcdd39909eede6f63a7e1abe036 100644 (file)
@@ -56,11 +56,34 @@ function videolist_parseurl_bliptv($url) {
        );
 }
 
+function videolist_parseurl_gisstv($url) {
+       $parsed = parse_url($url);
+       $path = explode('/', $parsed['path']);
+
+       if ($parsed['host'] != 'giss.tv' || $path[1] != 'dmmdb') {
+               return false;
+       }
+       
+       if($path[2] == 'contents' && isset($path[3])) {
+               $video_id = $path[3];
+       } elseif($path[3] == 'contents' && isset($path[4])) {
+               $video_id = $path[4];
+       } else {
+               return false;
+       }
+       
+       return array(
+               'videotype' => 'gisstv',
+               'video_id' => $video_id,
+       );
+}
+
 function videolist_parseurl($url){
        if ($parsed = videolist_parseurl_youtube($url)) return $parsed;
        elseif ($parsed = videolist_parseurl_vimeo($url)) return $parsed;
        elseif ($parsed = videolist_parseurl_metacafe($url)) return $parsed;
        elseif ($parsed = videolist_parseurl_bliptv($url)) return $parsed;
+       elseif ($parsed = videolist_parseurl_gisstv($url)) return $parsed;
        else return array();
 }
 
@@ -72,6 +95,7 @@ function videolist_get_data($video_parsed_url) {
                case 'vimeo': return videolist_get_data_vimeo($video_id);
                case 'metacafe': return videolist_get_data_metacafe($video_id);
                case 'bliptv': return videolist_get_data_bliptv($video_id);
+               case 'gisstv': return videolist_get_data_gisstv($video_id);
                default: return array();
        }
 }
@@ -110,15 +134,11 @@ function videolist_get_data_metacafe($video_id){ //FIXME
        $buffer = file_get_contents("http://www.metacafe.com/api/item/$video_id");
        $xml = new SimpleXMLElement($buffer);
        
-       $children = $xml->children();
-       $channel = $children[1];
-       
-       preg_match('/<img[^>]+src[\\s=\'"]+([^"\'>\\s]+)/is', $channel->description, $matches);
-       
        return array(
-               'title' => $channel->title,
-               'description' => $channel->description,
-               'thumbnail' => $matches[1],
+               'title' => current($xml->xpath('/rss/channel/item/title')),
+               'description' => current($xml->xpath('/rss/channel/item/description')),
+               'thumbnail' => current($xml->xpath('/rss/channel/item/media:thumbnail/@url')),
+               'embedurl' => current($xml->xpath('/rss/channel/item/media:content/@url')),
                'video_id' => $video_id,
                'videotype' => 'metacafe',
        );
@@ -137,3 +157,22 @@ function videolist_get_data_bliptv($video_id){
                'videotype' => 'bliptv',
        );
 }
+
+function videolist_get_data_gisstv($video_id){
+       $buffer = file_get_contents('http://giss.tv/dmmdb//rss.php');
+       $xml = new SimpleXMLElement($buffer);
+       
+       $data = array();
+       foreach($xml->xpath('/rss/channel/item') as $item){
+               if(sanitize_string($item->link) == 'http://giss.tv/dmmdb//contents/'.$video_id) {
+                       $data['title'] = sanitize_string($item->title);
+                       $data['description'] = sanitize_string($item->description);
+                       $data['thumbnail'] = sanitize_string($item->thumbnail);
+                       break;
+               }
+       }
+       return array_merge($data, array(
+               'video_id' => $video_id,
+               'videotype' => 'gisstv',
+       ));
+}
diff --git a/views/default/videolist/watch/gisstv.php b/views/default/videolist/watch/gisstv.php
new file mode 100644 (file)
index 0000000..6fdecd1
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+
+$video_id = $vars['entity']->video_id;
+$width = $vars['width'];
+$height = $vars['height'];
+
+echo "<video width=\"$width\" height=\"$height\" controls=\"\" autoplay=\"\" tabindex=\"0\">
+       <source type=\"video/ogg\" src=\"http://giss.tv/dmmdb//contents/$video_id\"></source>
+</video>";
index cfa5e02a4710aeb2010fa6d2c94867f6975b851a..ddf2b155ed94a9e21ef85099528c8c60e5fb62ee 100644 (file)
@@ -1,15 +1,7 @@
 <?php
 
-/* TODO
-$video_id = $vars['video_id'];
+$embedurl = $vars['entity']->embedurl;
 $width = $vars['width'];
 $height = $vars['height'];
 
-$path = explode("/", $videos->thumbnail);
-$path = array_reverse($path);
-$thumbnailArray = explode(".", $path[0]);
-$video_id = $video_id."/".$thumbnailArray[0].".swf";
-
-echo "<br />
-<embed src=\"http://www.metacafe.com/fplayer/".$video_id."\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"$width\" height=\"$height\" wmode=\"transparent\" name=\"Metacafe_".$video_id."\"></embed>";
-*/
+echo "<embed flashVars=\"playerVars=autoPlay=no\" src=\"$embedurl\" width=\"540\" height=\"304\" wmode=\"transparent\" allowFullScreen=\"true\" allowScriptAccess=\"always\" name=\"Metacafe_$video_id\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>";