function video_filter_bliptv in Video Filter 7.3
Same name and namespace in other branches
- 5.2 video_filter.codecs.inc \video_filter_bliptv()
- 6.3 video_filter.codecs.inc \video_filter_bliptv()
- 6.2 video_filter.codecs.inc \video_filter_bliptv()
Callback for Blip.tv codec.
See also
1 string reference to 'video_filter_bliptv'
- video_filter_codec_info in ./
video_filter.codecs.inc - Implements hook_codec_info().
File
- ./
video_filter.codecs.inc, line 424 - This file contains all codecs provided by Video Filter.
Code
function video_filter_bliptv($video) {
$id = $video['codec']['matches'][1];
// Since video ID in URL is different than in embed code, use API to lookup
// the embed code video ID. Adapted from emfield.module.
$result = drupal_http_request('//blip.tv/file/' . $id . '?skin=api');
if ($result->code == 200) {
$parser = drupal_xml_parser_create($result->data);
$vals = array();
$index = array();
xml_parse_into_struct($parser, $result->data, $vals, $index);
xml_parser_free($parser);
$response = array();
// @todo: What's $arghash supposed to be? It's undefined.
$response['_emfield_arghash'] = $arghash;
$level = array();
$start_level = 1;
foreach ($vals as $xml_elem) {
if ($xml_elem['type'] == 'open') {
if (array_key_exists('attributes', $xml_elem)) {
list($level[$xml_elem['level']], $extra) = array_values($xml_elem['attributes']);
}
else {
$level[$xml_elem['level']] = $xml_elem['tag'];
}
}
if ($xml_elem['type'] == 'complete') {
$php_stmt = '$response';
while ($start_level < $xml_elem['level']) {
$php_stmt .= '[$level[' . $start_level . ']]';
$start_level++;
}
$php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'value\'];' . $php_stmt . '[$xml_elem[\'tag\']][] = $xml_elem[\'attributes\'];';
eval($php_stmt);
$start_level--;
}
}
$id = $response['EMBEDLOOKUP'][0];
// Protect from XSS.
if (preg_match("/[^A-Za-z0-9]/", $id, $matches)) {
watchdog('Video Filter', 'A faulty Blip.tv ID has been detected.');
$id = 0;
}
}
$video['source'] = '//blip.tv/play/' . $id;
$params = array(
'allowscriptaccess' => 'always',
);
return video_filter_flash($video, $params);
}