Merge branch 'cc-5709-airtime-analyzer' of github.com:sourcefabric/Airtime into cc-5709-airtime-analyzer

This commit is contained in:
Albert Santoni 2014-04-23 17:42:52 -04:00
commit 0a906ba6ec
59 changed files with 51180 additions and 50667 deletions

View File

@ -9,6 +9,49 @@ class ListenerstatController extends Zend_Controller_Action
->addActionContext('get-data', 'json')
->initContext();
}
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function indexAction()
{
@ -26,25 +69,17 @@ class ListenerstatController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
//default time is the last 24 hours.
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
list($startsDT, $endsDT) = $this->getStartEnd();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$startsDT->setTimezone($userTimezone);
$endsDT->setTimezone($userTimezone);
$form = new Application_Form_DateRange();
$form->populate(array(
'his_date_start' => $start->format("Y-m-d"),
'his_time_start' => $start->format("H:i"),
'his_date_end' => $end->format("Y-m-d"),
'his_time_end' => $end->format("H:i")
'his_date_start' => $startsDT->format("Y-m-d"),
'his_time_start' => $startsDT->format("H:i"),
'his_date_end' => $endsDT->format("Y-m-d"),
'his_time_end' => $endsDT->format("H:i")
));
$errorStatus = Application_Model_StreamSetting::GetAllListenerStatErrors();
@ -63,17 +98,8 @@ class ListenerstatController extends Zend_Controller_Action
}
public function getDataAction(){
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("startTimestamp", $current_time - (60*60*24));
$ends_epoch = $request->getParam("endTimestamp", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"));
$this->_helper->json->sendJson($data);
}

View File

@ -17,35 +17,68 @@ class PlayouthistoryController extends Zend_Controller_Action
->addActionContext('update-list-item', 'json')
->addActionContext('update-file-item', 'json')
->initContext();
}
}
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function indexAction()
{
$CC_CONFIG = Config::getConfig();
$request = $this->getRequest();
$baseUrl = Application_Common_OsPath::getBaseDir();
//default time is the last 24 hours.
$now = time();
$from = $request->getParam("from", $now - (24*60*60));
$to = $request->getParam("to", $now);
$utcTimezone = new DateTimeZone("UTC");
$displayTimeZone = new DateTimeZone(Application_Model_Preference::GetTimezone());
$start = DateTime::createFromFormat("U", $from, $utcTimezone);
$start->setTimezone($displayTimeZone);
$end = DateTime::createFromFormat("U", $to, $utcTimezone);
$end->setTimezone($displayTimeZone);
list($startsDT, $endsDT) = $this->getStartEnd();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$startsDT->setTimezone($userTimezone);
$endsDT->setTimezone($userTimezone);
$form = new Application_Form_DateRange();
$form->populate(array(
'his_date_start' => $start->format("Y-m-d"),
'his_time_start' => $start->format("H:i"),
'his_date_end' => $end->format("Y-m-d"),
'his_time_end' => $end->format("H:i")
'his_date_start' => $startsDT->format("Y-m-d"),
'his_time_start' => $startsDT->format("H:i"),
'his_date_end' => $endsDT->format("Y-m-d"),
'his_time_end' => $endsDT->format("H:i")
));
$this->view->date_form = $form;
@ -87,15 +120,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{
try {
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
@ -114,18 +142,12 @@ class PlayouthistoryController extends Zend_Controller_Action
public function itemHistoryFeedAction()
{
try {
$request = $this->getRequest();
$current_time = time();
$params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$instance = $request->getParam("instance_id", null);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$request = $this->getRequest();
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance);
@ -144,12 +166,10 @@ class PlayouthistoryController extends Zend_Controller_Action
{
try {
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$params = $request->getParams();
$instance = $request->getParam("instance_id", null);
list($startsDT, $endsDT) = $this->getStartEnd();
$historyService = new Application_Service_HistoryService();
$shows = $historyService->getShowList($startsDT, $endsDT);

View File

@ -230,29 +230,66 @@ class ShowbuilderController extends Zend_Controller_Action
$end_time = $end->format("Y-m-d H:i:s");
$this->view->title = "{$show_name}: {$start_time} - {$end_time}";
$this->view->start = $instance->getDbStarts("U");
$this->view->end = $instance->getDbEnds("U");
$this->view->start = $start_time;
$this->view->end = $end_time;
$this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml');
}
private function getStartEnd()
{
$request = $this->getRequest();
$userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$utcTimezone = new DateTimeZone("UTC");
$utcNow = new DateTime("now", $utcTimezone);
$start = $request->getParam("start");
$end = $request->getParam("end");
if (empty($start) || empty($end)) {
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
else {
try {
$startsDT = new DateTime($start, $userTimezone);
$startsDT->setTimezone($utcTimezone);
$endsDT = new DateTime($end, $userTimezone);
$endsDT->setTimezone($utcTimezone);
if ($startsDT > $endsDT) {
throw new Exception("start greater than end");
}
}
catch (Exception $e) {
Logging::info($e);
Logging::info($e->getMessage());
$startsDT = clone $utcNow;
$startsDT->sub(new DateInterval("P1D"));
$endsDT = clone $utcNow;
}
}
return array($startsDT, $endsDT);
}
public function checkBuilderFeedAction()
{
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$request = $this->getRequest();
$show_filter = intval($request->getParam("showFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1));
$instances = $request->getParam("instances", array());
$my_shows = intval($request->getParam("myShows", 0));
$timestamp = intval($request->getParam("timestamp", -1));
$instances = $request->getParam("instances", array());
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
//only send the schedule back if updates have been made.
@ -263,18 +300,14 @@ class ShowbuilderController extends Zend_Controller_Action
public function builderFeedAction()
{
$request = $this->getRequest();
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$current_time = time();
$request = $this->getRequest();
$show_filter = intval($request->getParam("showFilter", 0));
$show_instance_filter = intval($request->getParam("showInstanceFilter", 0));
$my_shows = intval($request->getParam("myShows", 0));
$my_shows = intval($request->getParam("myShows", 0));
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
list($startsDT, $endsDT) = $this->getStartEnd();
$opts = array("myShows" => $my_shows,
"showFilter" => $show_filter,

View File

@ -641,6 +641,11 @@ class Application_Model_Preference
{
return self::getValue("logoImage");
}
public static function SetUniqueId($id)
{
self::setValue("uniqueId", $id);
}
public static function GetUniqueId()
{
@ -896,6 +901,11 @@ class Application_Model_Preference
return self::getValue("enable_stream_conf");
}
public static function SetAirtimeVersion($version)
{
self::setValue("system_version", $version);
}
public static function GetAirtimeVersion()
{

View File

@ -590,15 +590,14 @@ class Application_Model_Scheduler
* to that show
*/
if ($linked) {
$instance_sql = "SELECT * FROM cc_show_instances ".
"WHERE show_id = ".$ccShow["id"];
$instances = Application_Common_Database::prepareAndExecute(
$instance_sql);
$instances = CcShowInstancesQuery::create()
->filterByDbShowId($ccShow["id"])
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
->find();
} else {
$instance_sql = "SELECT * FROM cc_show_instances ".
"WHERE id = ".$schedule["instance"];
$instances = Application_Common_Database::prepareAndExecute(
$instance_sql);
$instances = CcShowInstancesQuery::create()
->filterByDbId($schedule["instance"])
->find();
}
$excludePositions = array();
@ -606,7 +605,8 @@ class Application_Model_Scheduler
//reset
$this->applyCrossfades = true;
$instanceId = $instance["id"];
//$instanceId = $instance["id"];
$instanceId = $instance->getDbId();
if ($id !== 0) {
/* We use the selected cursor's position to find the same
* positions in every other linked instance
@ -632,7 +632,7 @@ class Application_Model_Scheduler
//show instance has no scheduled tracks
if (empty($pos)) {
$pos = 0;
$nextStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
$nextStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone("UTC"));
} else {
$linkedItem_sql = "SELECT ends FROM cc_schedule ".
@ -658,7 +658,7 @@ class Application_Model_Scheduler
}
//selected empty row to add after
else {
$showStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
$showStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone("UTC"));
$nextStartDT = $this->findNextStartTime($showStartDT, $instanceId);
//first item in show so start position counter at 0

View File

@ -47,8 +47,8 @@ class CcShow extends BaseCcShow {
*/
public function getFirstCcShowDay($criteria = null, PropelPDO $con = null)
{
CcShowPeer::clearInstancePool();
CcShowPeer::clearRelatedInstancePool();
/*CcShowPeer::clearInstancePool();
CcShowPeer::clearRelatedInstancePool();*/
if(null === $this->collCcShowDayss || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowDayss) {

View File

@ -304,24 +304,20 @@ class Application_Service_SchedulerService
private static function replaceInstanceContentCheck($currentShowStamp, $showStamp)
{
/*$currentShowStamp = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->orderByDbStarts()
->find();*/
$counter = 0;
foreach ($showStamp as $item) {
if ($item["file_id"] != $currentShowStamp[$counter]["file_id"] ||
$item["stream_id"] != $currentShowStamp[$counter]["stream_id"]) {
/*CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->delete();*/
$delete_sql = "DELETE FROM cc_schedule ".
"WHERE instance_id = {$currentShowStamp[$counter]["instance_id"]}";
Application_Common_Database::prepareAndExecute(
$delete_sql, array(), Application_Common_Database::EXECUTE);
return true;
}
/*CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->delete();*/
$delete_sql = "DELETE FROM cc_schedule ".
"WHERE instance_id = {$currentShowStamp[$counter]["instance_id"]}";
Application_Common_Database::prepareAndExecute(
$delete_sql, array(), Application_Common_Database::EXECUTE);
return true;
}
$counter += 1;
}
/* If we get here, the content in the show instance is the same

View File

@ -20,6 +20,7 @@ class Application_Service_ShowService
private $localShowStartHour;
private $localShowStartMin;
private $origCcShowDay;
private $origShowRepeatStatus;
private $instanceIdsForScheduleUpdates;
public function __construct($showId=null, $showData=null, $isUpdate=false)
@ -158,8 +159,10 @@ class Application_Service_ShowService
{
if ($this->ccShow->isRepeating()) {
$this->origCcShowDay = clone $this->ccShow->getFirstRepeatingCcShowDay();
$this->origShowRepeatStatus = true;
} else {
$this->origCcShowDay = clone $this->ccShow->getFirstCcShowDay();
$this->origShowRepeatStatus = false;
}
$this->oldShowTimezone = $this->origCcShowDay->getDbTimezone();
@ -183,6 +186,7 @@ class Application_Service_ShowService
if (!$currentUser->isAdminOrPM()) {
throw new Exception("Permission denied");
}
//update ccShow
$this->setCcShow($showData);
@ -220,12 +224,15 @@ class Application_Service_ShowService
$this->delegateInstanceCreation($daysAdded);
if ($this->isUpdate) {
/* Set the show's start date to the start date of the first instance.
* We need to do this so we get the correct time diff for
* updating show content. CC-5696
/* If the show is repeating and the start date changes we need
* to ignore that difference when re-calculating schedule start times.
* Otherwise it might calculate a difference of a week, for example.
*/
$showData["add_show_start_date"] = $this->ccShow->getFirstCcShowDay()->getDbFirstShow();
$showData["add_show_start_time"] = $this->ccShow->getFirstCcShowDay()->getDbStartTime();
if ($this->ccShow->isRepeating() &&
$this->origCcShowDay->getLocalStartDateAndTime()->format("Y-m-d") != $showData["add_show_start_date"]) {
$showData["add_show_start_date"] = $this->origCcShowDay->getLocalStartDateAndTime()->format("Y-m-d");
}
$this->adjustSchedule($showData);
}
@ -411,6 +418,13 @@ SQL;
':timestamp' => gmdate("Y-m-d H:i:s")), 'execute');
}
private function deleteAllShowDays($showId)
{
CcShowDaysQuery::create()
->filterByDbShowId($showId)
->delete();
}
/**
* TODO: This function is messy. Needs refactoring
*
@ -432,8 +446,14 @@ SQL;
//CcShowDay object
if ($this->ccShow->isRepeating()) {
$currentShowDay = $this->ccShow->getFirstRepeatingCcShowDay();
//all cc_show_days
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
} else {
$currentShowDay = $this->ccShow->getFirstCcShowDay();
//all cc_show_days
$ccShowDays = $this->ccShow->getCcShowDayss();
}
//new end date in the show's timezone (from the select box)
@ -442,6 +462,11 @@ SQL;
//repeat option was toggled
if ($showData['add_show_repeats'] != $currentShowDay->isRepeating()) {
$this->deleteAllRepeatInstances($currentShowDay, $showId);
if (!$showData["add_show_repeats"]) {
$this->deleteAllShowDays($showId);
}
//if repeat option was checked we need to treat the current show day
//as a new show day so the repeat instances get created properly
//in createWeeklyRepeatInstances()
@ -473,17 +498,13 @@ SQL;
//and the repeat type changed
if ($currentRepeatType != -1 && $this->repeatType != $currentRepeatType) {
$this->deleteAllInstances($showId);
$this->deleteAllShowDays($showId);
// when repeating by day of the month (1st, 2nd, etc.) we do not store the repeat week days
} elseif ($currentRepeatType != 2) {
//repeat type is the same, check if the days of the week are the same
$repeatingDaysChanged = false;
if ($this->ccShow->isRepeating()) {
$ccShowDays = $this->ccShow->getRepeatingCcShowDays();
} else {
$ccShowDays = $this->ccShow->getCcShowDayss();
}
$showDays = array();
foreach ($ccShowDays as $day) {
$showDays[] = $day->getDbDay();
@ -534,12 +555,11 @@ SQL;
//check if this is null if "no end"
$currentShowEndDateTime = $this->getRepeatingEndDate();
if ($currentShowEndDateTime != $endDateTime) {
if ($endDateTime && $currentShowEndDateTime != $endDateTime) {
$endDate = clone $endDateTime;
$endDate->setTimezone(new DateTimeZone("UTC"));
//show "No End" option was toggled
//show's "No End" option was toggled
//or the end date comes earlier
if (is_null($currentShowEndDateTime) || ($endDateTime < $currentShowEndDateTime)) {
//"No End" option was unchecked so we need to delete the
@ -557,11 +577,14 @@ SQL;
private function preserveLinkedShowContent()
{
/* Get show content from any linekd instance. It doesn't
/* Get show content from any linked instance. It doesn't
* matter which instance since content is the same in all.
*/
$ccShowInstance = $this->ccShow->getCcShowInstancess()->getFirst();
if (!$ccShowInstance) {
return;
}
$ccSchedules = CcScheduleQuery::create()
->filterByDbInstanceId($ccShowInstance->getDbId())
->find();
@ -1509,8 +1532,12 @@ SQL;
if ($this->isUpdate) {
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($showId)
->filterByDbRepeatType($showData['add_show_repeat_type'])
->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
->findOne();
if (!$showDay) {
//repeat type changed so we have to create a new show_day rule
$showDay = new CcShowDays();
}
} else {
$showDay = new CcShowDays();
}
@ -1542,16 +1569,30 @@ SQL;
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
if ($this->isUpdate) {
if ($this->origCcShowDay->getDbRepeatType() == 2 ||
$this->origCcShowDay->getDbRepeatType() == 3) {
$day = null;
} else if (!$this->origShowRepeatStatus) {
//keep current show day to use for updating cc_show_day rule
$keepDay = $day;
$day = $this->origCcShowDay->getDbDay();
}
$showDay = CcShowDaysQuery::create()
->filterByDbShowId($showId)
->filterByDbRepeatType($this->repeatType)
->filterByDbRepeatType($this->origCcShowDay->getDbRepeatType())
->filterByDbDay($day)
->findOne();
if (!$showDay) {
//if no show day object was found it is because a new
//repeating day of the week was added
//repeating day of the week was added OR the repeat
//type has changed
$showDay = new CcShowDays();
}
if (isset($keepDay)) {
$day = $keepDay;
}
} else {
$showDay = new CcShowDays();
}

View File

@ -330,16 +330,28 @@ INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('en_GB', 'English (Brit
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('en_US', 'English (USA)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('cs_CZ', 'Český');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('de_DE', 'Deutsch');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('de_AT', 'Österreichisches Deutsch');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hu_HU', 'Magyar');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('de_AT', 'Deutsch (Österreich)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('el_GR', 'Ελληνικά');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('es_ES', 'Español');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('fr_FR', 'Français');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hr_HR', 'Hrvatski');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hu_HU', 'Magyar');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('it_IT', 'Italiano');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('ko_KR', '한국어');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('pl_PL', 'Polski');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('pt_BR', 'Português Brasileiro');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('pt_BR', 'Português (Brasil)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('ru_RU', 'Русский');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS', 'Српски (Ћирилица)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS@latin', 'Srpski (Latinica)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('zh_CN', '简体中文');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('el_GR', 'Ελληνικά');
-- end of added in 2.3
-- added in 2.5.2
INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'UTC');
INSERT INTO cc_pref (subjid, keystr, valstr) VALUES (1, 'user_timezone', 'UTC');
INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0');
--end added in 2.5.2

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -194,3 +194,7 @@
#history_content .ui-tabs .ui-tabs-panel {
padding-top: 10px;
}
div.his-timerange input.error {
background-color: rgba(255,0,0,0.2);
}

View File

@ -2,7 +2,7 @@
#history_content {
width: 100%;
margin: 0px;
margin: 0 0 30px 0;
height: auto;
box-sizing: border-box;
}

View File

@ -14,15 +14,17 @@ $(document).ready(function() {
getDataAndPlot();
listenerstat_content.find("#his_submit").click(function(){
startTimestamp = AIRTIME.utilities.fnGetTimestamp(dateStartId, timeStartId);
endTimestamp = AIRTIME.utilities.fnGetTimestamp(dateEndId, timeEndId);
getDataAndPlot(startTimestamp, endTimestamp);
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
var start = oRange.start;
var end = oRange.end;
getDataAndPlot(start, end);
});
});
function getDataAndPlot(startTimestamp, endTimestamp){
// get data
$.get(baseUrl+'Listenerstat/get-data', {startTimestamp: startTimestamp, endTimestamp: endTimestamp}, function(data){
$.get(baseUrl+'Listenerstat/get-data', {start: startTimestamp, end: endTimestamp}, function(data){
out = new Object();
$.each(data, function(mpName, v){
plotData = new Object();

View File

@ -60,6 +60,30 @@ var AIRTIME = (function(AIRTIME) {
oTableShow,
inShowsTab = false;
function validateTimeRange() {
var oRange,
inputs = $('.his-timerange > input'),
start, end;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
start = oRange.start;
end = oRange.end;
if (end >= start) {
inputs.removeClass('error');
}
else {
inputs.addClass('error');
}
return {
start: start,
end: end,
isValid: end >= start
};
}
function getSelectedLogItems() {
var items = Object.keys(selectedLogItems);
@ -401,13 +425,12 @@ var AIRTIME = (function(AIRTIME) {
return oTable;
}
function showSummaryList() {
function showSummaryList(start, end) {
var url = baseUrl+"playouthistory/show-history-feed",
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId),
data = {
format: "json",
start: oRange.start,
end: oRange.end
start: start,
end: end
};
$.post(url, data, function(json) {
@ -460,7 +483,9 @@ var AIRTIME = (function(AIRTIME) {
},
always: function() {
inShowsTab = true;
showSummaryList();
var info = getStartEnd();
showSummaryList(info.start, info.end);
emptySelectedLogItems();
}
}
@ -544,7 +569,8 @@ var AIRTIME = (function(AIRTIME) {
dayNamesMin: i18n_days_short,
onSelect: function(sDate, oDatePicker) {
$(this).datepicker( "setDate", sDate );
}
},
onClose: validateTimeRange
};
oBaseTimePickerSettings = {
@ -554,13 +580,25 @@ var AIRTIME = (function(AIRTIME) {
showLeadingZero: false,
defaultTime: '0:00',
hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute")
minuteText: $.i18n._("Minute"),
onClose: validateTimeRange
};
$historyContentDiv.find(dateStartId).datepicker(oBaseDatePickerSettings);
$historyContentDiv.find(timeStartId).timepicker(oBaseTimePickerSettings);
$historyContentDiv.find(dateEndId).datepicker(oBaseDatePickerSettings);
$historyContentDiv.find(timeEndId).timepicker(oBaseTimePickerSettings);
$historyContentDiv.find(dateStartId)
.datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.find(timeStartId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.find(dateEndId)
.datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.find(timeEndId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange);
$historyContentDiv.on("click", "#his_create", function(e) {
var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
@ -665,17 +703,16 @@ var AIRTIME = (function(AIRTIME) {
});
$('body').on("click", "#his_instance_retrieve", function(e) {
var startPicker = $hisDialogEl.find('#his_item_starts_datetimepicker').data('datetimepicker'),
endPicker = $hisDialogEl.find('#his_item_ends_datetimepicker').data('datetimepicker'),
var startPicker = $hisDialogEl.find('#his_item_starts'),
endPicker = $hisDialogEl.find('#his_item_ends'),
url = baseUrl+"playouthistory/show-history-feed",
startDate = startPicker.getLocalDate(),
endDate = endPicker.getLocalDate(),
getEpochSeconds = AIRTIME.utilities.fnGetSecondsEpoch,
startDate = startPicker.val(),
endDate = endPicker.val(),
data;
data = {
start: getEpochSeconds(startDate),
end: getEpochSeconds(endDate),
start: startDate,
end: endDate,
format: "json"
};
@ -710,18 +747,23 @@ var AIRTIME = (function(AIRTIME) {
});
});
function getStartEnd() {
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
}
$historyContentDiv.find("#his_submit").click(function(ev){
var fn,
oRange;
info;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
info = getStartEnd();
fn = fnServerData;
fn.start = oRange.start;
fn.end = oRange.end;
fn.start = info.start;
fn.end = info.end;
if (inShowsTab) {
showSummaryList();
showSummaryList(info.start, info.end);
}
else {
redrawTables();

View File

@ -46,7 +46,8 @@ AIRTIME = (function(AIRTIME) {
showLeadingZero: false,
defaultTime: '0:00',
hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute")
minuteText: $.i18n._("Minute"),
onClose: validateTimeRange
};
function setWidgetSize() {

View File

@ -35,75 +35,39 @@ var AIRTIME = (function(AIRTIME){
};
};
mod.fnGetSecondsEpoch = function(oDate) {
var iTime,
iUserOffset,
iClientOffset;
iTime = oDate.getTime(); //value is in millisec.
iTime = Math.round(iTime / 1000);
iUserOffset = userTimezoneOffset;
iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
//adjust for the fact the the Date object is in client time.
iTime = iTime + iClientOffset + iUserOffset;
return iTime;
};
/*
* Get the schedule range start in unix timestamp form (in seconds).
* defaults to NOW if nothing is selected.
*
* @param String sDatePickerId
*
* @param String sTimePickerId
*
* @return Number iTime
*/
mod.fnGetTimestamp = function(sDateId, sTimeId) {
var date,
time,
temp;
temp = $(sDateId).val();
if ( temp === "") {
return 0;
}
else {
date = temp;
}
time = $(sTimeId).val();
date = date.split("-");
time = time.split(":");
//0 based month in js.
oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
return mod.fnGetSecondsEpoch(oDate);
};
/*
* Returns an object containing a unix timestamp in seconds for the start/end range
*
* @return Object {"start", "end", "range"}
*/
mod.fnGetScheduleRange = function(dateStart, timeStart, dateEnd, timeEnd) {
var iStart,
iEnd,
iRange;
mod.fnGetScheduleRange = function(dateStartId, timeStartId, dateEndId, timeEndId) {
var start,
end,
time;
iStart = AIRTIME.utilities.fnGetTimestamp(dateStart, timeStart);
iEnd = AIRTIME.utilities.fnGetTimestamp(dateEnd, timeEnd);
start = $(dateStartId).val();
start = start === "" ? null : start;
iRange = iEnd - iStart;
time = $(timeStartId).val();
time = time === "" ? "00:00" : time;
if (start) {
start = start + " " + time;
}
end = $(dateEndId).val();
end = end === "" ? null : end;
time = $(timeEndId).val();
time = time === "" ? "00:00" : time;
if (end) {
end = end + " " + time;
}
return {
start: iStart,
end: iEnd,
range: iRange
start: start,
end: end
};
};

View File

@ -0,0 +1,19 @@
//Croatian
{
"sProcessing": "Procesiram...",
"sLengthMenu": "Prikaži _MENU_ rezultata po stranici",
"sZeroRecords": "Ništa nije pronađeno",
"sInfo": "Prikazano _START_ do _END_ od _TOTAL_ rezultata",
"sInfoEmpty": "Prikazano 0 do 0 od 0 rezultata",
"sInfoFiltered": "(filtrirano iz _MAX_ ukupnih rezultata)",
"sInfoPostFix": "",
"sSearch": "Filter",
"sUrl": "",
"oPaginate": {
"sFirst": "Prva",
"sPrevious": "Nazad",
"sNext": "Naprijed",
"sLast": "Zadnja"
}
}

View File

@ -0,0 +1,19 @@
//Serbian Cyrillic
{
"sProcessing": "Обрада...",
"sLengthMenu": "_MENU_ Резултати по страници",
"sZeroRecords": "Ништа није пронађено",
"sInfo": "Резултати: _START_ - _END_ Укупно: _TOTAL_",
"sInfoEmpty": "Нула Резултат",
"sInfoFiltered": "(филтрирано из _MAX_ укупних резултата)",
"sInfoPostFix": "",
"sSearch": "Филтер",
"sUrl": "",
"oPaginate": {
"sFirst": "Прва",
"sPrevious": "Назад",
"sNext": "Напред",
"sLast": "Задња"
}
}

View File

@ -0,0 +1,19 @@
//Serbian Latin
{
"sProcessing": "Obrada...",
"sLengthMenu": "_MENU_ Rezultati po stranici",
"sZeroRecords": "Ništa nije pronađeno",
"sInfo": "Rezultati: _START_ - _END_ Ukupno: _TOTAL_",
"sInfoEmpty": "Nula Rezultat",
"sInfoFiltered": "(filtrirano iz _MAX_ ukupnih rezultata)",
"sInfoPostFix": "",
"sSearch": "Filter",
"sUrl": "",
"oPaginate": {
"sFirst": "Prva",
"sPrevious": "Nazad",
"sNext": "Napred",
"sLast": "Zadnja"
}
}

View File

@ -0,0 +1,25 @@
// Croatian
plupload.addI18n({
'Select files': 'Izaberite datoteke:',
'Add files to the upload queue and click the start button.': 'Dodajte datoteke u listu i kliknite Upload.',
'Filename': 'Ime datoteke',
'Status': 'Status',
'Size': 'Veličina',
'Add files': 'Dodajte datoteke',
'Stop current upload': 'Zaustavi trenutan upload',
'Start uploading queue': 'Pokreni Upload',
'Uploaded %d/%d files': 'Uploadano %d/%d datoteka',
'N/A': 'N/A',
'Drag files here.': 'Dovucite datoteke ovdje',
'File extension error.': 'Greška ekstenzije datoteke.',
'File size error.': 'Greška veličine datoteke.',
'Init error.': 'Greška inicijalizacije.',
'HTTP Error.': 'HTTP greška.',
'Security error.': 'Sigurnosna greška.',
'Generic error.': 'Generička greška.',
'IO error.': 'I/O greška.',
'Stop Upload': 'Zaustavi upload.',
'Add Files': 'Dodaj datoteke',
'Start Upload': 'Pokreni upload.',
'%d files queued': '%d datoteka na čekanju.'
});

View File

@ -0,0 +1,14 @@
// Serbian Cyrillic
plupload.addI18n({
'Select files' : 'Изаберите фајлове',
'Add files to the upload queue and click the start button.' : 'Додајте фајлове у листу и кликните на дугме Старт.',
'Filename' : 'Назив фајла',
'Status' : 'Status',
'Size' : 'Величина',
'Add Files' : 'Додај фајлове',
'Stop current upload' : 'Заустави upload',
'Start uploading queue' : 'Почни upload',
'Drag files here.' : 'Превуци фајлове овде.',
'Start Upload': 'Почни upload',
'Uploaded %d/%d files': 'Снимљено %d/%d фајлова'
});

View File

@ -0,0 +1,14 @@
// Serbian Latin
plupload.addI18n({
'Select files' : 'Izaberite fajlove',
'Add files to the upload queue and click the start button.' : 'Dodajte fajlove u listu i kliknite na dugme Start.',
'Filename' : 'Naziv fajla',
'Status' : 'Status',
'Size' : 'Veličina',
'Add Files' : 'Dodaj fajlove',
'Stop current upload' : 'Zaustavi upload',
'Start uploading queue' : 'Počni upload',
'Drag files here.' : 'Prevucite fajlove ovde.',
'Start Upload': 'Počni upload',
'Uploaded %d/%d files': 'Snimljeno %d/%d fajlova'
});

0
airtime_mvc/tests/airtime.conf Executable file → Normal file
View File

View File

@ -611,7 +611,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_start_date"] = "2016-01-29";
$data["add_show_day_check"] = array(5);
$data["add_show_day_check"] = array(5, 6);
$data["add_show_linked"] = 1;
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
@ -661,4 +661,69 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds
);
}
public function testChangeRepeatTypeFromWeeklyToNoRepeat()
{
TestHelper::loginUser();
//test change repeat type from weekly to no-repeat
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_repeats"] = 0;
$data["add_show_id"] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_weeklyToNoRepeat.xml"),
$ds
);
}
public function testChangeRepeatTypeFromWeeklyToBiWeekly()
{
TestHelper::loginUser();
//test change repeat type weekly to bi-weekly
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_id"] = 1;
$data["add_show_repeat_type"] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
$this->createXmlDataSet(dirname(__FILE__)."/datasets/test_weeklyToBiWeekly.xml"),
$ds
);
}
public function testChangeRepeatTypeFromMonthlyWeeklyToNoRepeat()
{
}
}

View File

@ -0,0 +1,107 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<row>
<value>1</value>
<value>test show</value>
<null />
<null />
<null />
<value>ffffff</value>
<value>364492</value>
<value></value>
<value></value>
<null />
<null />
<value></value>
<value>1</value>
</row>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
<row>
<value>2</value>
<value>2016-01-01</value>
<null />
<value>00:00:00</value>
<value>UTC</value>
<value>01:00</value>
<value>5</value>
<value>1</value>
<value>2016-02-12</value>
<value>1</value>
<value>0</value>
</row>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>modified_instance</column>
<row>
<value>7</value>
<value>2016-01-01 00:00:00</value>
<value>2016-01-01 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
<row>
<value>8</value>
<value>2016-01-15 00:00:00</value>
<value>2016-01-15 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
<row>
<value>9</value>
<value>2016-01-29 00:00:00</value>
<value>2016-01-29 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
</table>
<table name="cc_show_rebroadcast">
</table>
<table name="cc_show_hosts">
</table>
</dataset>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" ?>
<dataset>
<table name="cc_show">
<column>id</column>
<column>name</column>
<column>url</column>
<column>genre</column>
<column>description</column>
<column>color</column>
<column>background_color</column>
<column>live_stream_using_airtime_auth</column>
<column>live_stream_using_custom_auth</column>
<column>live_stream_user</column>
<column>live_stream_pass</column>
<column>linked</column>
<column>is_linkable</column>
<row>
<value>1</value>
<value>test show</value>
<null />
<null />
<null />
<value>ffffff</value>
<value>364492</value>
<value></value>
<value></value>
<null />
<null />
<value></value>
<value>1</value>
</row>
</table>
<table name="cc_show_days">
<column>id</column>
<column>first_show</column>
<column>last_show</column>
<column>start_time</column>
<column>timezone</column>
<column>duration</column>
<column>day</column>
<column>repeat_type</column>
<column>next_pop_date</column>
<column>show_id</column>
<column>record</column>
<row>
<value>2</value>
<value>2016-01-01</value>
<null />
<value>00:00:00</value>
<value>UTC</value>
<value>01:00</value>
<value>5</value>
<value>-1</value>
<value>2016-01-01</value>
<value>1</value>
<value>0</value>
</row>
</table>
<table name="cc_show_instances">
<column>id</column>
<column>starts</column>
<column>ends</column>
<column>show_id</column>
<column>record</column>
<column>rebroadcast</column>
<column>instance_id</column>
<column>modified_instance</column>
<row>
<value>1</value>
<value>2016-01-01 00:00:00</value>
<value>2016-01-01 01:00:00</value>
<value>1</value>
<value>0</value>
<value>0</value>
<null />
<value></value>
</row>
</table>
<table name="cc_show_rebroadcast">
</table>
<table name="cc_show_hosts">
</table>
</dataset>

View File

@ -27,5 +27,11 @@ export RABBITMQ_PASSWORD
export RABBITMQ_VHOST
export AIRTIME_UNIT_TEST="1"
#Change the working directory to this script's directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
#Run the unit tests
phpunit --log-junit test_results.xml

View File

@ -308,62 +308,15 @@ class AirtimeInstall
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
$con->exec($sql);
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$p_version')";
$result = $con->exec($sql);
if ($result < 1) {
return false;
}
return true;
Application_Model_Preference::SetAirtimeVersion($p_version);
}
public static function SetUniqueId()
{
$con = Propel::getConnection();
$uniqueId = md5(uniqid("", true));
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
$result = $con->exec($sql);
if ($result < 1) {
return false;
}
return true;
Application_Model_Preference::SetUniqueId($uniqueId);
}
public static function SetDefaultTimezone()
{
$con = Propel::getConnection();
// we need to run php as commandline because we want to get the timezone in cli php.ini file
//$defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'");
$defaultTimezone = exec("cat /etc/timezone");
$defaultTimezone = trim($defaultTimezone);
if((!in_array($defaultTimezone, DateTimeZone::listIdentifiers()))){
$defaultTimezone = "UTC";
}
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')";
$result = $con->exec($sql);
if ($result < 1) {
return false;
}
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr) VALUES (1, 'user_timezone', '$defaultTimezone')";
$result = $con->exec($sql);
if ($result < 1) {
return false;
}
return true;
}
public static function SetImportTimestamp()
{
$con = Propel::getConnection();
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')";
$result = $con->exec($sql);
if ($result < 1) {
return false;
}
return true;
}
public static function GetAirtimeVersion()
{
$con = Propel::getConnection();

View File

@ -10,10 +10,19 @@ require_once(__DIR__.'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
//Propel classes.
set_include_path(AirtimeInstall::GetAirtimeSrcDir().'/application/models' . PATH_SEPARATOR . get_include_path());
$CC_CONFIG = Config::getConfig();
require_once 'propel/runtime/lib/Propel.php';
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
//use this class to set new values in the cache as well.
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/common/Database.php');
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/models/Preference.php');
echo PHP_EOL."* Database Installation".PHP_EOL;
AirtimeInstall::CreateDatabaseUser();
@ -56,10 +65,8 @@ AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);
if (AirtimeInstall::$databaseTablesCreated) {
AirtimeInstall::SetDefaultTimezone();
// set up some keys in DB
AirtimeInstall::SetUniqueId();
AirtimeInstall::SetImportTimestamp();
$ini = parse_ini_file(__DIR__."/airtime-install.ini");

View File

@ -0,0 +1,8 @@
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hr_HR', 'Hrvatski');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS', 'Српски (Ћирилица)');
INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS@latin', 'Srpski (Latinica)');
UPDATE cc_locale SET locale_lang='Deutsch (Österreich)' WHERE locale_code='de_AT';
UPDATE cc_locale SET locale_lang='Português Brasileiro' WHERE locale_code='pt_BR';
-- NOTE BECAUSE OF CACHING NOW ANY UPGRADES TO cc_pref MUST NOT BE DONE HERE.

View File

@ -56,6 +56,8 @@ def get_file_type(file_path):
file_type = 'mp3'
elif re.search(r'og(g|a)$', file_path, re.IGNORECASE):
file_type = 'vorbis'
elif re.search(r'm4a$', file_path, re.IGNORECASE):
file_type = 'mp4'
elif re.search(r'flac$', file_path, re.IGNORECASE):
file_type = 'flac'
else:
@ -64,6 +66,8 @@ def get_file_type(file_path):
file_type = 'mp3'
elif 'ogg' in mime_type:
file_type = 'vorbis'
elif 'mp4' in mime_type:
file_type = 'mp4'
elif 'flac' in mime_type:
file_type = 'flac'
@ -111,6 +115,14 @@ def calculate_replay_gain(file_path):
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
else:
logger.warn("vorbisgain/ogginfo not found")
elif file_type == 'mp4':
if run_process(['which', 'aacgain']) == 0:
command = ['nice', '-n', nice_level, 'aacgain', '-q', temp_file_path]
out = get_process_output(command)
search = re.search(r'Recommended "Track" dB change: (.*)', \
out)
else:
logger.warn("aacgain not found")
elif file_type == 'flac':
if run_process(['which', 'metaflac']) == 0:

View File

@ -117,76 +117,79 @@ class PypoLiquidsoap():
#independent_event: true
#},
try:
scheduled_now_files = \
filter(lambda x: x["type"] == eventtypes.FILE, scheduled_now)
scheduled_now_files = \
filter(lambda x: x["type"] == eventtypes.FILE, scheduled_now)
scheduled_now_webstream = \
filter(lambda x: x["type"] == eventtypes.STREAM_OUTPUT_START, \
scheduled_now)
scheduled_now_webstream = \
filter(lambda x: x["type"] == eventtypes.STREAM_OUTPUT_START, \
scheduled_now)
schedule_ids = set(map(lambda x: x["row_id"], scheduled_now_files))
schedule_ids = set(map(lambda x: x["row_id"], scheduled_now_files))
row_id_map = {}
liq_queue_ids = set()
for i in self.liq_queue_tracker:
mi = self.liq_queue_tracker[i]
if not self.is_media_item_finished(mi):
liq_queue_ids.add(mi["row_id"])
row_id_map[mi["row_id"]] = mi
to_be_removed = set()
to_be_added = set()
#Iterate over the new files, and compare them to currently scheduled
#tracks. If already in liquidsoap queue still need to make sure they don't
#have different attributes
#if replay gain changes, it shouldn't change the amplification of the currently playing song
for i in scheduled_now_files:
if i["row_id"] in row_id_map:
mi = row_id_map[i["row_id"]]
correct = mi['start'] == i['start'] and \
mi['end'] == i['end'] and \
mi['row_id'] == i['row_id']
if not correct:
#need to re-add
self.logger.info("Track %s found to have new attr." % i)
to_be_removed.add(i["row_id"])
to_be_added.add(i["row_id"])
to_be_removed.update(liq_queue_ids - schedule_ids)
to_be_added.update(schedule_ids - liq_queue_ids)
if to_be_removed:
self.logger.info("Need to remove items from Liquidsoap: %s" % \
to_be_removed)
#remove files from Liquidsoap's queue
row_id_map = {}
liq_queue_ids = set()
for i in self.liq_queue_tracker:
mi = self.liq_queue_tracker[i]
if mi is not None and mi["row_id"] in to_be_removed:
self.stop(i)
if not self.is_media_item_finished(mi):
liq_queue_ids.add(mi["row_id"])
row_id_map[mi["row_id"]] = mi
if to_be_added:
self.logger.info("Need to add items to Liquidsoap *now*: %s" % \
to_be_added)
to_be_removed = set()
to_be_added = set()
for i in scheduled_now:
if i["row_id"] in to_be_added:
self.modify_cue_point(i)
self.play(i)
#Iterate over the new files, and compare them to currently scheduled
#tracks. If already in liquidsoap queue still need to make sure they don't
#have different attributes
#if replay gain changes, it shouldn't change the amplification of the currently playing song
for i in scheduled_now_files:
if i["row_id"] in row_id_map:
mi = row_id_map[i["row_id"]]
correct = mi['start'] == i['start'] and \
mi['end'] == i['end'] and \
mi['row_id'] == i['row_id']
if not correct:
#need to re-add
self.logger.info("Track %s found to have new attr." % i)
to_be_removed.add(i["row_id"])
to_be_added.add(i["row_id"])
to_be_removed.update(liq_queue_ids - schedule_ids)
to_be_added.update(schedule_ids - liq_queue_ids)
if to_be_removed:
self.logger.info("Need to remove items from Liquidsoap: %s" % \
to_be_removed)
#remove files from Liquidsoap's queue
for i in self.liq_queue_tracker:
mi = self.liq_queue_tracker[i]
if mi is not None and mi["row_id"] in to_be_removed:
self.stop(i)
if to_be_added:
self.logger.info("Need to add items to Liquidsoap *now*: %s" % \
to_be_added)
for i in scheduled_now_files:
if i["row_id"] in to_be_added:
self.modify_cue_point(i)
self.play(i)
#handle webstreams
current_stream_id = self.telnet_liquidsoap.get_current_stream_id()
if scheduled_now_webstream:
if int(current_stream_id) != int(scheduled_now_webstream[0]["row_id"]):
self.play(scheduled_now_webstream[0])
elif current_stream_id != "-1":
#something is playing and it shouldn't be.
self.telnet_liquidsoap.stop_web_stream_buffer()
self.telnet_liquidsoap.stop_web_stream_output()
except KeyError as e:
self.logger.error("Error: Malformed event in schedule. " + str(e))
#handle webstreams
current_stream_id = self.telnet_liquidsoap.get_current_stream_id()
if scheduled_now_webstream:
if int(current_stream_id) != int(scheduled_now_webstream[0]["row_id"]):
self.play(scheduled_now_webstream[0])
elif current_stream_id != "-1":
#something is playing and it shouldn't be.
self.telnet_liquidsoap.stop_web_stream_buffer()
self.telnet_liquidsoap.stop_web_stream_output()
def stop(self, queue):
self.telnet_liquidsoap.queue_remove(queue)
@ -200,8 +203,7 @@ class PypoLiquidsoap():
self.liq_queue_tracker[i] = None
def modify_cue_point(self, link):
if not self.is_file(link):
return
assert self.is_file(link)
tnow = datetime.utcnow()

View File

@ -153,8 +153,10 @@ class PypoPush(Thread):
self.telnet_lock.release()
def run(self):
try: self.main()
except Exception, e:
top = traceback.format_exc()
self.logger.error('Pypo Push Exception: %s', top)
while True:
try: self.main()
except Exception, e:
top = traceback.format_exc()
self.logger.error('Pypo Push Exception: %s', top)
time.sleep(5)