Merge branch '2.5.x' of dev.sourcefabric.org:airtime into 2.5.x
This commit is contained in:
commit
3d9bc85fa0
|
@ -1042,12 +1042,15 @@ class ApiController extends Zend_Controller_Action
|
|||
{
|
||||
$request = $this->getRequest();
|
||||
$data = $request->getParam("data");
|
||||
$media_id = $request->getParam("media_id");
|
||||
$media_id = intval($request->getParam("media_id"));
|
||||
$data_arr = json_decode($data);
|
||||
|
||||
//$media_id is -1 sometimes when a stream has stopped playing
|
||||
if (!is_null($media_id) && $media_id > 0) {
|
||||
|
||||
if (!is_null($media_id)) {
|
||||
if (isset($data_arr->title) &&
|
||||
strlen($data_arr->title) < 1024) {
|
||||
if (isset($data_arr->title)) {
|
||||
|
||||
$data_title = substr($data_arr->title, 0, 1024);
|
||||
|
||||
$previous_metadata = CcWebstreamMetadataQuery::create()
|
||||
->orderByDbStartTime('desc')
|
||||
|
@ -1056,23 +1059,27 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
$do_insert = true;
|
||||
if ($previous_metadata) {
|
||||
if ($previous_metadata->getDbLiquidsoapData() == $data_arr->title) {
|
||||
Logging::debug("Duplicate found: ".$data_arr->title);
|
||||
if ($previous_metadata->getDbLiquidsoapData() == $data_title) {
|
||||
Logging::debug("Duplicate found: ". $data_title);
|
||||
$do_insert = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($do_insert) {
|
||||
|
||||
$startDT = new DateTime("now", new DateTimeZone("UTC"));
|
||||
|
||||
$webstream_metadata = new CcWebstreamMetadata();
|
||||
$webstream_metadata->setDbInstanceId($media_id);
|
||||
$webstream_metadata->setDbStartTime(new DateTime("now", new DateTimeZone("UTC")));
|
||||
$webstream_metadata->setDbLiquidsoapData($data_arr->title);
|
||||
$webstream_metadata->setDbStartTime($startDT);
|
||||
$webstream_metadata->setDbLiquidsoapData($data_title);
|
||||
$webstream_metadata->save();
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$historyService->insertWebstreamMetadata($media_id, $startDT, $data_arr);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Null value of media_id");
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->response = $data;
|
||||
$this->view->media_id = $media_id;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
require_once( __DIR__ . '/../validate/NotDemoValidate.php');
|
||||
|
||||
class Application_Form_AddUser extends Zend_Form
|
||||
{
|
||||
|
@ -12,7 +13,8 @@ class Application_Form_AddUser extends Zend_Form
|
|||
* */
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator();
|
||||
|
||||
$notDemoValidator = new Application_Validate_NotDemoValidate();
|
||||
|
||||
$this->setAttrib('id', 'user_form');
|
||||
|
||||
$hidden = new Zend_Form_Element_Hidden('user_id');
|
||||
|
@ -42,6 +44,7 @@ class Application_Form_AddUser extends Zend_Form
|
|||
$passwordVerify->setRequired(true);
|
||||
$passwordVerify->addFilter('StringTrim');
|
||||
$passwordVerify->addValidator($notEmptyValidator);
|
||||
$passwordVerify->addValidator($notDemoValidator);
|
||||
$this->addElement($passwordVerify);
|
||||
|
||||
$firstName = new Zend_Form_Element_Text('first_name');
|
||||
|
|
|
@ -43,7 +43,7 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory
|
|||
$ends->addFilter('StringTrim');
|
||||
$ends->setLabel(_('End Time'));
|
||||
$ends->setDecorators(array('ViewHelper'));
|
||||
$ends->setRequired(true);
|
||||
//$ends->setRequired(true);
|
||||
$this->addElement($ends);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
require_once( __DIR__ . '/../validate/NotDemoValidate.php');
|
||||
|
||||
class Application_Form_EditUser extends Zend_Form
|
||||
{
|
||||
|
@ -16,7 +17,8 @@ class Application_Form_EditUser extends Zend_Form
|
|||
$userData = Application_Model_User::GetUserData($currentUserId);
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator();
|
||||
|
||||
$notDemoValidator = new Application_Validate_NotDemoValidate();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/edit-user.phtml', "currentUser" => $currentUser->getLogin()))));
|
||||
$this->setAttrib('id', 'current-user-form');
|
||||
|
@ -52,6 +54,7 @@ class Application_Form_EditUser extends Zend_Form
|
|||
$passwordVerify->setRequired(true);
|
||||
$passwordVerify->addFilter('StringTrim');
|
||||
$passwordVerify->addValidator($notEmptyValidator);
|
||||
$passwordVerify->addValidator($notDemoValidator);
|
||||
$passwordVerify->setDecorators(array('viewHelper'));
|
||||
$this->addElement($passwordVerify);
|
||||
|
||||
|
|
|
@ -14,5 +14,21 @@
|
|||
* @package propel.generator.airtime
|
||||
*/
|
||||
class CcPlayoutHistoryMetaData extends BaseCcPlayoutHistoryMetaData {
|
||||
|
||||
/**
|
||||
* Set the value of [value] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return CcPlayoutHistoryMetaData The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbValue($v)
|
||||
{
|
||||
//make sure the metadata isn't longer than the DB field.
|
||||
$v = substr($v, 0, 128);
|
||||
|
||||
parent::setDbValue($v);
|
||||
|
||||
return $this;
|
||||
} // setDbValue()
|
||||
|
||||
} // CcPlayoutHistoryMetaData
|
||||
|
|
|
@ -41,7 +41,7 @@ class CcPlayoutHistoryTableMap extends TableMap {
|
|||
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null);
|
||||
$this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null);
|
||||
$this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', true, null, null);
|
||||
$this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', false, null, null);
|
||||
$this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'ID', false, null, null);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
|
|
@ -290,9 +290,12 @@ class Application_Service_HistoryService
|
|||
$dateTime->setTimezone($timezoneLocal);
|
||||
$result["starts"] = $dateTime->format("Y-m-d H:i:s");
|
||||
|
||||
$dateTime = new DateTime($result["ends"], $timezoneUTC);
|
||||
$dateTime->setTimezone($timezoneLocal);
|
||||
$result["ends"] = $dateTime->format("Y-m-d H:i:s");
|
||||
//if ends is null we don't want it to default to "now"
|
||||
if (isset($result["ends"])) {
|
||||
$dateTime = new DateTime($result["ends"], $timezoneUTC);
|
||||
$dateTime->setTimezone($timezoneLocal);
|
||||
$result["ends"] = $dateTime->format("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
if (isset($result[MDATA_KEY_DURATION])) {
|
||||
$formatter = new LengthFormatter($result[MDATA_KEY_DURATION]);
|
||||
|
@ -505,6 +508,48 @@ class Application_Service_HistoryService
|
|||
|
||||
return $filteredShows;
|
||||
}
|
||||
|
||||
public function insertWebstreamMetadata($schedId, $startDT, $data) {
|
||||
|
||||
$this->con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
$item = CcScheduleQuery::create()->findPK($schedId, $this->con);
|
||||
|
||||
//TODO figure out how to combine these all into 1 query.
|
||||
$showInstance = $item->getCcShowInstances($this->con);
|
||||
$show = $showInstance->getCcShow($this->con);
|
||||
|
||||
$webstream = $item->getCcWebstream($this->con);
|
||||
|
||||
$metadata = array();
|
||||
$metadata["showname"] = $show->getDbName();
|
||||
$metadata[MDATA_KEY_TITLE] = $data->title;
|
||||
$metadata[MDATA_KEY_CREATOR] = $webstream->getDbName();
|
||||
|
||||
$history = new CcPlayoutHistory();
|
||||
$history->setDbStarts($startDT);
|
||||
$history->setDbEnds(null);
|
||||
$history->setDbInstanceId($item->getDbInstanceId());
|
||||
|
||||
foreach ($metadata as $key => $val) {
|
||||
$meta = new CcPlayoutHistoryMetaData();
|
||||
$meta->setDbKey($key);
|
||||
$meta->setDbValue($val);
|
||||
|
||||
$history->addCcPlayoutHistoryMetaData($meta);
|
||||
}
|
||||
|
||||
$history->save($this->con);
|
||||
|
||||
$this->con->commit();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function insertPlayedItem($schedId) {
|
||||
|
||||
|
@ -611,7 +656,7 @@ class Application_Service_HistoryService
|
|||
}
|
||||
|
||||
//need to convert to the station's local time first.
|
||||
if ($field["type"] == TEMPLATE_DATETIME) {
|
||||
if ($field["type"] == TEMPLATE_DATETIME && !is_null($value)) {
|
||||
$timezoneUTC = new DateTimeZone("UTC");
|
||||
$timezoneLocal = new DateTimeZone($this->timezone);
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
class Application_Validate_NotDemoValidate extends Zend_Validate_Abstract
|
||||
{
|
||||
const NOTDEMO = 'notdemo';
|
||||
|
||||
protected $_messageTemplates = array(
|
||||
self::NOTDEMO => "Cannot be changed in demo mode"
|
||||
);
|
||||
|
||||
public function isValid($value)
|
||||
{
|
||||
$this->_setValue($value);
|
||||
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
if (isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1) {
|
||||
$this->_error(self::NOTDEMO);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -483,7 +483,7 @@
|
|||
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
|
||||
<column name="file_id" phpName="DbFileId" type="INTEGER" required="false" />
|
||||
<column name="starts" phpName="DbStarts" type="TIMESTAMP" required="true"/>
|
||||
<column name="ends" phpName="DbEnds" type="TIMESTAMP" required="true"/>
|
||||
<column name="ends" phpName="DbEnds" type="TIMESTAMP" required="false"/>
|
||||
<column name="instance_id" phpName="DbInstanceId" type="INTEGER" required="false"/>
|
||||
<foreign-key foreignTable="cc_files" name="cc_playout_history_file_tag_fkey" onDelete="CASCADE">
|
||||
<reference local="file_id" foreign="id"/>
|
||||
|
|
|
@ -765,7 +765,7 @@ CREATE TABLE "cc_playout_history"
|
|||
"id" serial NOT NULL,
|
||||
"file_id" INTEGER,
|
||||
"starts" TIMESTAMP NOT NULL,
|
||||
"ends" TIMESTAMP NOT NULL,
|
||||
"ends" TIMESTAMP,
|
||||
"instance_id" INTEGER,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
|
|
@ -214,6 +214,9 @@
|
|||
.ui-widget-content .ui-icon {
|
||||
background-image: url(images/ui-icons_ffffff_256x240.png);
|
||||
}
|
||||
.ui-widget-content .ui-icon-alert {
|
||||
background-image: url(images/ui-icons_ff5d1a_256x240.png);
|
||||
}
|
||||
.ui-widget-header .ui-icon {
|
||||
background-image: url(images/ui-icons_ffffff_256x240.png);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ CREATE TABLE cc_playout_history (
|
|||
id integer DEFAULT nextval('cc_playout_history_id_seq'::regclass) NOT NULL,
|
||||
file_id integer,
|
||||
starts timestamp without time zone NOT NULL,
|
||||
ends timestamp without time zone NOT NULL,
|
||||
ends timestamp without time zone,
|
||||
instance_id integer
|
||||
);
|
||||
|
||||
|
|
|
@ -16,8 +16,11 @@ def notify_stream(m)
|
|||
#escaping the apostrophe, and then starting a new string right after it. This is why we use 3 apostrophes.
|
||||
json_str = string.replace(pattern="'",(fun (s) -> "'\''"), json_str)
|
||||
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --webstream='#{json_str}' --media-id=#{!current_dyn_id} &"
|
||||
log(command)
|
||||
system(command)
|
||||
|
||||
if !current_dyn_id != "-1" then
|
||||
log(command)
|
||||
system(command)
|
||||
end
|
||||
end
|
||||
|
||||
# A function applied to each metadata chunk
|
||||
|
|
|
@ -181,7 +181,7 @@ class PypoLiquidsoap():
|
|||
#handle webstreams
|
||||
current_stream_id = self.telnet_liquidsoap.get_current_stream_id()
|
||||
if scheduled_now_webstream:
|
||||
if current_stream_id != scheduled_now_webstream[0]:
|
||||
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.
|
||||
|
|
|
@ -14,12 +14,11 @@ fi
|
|||
#Check whether version of virtualenv is <= 1.4.8. If so exit install.
|
||||
BAD_VERSION="1.4.8"
|
||||
VERSION=$(virtualenv --version)
|
||||
NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n'" | sort -t '.' -g | tail -n 1)
|
||||
NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n" | sort -t '.' -V | tail -n 1)
|
||||
echo -n "Ensuring python-virtualenv version > $BAD_VERSION..."
|
||||
if [[ "$NEWEST_VERSION" = "$BAD_VERSION" ]]; then
|
||||
URL="http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb"
|
||||
echo "Failed!"
|
||||
echo "You have version $BAD_VERSION or older installed. Please install package at $URL first and then try installing Airtime again."
|
||||
echo "You have version $BAD_VERSION or older installed. Please upgrade python-virtualenv and install Airtime again."
|
||||
exit 1
|
||||
else
|
||||
echo "Success!"
|
||||
|
|
Loading…
Reference in New Issue