diff options
author | Sem <sembrestels@riseup.net> | 2011-11-10 23:03:58 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2011-11-10 23:03:58 +0100 |
commit | 34e4ad8ba5e0a77b797f24ed9af1cee6dce82c36 (patch) | |
tree | 9f6bde2cac9d032f013a15d614beea5af567a927 /lib/vimeo.php | |
parent | 614c1203c7ddd6108c24b6114d3278089fa70633 (diff) | |
download | elgg-34e4ad8ba5e0a77b797f24ed9af1cee6dce82c36.tar.gz elgg-34e4ad8ba5e0a77b797f24ed9af1cee6dce82c36.tar.bz2 |
Refactored library. One file per videotype.
Diffstat (limited to 'lib/vimeo.php')
-rw-r--r-- | lib/vimeo.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/vimeo.php b/lib/vimeo.php new file mode 100644 index 000000000..0433c5a94 --- /dev/null +++ b/lib/vimeo.php @@ -0,0 +1,31 @@ +<?php + +function videolist_parseurl_vimeo($url) { + $parsed = parse_url($url); + $path = explode('/', $parsed['path']); + + if ($parsed['host'] != 'vimeo.com' || !(int) $path[1]) { + return false; + } + + return array( + 'videotype' => 'vimeo', + 'video_id' => $path[1], + ); +} + +function videolist_get_data_vimeo($parsed){ + $video_id = $parsed['video_id']; + + $buffer = file_get_contents("http://vimeo.com/api/v2/video/$video_id.xml"); + $xml = new SimpleXMLElement($buffer); + + $videos = $xml->children(); + $video = $videos[0]; + + return array( + 'title' => sanitize_string($video->title), + 'description' => strip_tags($video->description), + 'thumbnail' => sanitize_string($video->thumbnail_medium), + ); +} |