function emvideo_bliptv_data in Embedded Media Field 6
2 calls to emvideo_bliptv_data()
- emvideo_bliptv_duration in contrib/
emvideo/ providers/ bliptv.inc - hook emvideo_PROVIDER_duration($item) Returns the duration of the video in seconds.
- emvideo_bliptv_rss in contrib/
emvideo/ providers/ bliptv.inc - Providers may supply an enclosure for rss feeds. This expects something in a file format, so would be an object in the format of $file->filepath, $file->filesize, and $file->filemime. calls the providers hook emvideo_PROVIDER_rss.
File
- contrib/
emvideo/ providers/ bliptv.inc, line 87 - This include processes blip.tv media files for use by emfield.module.
Code
function emvideo_bliptv_data($field, $item) {
$data = array();
// we added new data fields to keep from having to reload the api/rss
// because the data is only stored on update/insert, however, we have to know which data type we're using
// this will just be an integer, increased when we make a change to data
$data['emvideo_bliptv_data_version'] = $data['emvideo_data_version'] = EMVIDEO_BLIPTV_DATA_VERSION;
// use the page id, since we'll have that in most cases (except in embed pastes, which gets parsed during extraction)
// we use this to get an rss feed w/ all the info for the video. interesting reading ;)
// some of our data we'll get from the api, like available files
$rss = emvideo_bliptv_request($item['value'], TRUE, 'rss');
$api = emvideo_bliptv_request($item['value'], TRUE, 'api');
// special handling for show/feature pages
// TODO: this is disabled for now.
// if (empty($rss) && empty($api) && preg_match('@http\://([^\.]+)\.blip\.tv/@i', $item['embed'], $matches)) {
// $show_rss = emvideo_bliptv_request($item['value'], TRUE, 'rss', TRUE);
// $data['thumbnail']['url'] = $rss['IMAGE']['URL'][0];
// $data['flv'] = array();
// $data['showpage'] = "http://{$item['value']}.blip.tv/";
// $data['is_show'] = TRUE;
// return $data;
// }
$data['is_show'] = FALSE;
// get our thumbnail url
$data['thumbnail']['url'] = $rss['ITEM']['MEDIA:THUMBNAIL'][1]['URL'];
// this gets sent to the player
foreach ((array) $api['MEDIA']['LINK'] as $x => $link) {
$x--;
$video_type = '';
switch ($link['TYPE']) {
case 'video/x-flv':
$video_type = 'flv';
break;
case 'video/x-m4v':
$video_type = 'm4v';
break;
case 'video/quicktime':
$video_type = 'mov';
break;
}
if ($video_type) {
$video_info = array();
$video_info['url'] = $link['HREF'];
$video_info['width'] = $api['MEDIA']['WIDTH'][$x];
$video_info['height'] = $api['MEDIA']['HEIGHT'][$x];
$video_info['duration'] = $api['MEDIA']['DURATION'][$x];
$video_info['size'] = $api['MEDIA']['SIZE'][$x];
$video_info['mime'] = $link['TYPE'];
$video_info['embed_code'] = $rss['ITEM']['BLIP:EMBEDLOOKUP'];
// we only store the last video of a particular type, for instance if two roles use .mov
$data[$video_type] = $video_info;
// however, we store the whole thing under role, so the information is still saved
// but our arrays may be out of synch...
$y = $x + 1;
if ($api['MEDIA']['ROLE'][$y]) {
$data[$video_type]['role'] = $api['MEDIA']['ROLE'][$y];
$data[$api['MEDIA']['ROLE'][$y]] = $video_info;
$data[$api['MEDIA']['ROLE'][$y]]['role'] = $api['MEDIA']['ROLE'][$y];
}
}
}
if (!$data['flv']) {
$data['flv'] = array();
}
if (!$data['flv']['url']) {
$data['flv']['url'] = $rss['ITEM']['ENCLOSURE'][1]['URL'];
}
$data['title'] = $api['en']['TITLE'][0] ? $api['en']['TITLE'][0] : $rss['2.0']['CHANNEL']['TITLE'][0];
$data['description'] = $api['en']['DESCRIPTION'][0] ? $api['en']['DESCRIPTION'][0] : $rss['ITEM']['BLIP:PUREDESCRIPTION'][0];
$data['blip_user']['uid'] = $api['CREATEDBY']['UID'][0] ? $api['CREATEDBY']['UID'][0] : $rss['ITEM']['BLIP:USERID'][0];
$data['blip_user']['username'] = $api['CREATEDBY']['LOGIN'][0] ? $api['CREATEDBY']['LOGIN'][0] : $rss['ITEM']['BLIP:USER'][0];
$data['blip_user']['url'] = $api['CREATEDBY']['LINKS']['LINK'][1] ? $api['CREATEDBY']['LINKS']['LINK'][1] : 'http://blip.tv/users/view/' . $data['blip_user']['username'];
$data['showpage'] = $rss['ITEM']['BLIP:SHOWPAGE'][0];
$data['embed_code'] = $rss['ITEM']['BLIP:EMBEDLOOKUP'];
// this is the code actually used by the player, even though it's different than for the page
if ($rss['ITEM']['BLIP:POSTS_ID'][0]) {
$data['post_id'] = $rss['ITEM']['BLIP:POSTS_ID'][0];
}
return $data;
}