function kaltura_cron in Kaltura 7.2
Same name and namespace in other branches
- 5 kaltura.module \kaltura_cron()
- 6.2 kaltura.module \kaltura_cron()
- 6 kaltura.module \kaltura_cron()
- 7.3 kaltura.module \kaltura_cron()
Implements hook_cron().
TODO: I saw multiple warnings occurring in the cron function right after module was installed. TODO: This hook should be checked thoroughly.
File
- ./
kaltura.module, line 600 - Kaltura integration module - core functions.
Code
function kaltura_cron() {
// Get all entries from node_kaltura table,
// use the getEntries service to retrieve the data of entries.
$lastcron = variable_get('kaltura_last_update', 0);
$now = time();
$diff = $now - $lastcron;
$diffHours = round($diff / 60 / 60);
// if ($diffHours >= variable_get('kaltura_update_frequency', 0) + 1) {
try {
$all_entries = db_select('node_kaltura', 'k')
->fields('k', array(
'kaltura_entryid',
))
->execute()
->fetchCol();
if (is_array($all_entries) && count($all_entries)) {
$result = kaltura_get_entries($all_entries, TRUE);
}
else {
$result = FALSE;
}
// If we got a good result, we update the entry data in the DB.
if ($result[0] !== FALSE) {
foreach ($result[0]->objects as $result_object) {
$ent['kaltura_entryid'] = $result_object->id;
$ent['kaltura_tags'] = $result_object->tags;
$ent['kaltura_admin_tags'] = $result_object->adminTags;
$ent['kstatus'] = $result_object->status;
$ent['kaltura_media_type'] = $result_object->mediaType;
$ent['kaltura_duration'] = $result_object->duration;
$ent['kaltura_thumbnail_url'] = $result_object->thumbnailUrl;
$ent['kaltura_partner_data'] = $result_object->partnerData;
$ent['kaltura_source'] = $result_object->sourceType;
$ent['kaltura_width'] = $result_object->width;
$ent['kaltura_height'] = $result_object->height;
$ent['kaltura_download_url'] = $result_object->downloadUrl;
$ent['kaltura_views'] = $result_object->views;
$ent['kaltura_plays'] = $result_object->plays;
$ent['kaltura_votes'] = $result_object->votes;
$ent['kaltura_rank'] = $result_object->rank;
$ent['kaltura_total_rank'] = $result_object->totalRank;
$ent['kaltura_title'] = $result_object->name;
$ent['kaltura_description'] = $result_object->description;
drupal_write_record('node_kaltura', $ent, 'kaltura_entryid');
}
}
// If there is a successful run write timestamp.
variable_set('kaltura_last_update', $now);
} catch (Exception $ex) {
// TODO: Error handling?
}
// }
}