';
}
return $output;
}
/**
* Implement hook emvideo_PROVIDER_data_version().
*/
function emvideo_google_data_version() {
return EMVIDEO_GOOGLE_DATA_VERSION;
}
/**
* hook emfield_PROVIDER_data
*
* provides an array to be serialised and made available with $item elsewhere
*/
function emvideo_google_data($field, $item) {
$data = array();
// Create some 'field' version control.
$data['emvideo_data_version'] = EMVIDEO_GOOGLE_DATA_VERSION;
$rss = emvideo_google_request($item['value']);
if (
is_array($rss['ITEM']) &&
is_array($rss['ITEM']['MEDIA:GROUP']) &&
is_array($rss['ITEM']['MEDIA:GROUP']['MEDIA:CONTENT']) &&
is_array($rss['ITEM']['MEDIA:GROUP']['MEDIA:CONTENT'][1])
) {
$video = $rss['ITEM']['MEDIA:GROUP']['MEDIA:CONTENT'][1];
$data['filepath'] = $video['URL'];
$data['filemime'] = $video['TYPE'];
$data['medium'] = $video['MEDIUM'];
$data['expression'] = $video['EXPRESSION'];
$data['duration'] = $video['DURATION'];
$data['width'] = $video['WIDTH'];
$data['height'] = $video['HEIGHT'];
}
if (is_array($rss['MEDIA:GROUP'])) {
if (is_array($rss['MEDIA:GROUP']['MEDIA:THUMBNAIL']) && is_array($rss['MEDIA:GROUP']['MEDIA:THUMBNAIL'][1])) {
$thumbnail = $rss['MEDIA:GROUP']['MEDIA:THUMBNAIL'][1];
$data['thumbnail']['filepath'] = $thumbnail['URL'];
$data['thumbnail']['width'] = $thumbnail['WIDTH'];
$data['thumbnail']['height'] = $thumbnail['HEIGHT'];
}
if (is_array($rss['MEDIA:GROUP']['MEDIA:PLAYER']) && is_array($rss['MEDIA:GROUP']['MEDIA:PLAYER'][1])) {
$data['player']['filepath'] = $rss['MEDIA:GROUP']['MEDIA:PLAYER'][1]['URL'];
}
}
if ($data['thumbnail']['filepath'] == '' && is_array($rss['ITEM'])) {
// for whatever reason the thumbnail failed try the old method
// we'll parse it from the description, where it's repeated.
$desc = $rss['ITEM']['DESCRIPTION'][0];
$regex = '@