aboutsummaryrefslogtreecommitdiff
path: root/lib/vimeo.php
blob: 0433c5a94b2da4608666a00d88c3e36a27ab5318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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),
	);
}