You are here

function video_filter_bliptv in Video Filter 6.2

Same name and namespace in other branches
  1. 5.2 video_filter.codecs.inc \video_filter_bliptv()
  2. 6.3 video_filter.codecs.inc \video_filter_bliptv()
  3. 7.3 video_filter.codecs.inc \video_filter_bliptv()
1 string reference to 'video_filter_bliptv'
video_filter_codec_info in ./video_filter.codecs.inc

File

./video_filter.codecs.inc, line 302

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('http://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();
    $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];
  }
  $video['source'] = 'http://blip.tv/play/' . $id;
  $params = array(
    'allowscriptaccess' => 'always',
  );
  return video_filter_flash($video, $params);
}