function createTestShow($showNumber, $showTime, $duration = "1:00") { $data = array(); $strTime = $showTime->format("Y-m-d H:i"); echo "Adding show: {$strTime}\n"; $data['add_show_name'] = 'automated show ' . $showNumber; $data['add_show_start_date'] = $showTime->format("Y-m-d"); $data['add_show_start_time'] = $showTime->format("H:i"); $data['add_show_duration'] = $duration; $data['add_show_no_end'] = 0; $data['add_show_repeats'] = 0; $data['add_show_description'] = 'automated show'; $data['add_show_url'] = 'http://www.OfirGal.com'; $data['add_show_color'] = ""; $data['add_show_genre'] = "Ofir"; $data['add_show_background_color'] = ""; $data['add_show_record'] = 0; $data['add_show_hosts'] = ""; $showId = Show::create($data); //echo "show created, ID: $showId\n"; // populating the show with a playlist $instances = Show::getShows($showTime->format("Y-m-d H:i:s"), $showTime->format("Y-m-d H:i:s")); $instance = array_pop($instances); $show = new ShowInstance($instance["instance_id"]); //echo "Adding playlist to show instance ".$show->getShowInstanceId()."\n"; $show->scheduleShow(array(1)); //echo "done\n"; //$show->scheduleShow(array($playlist->getId())); }
public static function SendMessageToShowRecorder($event_type) { global $CC_CONFIG; $conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"], $CC_CONFIG["rabbitmq"]["port"], $CC_CONFIG["rabbitmq"]["user"], $CC_CONFIG["rabbitmq"]["password"]); $channel = $conn->channel(); $channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true); $EXCHANGE = 'airtime-show-recorder'; $channel->exchange_declare($EXCHANGE, 'direct', false, true); $today_timestamp = date("Y-m-d H:i:s"); $now = new DateTime($today_timestamp); $end_timestamp = $now->add(new DateInterval("PT2H")); $end_timestamp = $end_timestamp->format("Y-m-d H:i:s"); $temp['event_type'] = $event_type; if ($event_type = "update_schedule") { $temp['shows'] = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance = NULL, $onlyRecord = TRUE); } $data = json_encode($temp); $msg = new AMQPMessage($data, array('content_type' => 'text/plain')); $channel->basic_publish($msg, $EXCHANGE); $channel->close(); $conn->close(); }
public function scheduleShowDialogAction() { $showInstanceId = $this->_getParam('id'); $this->sched_sess->showInstanceId = $showInstanceId; $show = new ShowInstance($showInstanceId); $start_timestamp = $show->getShowStart(); $end_timestamp = $show->getShowEnd(); //check to make sure show doesn't overlap. if (Show::getShows($start_timestamp, $end_timestamp, array($showInstanceId))) { $this->view->error = "cannot schedule an overlapping show."; return; } $start = explode(" ", $start_timestamp); $end = explode(" ", $end_timestamp); $startTime = explode(":", $start[1]); $endTime = explode(":", $end[1]); $dateInfo_s = getDate(strtotime($start_timestamp)); $dateInfo_e = getDate(strtotime($end_timestamp)); $this->view->showContent = $show->getShowContent(); $this->view->timeFilled = $show->getTimeScheduled(); $this->view->showName = $show->getName(); $this->view->showLength = $show->getShowLength(); $this->view->percentFilled = $show->getPercentScheduled(); $this->view->s_wday = $dateInfo_s['weekday']; $this->view->s_month = $dateInfo_s['month']; $this->view->s_day = $dateInfo_s['mday']; $this->view->e_wday = $dateInfo_e['weekday']; $this->view->e_month = $dateInfo_e['month']; $this->view->e_day = $dateInfo_e['mday']; $this->view->startTime = sprintf("%d:%02d", $startTime[0], $startTime[1]); $this->view->endTime = sprintf("%d:%02d", $endTime[0], $endTime[1]); $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); $this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml'); unset($this->view->showContent); }
public function resizeShow($deltaDay, $deltaMin) { global $CC_DBC; $hours = $deltaMin / 60; if ($hours > 0) { $hours = floor($hours); } else { $hours = ceil($hours); } $mins = abs($deltaMin % 60); $today_timestamp = date("Y-m-d H:i:s"); $starts = $this->getShowStart(); $ends = $this->getShowEnd(); if (strtotime($today_timestamp) > strtotime($starts)) { return "can't resize a past show"; } $sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; $new_ends = $CC_DBC->GetOne($sql); //only need to check overlap if show increased in size. if (strtotime($new_ends) > strtotime($ends)) { $overlap = Show::getShows($ends, $new_ends); if (count($overlap) > 0) { return "Should not overlap shows"; } } //with overbooking no longer need to check already scheduled content still fits. //must update length of all rebroadcast instances. if ($this->isRecorded()) { $sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')\n WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}"; $CC_DBC->query($sql); } $this->setShowEnd($new_ends); RabbitMq::PushSchedule(); }
public function recordedShowsAction() { global $CC_CONFIG; $api_key = $this->_getParam('api_key'); if (!in_array($api_key, $CC_CONFIG["apiKey"])) { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource.'; exit; } $today_timestamp = date("Y-m-d H:i:s"); $now = new DateTime($today_timestamp); $end_timestamp = $now->add(new DateInterval("PT2H")); $end_timestamp = $end_timestamp->format("Y-m-d H:i:s"); $this->view->shows = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance = NULL, $onlyRecord = TRUE); $this->view->is_recording = false; $rows = Show_DAL::GetCurrentShow($today_timestamp); if (count($rows) > 0) { $this->view->is_recording = $rows[0]['record'] == 1; } }