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 function remove() { global $CC_DBC; $music_dir_id = $this->getId(); $sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md LEFT JOIN cc_files as f on f.directory = md.id\n RIGHT JOIN cc_schedule as s on s.file_id = f.id WHERE md.id = {$music_dir_id}"; $show_instances = $CC_DBC->GetAll($sql); $this->_dir->delete(); foreach ($show_instances as $show_instance_row) { $temp_show = new ShowInstance($show_instance_row["instance_id"]); $temp_show->updateScheduledTime(); } RabbitMq::PushSchedule(); }
public static function GetNextItem($p_timeNow) { //get previous show and previous item in the schedule table. //Compare the two and if the last show was recorded and started //after the last item in the schedule table, then return the show's //name. Else return the last item from the schedule. $showInstance = ShowInstance::GetNextShowInstance($p_timeNow); $row = Schedule::GetNextScheduleItem($p_timeNow); if (is_null($showInstance)) { if (count($row) == 0) { return null; } else { return array("name" => $row[0]["artist_name"] . " - " . $row[0]["track_title"], "starts" => $row[0]["starts"], "ends" => $row[0]["ends"]); } } else { if (count($row) == 0) { if ($showInstance->isRecorded()) { //last item is a show instance return array("name" => $showInstance->getName(), "starts" => $showInstance->getShowStart(), "ends" => $showInstance->getShowEnd()); } else { return null; } } else { //return the one that starts sooner. if ($row[0]["starts"] <= $showInstance->getShowStart()) { return array("name" => $row[0]["artist_name"] . " - " . $row[0]["track_title"], "starts" => $row[0]["starts"], "ends" => $row[0]["ends"]); } else { return array("name" => $showInstance->getName(), "starts" => $showInstance->getShowStart(), "ends" => $showInstance->getShowEnd()); } } } }
public static function GetDataGridData($viewType, $dateString) { if ($viewType == "now") { $date = new DateHelper(); $timeNow = $date->getTimestamp(); $startCutoff = 60; $endCutoff = 86400; //60*60*24 - seconds in a day } else { $date = new DateHelper(); $time = $date->getTime(); $date->setDate($dateString . " " . $time); $timeNow = $date->getTimestamp(); $startCutoff = $date->getNowDayStartDiff(); $endCutoff = $date->getNowDayEndDiff(); } $data = array(); $showIds = ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff); foreach ($showIds as $showId) { $instanceId = $showId['id']; $si = new ShowInstance($instanceId); $showId = $si->getShowId(); $show = new Show($showId); //append show header row $data[] = Application_Model_Nowplaying::CreateHeaderRow($show->getName(), $si->getShowStart(), $si->getShowEnd()); $scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff); $dataTablesRows = Application_Model_Nowplaying::CreateDatatableRows($scheduledItems); //append show audio item rows $data = array_merge($data, $dataTablesRows); //append show gap time row $gapTime = Application_Model_Nowplaying::FormatDuration($si->getShowEndGapTime(), true); if ($si->isRecorded()) { $data[] = Application_Model_Nowplaying::CreateRecordingRow($si); } else { if ($gapTime > 0) { $data[] = Application_Model_Nowplaying::CreateGapRow($gapTime); } } } return array("currentShow" => Show_DAL::GetCurrentShow($timeNow), "rows" => $data); }
public function cancelCurrentShowAction() { $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id); if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $showInstanceId = $this->_getParam('id'); $show = new ShowInstance($showInstanceId); $show->clearShow(); $show->deleteShow(); } }
public function setRecordedFile($file_id) { $showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); $showInstance->setDbRecordedFile($file_id)->save(); $rebroadcasts = CcShowInstancesQuery::create()->filterByDbOriginalShow($this->_instanceId)->find(); foreach ($rebroadcasts as $rebroadcast) { $rebroad = new ShowInstance($rebroadcast->getDbId()); $rebroad->addFileToShow($file_id); } }
public function uploadRecordedAction() { 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; } //this file id is the recording for this show instance. $show_instance_id = $this->_getParam('showinstanceid'); $file_id = $this->_getParam('fileid'); $this->view->fileid = $file_id; $this->view->showinstanceid = $show_instance_id; $showCanceled = false; $file = StoredFile::Recall($file_id); //$show_instance = $this->_getParam('show_instance'); $show_name = null; try { $show_inst = new ShowInstance($show_instance_id); $show_inst->setRecordedFile($file_id); $show_name = $show_inst->getName(); $show_genre = $show_inst->getGenre(); $show_start_time = $show_inst->getShowStart(); } catch (Exception $e) { //we've reached here probably because the show was //cancelled, and therefore the show instance does not //exist anymore (ShowInstance constructor threw this error). //We've done all we can do (upload the file and put it in //the library), now lets just return. $showCanceled = true; } if (isset($show_name)) { $tmpTitle = "{$show_name}-{$show_start_time}"; $tmpTitle = str_replace(" ", "-", $tmpTitle); } else { $tmpTitle = $file->getName(); } $file->setMetadataValue('MDATA_KEY_TITLE', $tmpTitle); $file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder"); $file->setMetadataValue('MDATA_KEY_TRACKNUMBER', null); if (!$showCanceled && Application_Model_Preference::GetDoSoundCloudUpload()) { for ($i = 0; $i < $CC_CONFIG['soundcloud-connection-retries']; $i++) { $show = new Show($show_inst->getShowId()); $description = $show->getDescription(); $hosts = $show->getHosts(); $tags = array_merge($hosts, array($show_name)); try { $soundcloud = new ATSoundcloud(); $soundcloud_id = $soundcloud->uploadTrack($file->getFilePath(), $tmpTitle, $description, $tags, $show_start_time, $show_genre); $show_inst->setSoundCloudFileId($soundcloud_id); break; } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { $code = $e->getHttpCode(); if (!in_array($code, array(0, 100))) { break; } } sleep($CC_CONFIG['soundcloud-connection-wait']); } } $this->view->id = $file_id; }
public static function GetSystemInfo($returnArray = false) { exec('/usr/bin/airtime-check-system', $output); $output = preg_replace('/\\s+/', ' ', $output); $systemInfoArray = array(); foreach ($output as $key => &$out) { $info = explode('=', $out); if (isset($info[1])) { $key = str_replace(' ', '_', trim($info[0])); $key = strtoupper($key); $systemInfoArray[$key] = $info[1]; } } $outputArray = array(); $outputArray['STATION_NAME'] = Application_Model_Preference::GetStationName(); $outputArray['PHONE'] = Application_Model_Preference::GetPhone(); $outputArray['EMAIL'] = Application_Model_Preference::GetEmail(); $outputArray['STATION_WEB_SITE'] = Application_Model_Preference::GetStationWebSite(); $outputArray['STATION_COUNTRY'] = Application_Model_Preference::GetStationCountry(); $outputArray['STATION_CITY'] = Application_Model_Preference::GetStationCity(); $outputArray['STATION_DESCRIPTION'] = Application_Model_Preference::GetStationDescription(); // get web server info if (isset($systemInfoArray["AIRTIME_VERSION_URL"])) { $url = $systemInfoArray["AIRTIME_VERSION_URL"]; $index = strpos($url, '/api/'); $url = substr($url, 0, $index); $headerInfo = get_headers(trim($url), 1); $outputArray['WEB_SERVER'] = $headerInfo['Server'][0]; } $outputArray['NUM_OF_USERS'] = User::getUserCount(); $outputArray['NUM_OF_SONGS'] = StoredFile::getFileCount(); $outputArray['NUM_OF_PLAYLISTS'] = Playlist::getPlaylistCount(); $outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Schedule::getSchduledPlaylistCount(); $outputArray['NUM_OF_PAST_SHOWS'] = ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s")); $outputArray['UNIQUE_ID'] = Application_Model_Preference::GetUniqueId(); $outputArray = array_merge($systemInfoArray, $outputArray); $outputString = "\n"; foreach ($outputArray as $key => $out) { if ($out != '') { $outputString .= $key . ' : ' . $out . "\n"; } } if ($returnArray) { $outputArray['PROMOTE'] = Application_Model_Preference::GetPublicise(); $outputArray['LOGOIMG'] = Application_Model_Preference::GetStationLogo(); return $outputArray; } else { return $outputString; } }