CC-3224: "On-the-fly" stream rebroadcasting
- frond-end implementation for master dj and live dj - db implementation - liquidsoap is broken on this commit
This commit is contained in:
parent
96c4462adc
commit
128a497059
16 changed files with 304 additions and 99 deletions
|
@ -807,8 +807,6 @@ class ApiController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$info = Application_Model_StreamSetting::getStreamSetting();
|
$info = Application_Model_StreamSetting::getStreamSetting();
|
||||||
$info[] = (array("keyname" =>"harbor_input_port", "value"=>Application_Model_Preference::GetLiveSteamPort(), "type"=>"integer"));
|
|
||||||
$info[] = (array("keyname" =>"harbor_input_mount_point", "value"=>Application_Model_Preference::GetLiveSteamMountPoint(), "type"=>"string"));
|
|
||||||
$this->view->msg = $info;
|
$this->view->msg = $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,6 +986,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
$username = $request->getParam('username');
|
$username = $request->getParam('username');
|
||||||
$password = $request->getParam('password');
|
$password = $request->getParam('password');
|
||||||
|
$djtype = $request->getParam('djtype');
|
||||||
|
|
||||||
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
|
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||||
{
|
{
|
||||||
|
@ -995,12 +994,58 @@ class ApiController extends Zend_Controller_Action
|
||||||
print 'You are not allowed to access this resource.';
|
print 'You are not allowed to access this resource.';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logging::log("user:".$username." pass:".$password." type:".$djtype);
|
||||||
|
|
||||||
|
if($djtype == 'master'){
|
||||||
//check against master
|
//check against master
|
||||||
if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){
|
if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){
|
||||||
|
Logging::log("master true");
|
||||||
$this->view->msg = true;
|
$this->view->msg = true;
|
||||||
|
}else{
|
||||||
|
Logging::log("master false");
|
||||||
|
$this->view->msg = false;
|
||||||
|
}
|
||||||
|
}elseif($djtype == "dj"){
|
||||||
|
Logging::log("djtype...");
|
||||||
|
//check against show dj auth
|
||||||
|
$showInfo = Application_Model_Show::GetCurrentShow();
|
||||||
|
if(isset($showInfo[0]['id'])){
|
||||||
|
$current_show_id = $showInfo[0]['id'];
|
||||||
|
$CcShow = CcShowQuery::create()->findPK($current_show_id);
|
||||||
|
|
||||||
|
// get custom pass info from the show
|
||||||
|
$custom_user = $CcShow->getDbLiveStreamUser();
|
||||||
|
$custom_pass = $CcShow->getDbLiveStreamPass();
|
||||||
|
|
||||||
|
Logging::log("user:".$username." pass:".$password);
|
||||||
|
Logging::log("c_user:".$custom_user." c_pass:".$custom_pass);
|
||||||
|
|
||||||
|
// get hosts ids
|
||||||
|
$show = new Application_Model_Show($current_show_id);
|
||||||
|
$hosts_ids = $show->getHostsIds();
|
||||||
|
|
||||||
|
// check against hosts auth
|
||||||
|
foreach( $hosts_ids as $host){
|
||||||
|
$h = new Application_Model_User($host['subjs_id']);
|
||||||
|
if($username == $h->getLogin() && md5($password) == $h->getPassword()){
|
||||||
|
$this->view->msg = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check against custom auth
|
||||||
|
if($username == $custom_user && $password == $custom_pass){
|
||||||
|
Logging::log("custom true");
|
||||||
|
$this->view->msg = true;
|
||||||
|
}else{
|
||||||
|
Logging::log("custom false");
|
||||||
|
$this->view->msg = false;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->view->msg = false;
|
$this->view->msg = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,23 +205,29 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
$values['streamFormat'] = $form->getValue('streamFormat');
|
$values['streamFormat'] = $form->getValue('streamFormat');
|
||||||
|
|
||||||
Application_Model_StreamSetting::setStreamSetting($values);
|
Application_Model_StreamSetting::setStreamSetting($values);
|
||||||
$data = array();
|
|
||||||
$info = Application_Model_StreamSetting::getStreamSetting();
|
|
||||||
$info[] = (array("keyname" =>"harbor_input_port", "value"=>$values["harbor_input_port"], "type"=>"integer"));
|
|
||||||
$info[] = (array("keyname" =>"harbor_input_mount_point", "value"=>$values["harbor_input_mount_point"], "type"=>"string"));
|
|
||||||
$data['setting'] = $info;
|
|
||||||
for($i=1;$i<=$num_of_stream;$i++){
|
|
||||||
Application_Model_StreamSetting::setLiquidsoapError($i, "waiting");
|
|
||||||
}
|
|
||||||
// this goes into cc_pref table
|
// this goes into cc_pref table
|
||||||
Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']);
|
Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']);
|
||||||
Application_Model_Preference::SetLiveSteamAutoEnable($values["auto_enable_live_stream"]);
|
Application_Model_Preference::SetLiveSteamAutoEnable($values["auto_enable_live_stream"]);
|
||||||
Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]);
|
Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]);
|
||||||
Application_Model_Preference::SetLiveSteamMasterPassword($values["master_password"]);
|
Application_Model_Preference::SetLiveSteamMasterPassword($values["master_password"]);
|
||||||
Application_Model_Preference::SetLiveSteamPort($values["harbor_input_port"]);
|
|
||||||
Application_Model_Preference::SetLiveSteamMountPoint($values["harbor_input_mount_point"]);
|
// extra info that goes into cc_stream_setting
|
||||||
|
Application_Model_StreamSetting::SetMasterLiveSteamPort($values["master_harbor_input_port"]);
|
||||||
|
Application_Model_StreamSetting::SetMasterLiveSteamMountPoint($values["master_harbor_input_mount_point"]);
|
||||||
|
Application_Model_StreamSetting::SetDJLiveSteamPort($values["dj_harbor_input_port"]);
|
||||||
|
Application_Model_StreamSetting::SetDJLiveSteamMountPoint($values["dj_harbor_input_mount_point"]);
|
||||||
|
|
||||||
// store stream update timestamp
|
// store stream update timestamp
|
||||||
Application_Model_Preference::SetStreamUpdateTimestamp();
|
Application_Model_Preference::SetStreamUpdateTimestamp();
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$info = Application_Model_StreamSetting::getStreamSetting();
|
||||||
|
$data['setting'] = $info;
|
||||||
|
for($i=1;$i<=$num_of_stream;$i++){
|
||||||
|
Application_Model_StreamSetting::setLiquidsoapError($i, "waiting");
|
||||||
|
}
|
||||||
|
|
||||||
Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data);
|
Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data);
|
||||||
$this->view->statusMsg = "<div class='success'>Stream Setting Updated.</div>";
|
$this->view->statusMsg = "<div class='success'>Stream Setting Updated.</div>";
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
||||||
->setFilters(array('StringTrim'))
|
->setFilters(array('StringTrim'))
|
||||||
->setValidators(array(
|
->setValidators(array(
|
||||||
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
|
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
|
||||||
->setValue(Application_Model_Preference::GetLiveSteamMasterUsername())
|
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
$this->addElement($custom_username);
|
$this->addElement($custom_username);
|
||||||
|
|
||||||
|
@ -51,7 +50,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
||||||
->setFilters(array('StringTrim'))
|
->setFilters(array('StringTrim'))
|
||||||
->setValidators(array(
|
->setValidators(array(
|
||||||
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
|
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))))
|
||||||
//fix//->setValue(Application_Model_Preference::GetLiveSteamMasterUsername())
|
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
$this->addElement($custom_password);
|
$this->addElement($custom_password);
|
||||||
|
|
||||||
|
|
|
@ -39,17 +39,34 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
$this->addElement($master_password);
|
$this->addElement($master_password);
|
||||||
|
|
||||||
//liquidsoap harbor.input port
|
//liquidsoap harbor.input port
|
||||||
$port = new Zend_Form_Element_Text('harbor_input_port');
|
$port = new Zend_Form_Element_Text('master_harbor_input_port');
|
||||||
$port->setLabel("Port to Connect")
|
$port->setLabel("Master DJ Port")
|
||||||
->setValue(Application_Model_Preference::GetLiveSteamPort())
|
->setValue(Application_Model_StreamSetting::GetMasterLiveSteamPort())
|
||||||
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
|
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
|
||||||
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
$this->addElement($port);
|
$this->addElement($port);
|
||||||
|
|
||||||
$mount = new Zend_Form_Element_Text('harbor_input_mount_point');
|
$mount = new Zend_Form_Element_Text('master_harbor_input_mount_point');
|
||||||
$mount->setLabel("Mount Point to Connect")
|
$mount->setLabel("Master DJ Mount Point")
|
||||||
->setValue(Application_Model_Preference::GetLiveSteamMountPoint())
|
->setValue(Application_Model_StreamSetting::GetMasterLiveSteamMountPoint())
|
||||||
|
->setValidators(array(
|
||||||
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$this->addElement($mount);
|
||||||
|
|
||||||
|
//liquidsoap harbor.input port
|
||||||
|
$port = new Zend_Form_Element_Text('dj_harbor_input_port');
|
||||||
|
$port->setLabel("DJ Port")
|
||||||
|
->setValue(Application_Model_StreamSetting::GetDJLiveSteamPort())
|
||||||
|
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
|
||||||
|
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$this->addElement($port);
|
||||||
|
|
||||||
|
$mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point');
|
||||||
|
$mount->setLabel("DJ Mount Point")
|
||||||
|
->setValue(Application_Model_StreamSetting::GetDJLiveSteamMountPoint())
|
||||||
->setValidators(array(
|
->setValidators(array(
|
||||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
->setDecorators(array('ViewHelper'));
|
->setDecorators(array('ViewHelper'));
|
||||||
|
|
|
@ -728,22 +728,6 @@ class Application_Model_Preference
|
||||||
public static function GetLiveSteamMasterPassword(){
|
public static function GetLiveSteamMasterPassword(){
|
||||||
return self::GetValue("live_stream_master_password");
|
return self::GetValue("live_stream_master_password");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetLiveSteamPort($value){
|
|
||||||
self::SetValue("live_stream_port", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetLiveSteamPort(){
|
|
||||||
return self::GetValue("live_stream_port");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function SetLiveSteamMountPoint($value){
|
|
||||||
self::SetValue("live_stream_mp", $value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function GetLiveSteamMountPoint(){
|
|
||||||
return self::GetValue("live_stream_mp");
|
|
||||||
}
|
|
||||||
/* User specific preferences end */
|
/* User specific preferences end */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,19 @@ class Application_Model_Show {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getHostsIds()
|
||||||
|
{
|
||||||
|
global $CC_DBC;
|
||||||
|
|
||||||
|
$sql = "SELECT subjs_id
|
||||||
|
FROM cc_show_hosts
|
||||||
|
WHERE show_id = {$this->_showId}";
|
||||||
|
|
||||||
|
$hosts = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
|
return $hosts;
|
||||||
|
}
|
||||||
|
|
||||||
//remove everything about this show.
|
//remove everything about this show.
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
|
@ -785,6 +798,8 @@ class Application_Model_Show {
|
||||||
$info['allow_live_stream_override'] = $ccShow->getDbAllowLiveStream();
|
$info['allow_live_stream_override'] = $ccShow->getDbAllowLiveStream();
|
||||||
$info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth();
|
$info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth();
|
||||||
$info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth();
|
$info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth();
|
||||||
|
$info['custom_username'] = $ccShow->getDbLiveStreamUser();
|
||||||
|
$info['custom_password'] = $ccShow->getDbLiveStreamPass();
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1698,9 +1713,13 @@ class Application_Model_Show {
|
||||||
* @param String $timeNow - current time (in UTC)
|
* @param String $timeNow - current time (in UTC)
|
||||||
* @return array - show being played right now
|
* @return array - show being played right now
|
||||||
*/
|
*/
|
||||||
public static function GetCurrentShow($timeNow)
|
public static function GetCurrentShow($timeNow=null)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
if($timeNow == null){
|
||||||
|
$date = new Application_Model_DateHelper;
|
||||||
|
$timeNow = $date->getUtcTimestamp();
|
||||||
|
}
|
||||||
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
|
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
|
||||||
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
|
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
|
||||||
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
||||||
|
|
|
@ -1,6 +1,49 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Model_StreamSetting {
|
class Application_Model_StreamSetting {
|
||||||
|
|
||||||
|
public static function SetValue($key, $value, $type){
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
|
$key = pg_escape_string($key);
|
||||||
|
$value = pg_escape_string($value);
|
||||||
|
|
||||||
|
//Check if key already exists
|
||||||
|
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||||
|
." WHERE keyname = '$key'";
|
||||||
|
|
||||||
|
$result = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
if($result == 1) {
|
||||||
|
$sql = "UPDATE cc_stream_setting"
|
||||||
|
." SET value = '$value', type='$type'"
|
||||||
|
." WHERE keyname = '$key'";
|
||||||
|
} else {
|
||||||
|
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
|
||||||
|
." VALUES ('$key', '$value', '$type')";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $CC_DBC->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function GetValue($key){
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
|
//Check if key already exists
|
||||||
|
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||||
|
." WHERE keyname = '$key'";
|
||||||
|
$result = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
if ($result == 0)
|
||||||
|
return "";
|
||||||
|
else {
|
||||||
|
$sql = "SELECT value FROM cc_stream_setting"
|
||||||
|
." WHERE keyname = '$key'";
|
||||||
|
|
||||||
|
$result = $CC_DBC->GetOne($sql);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns the id's of all streams that are enabled in an array. An
|
/* Returns the id's of all streams that are enabled in an array. An
|
||||||
* example of the array returned in JSON notation is ["s1", "s2", "s3"] */
|
* example of the array returned in JSON notation is ["s1", "s2", "s3"] */
|
||||||
public static function getEnabledStreamIds(){
|
public static function getEnabledStreamIds(){
|
||||||
|
@ -63,6 +106,18 @@ class Application_Model_StreamSetting {
|
||||||
." WHERE keyname not like '%_error'";
|
." WHERE keyname not like '%_error'";
|
||||||
|
|
||||||
$rows = $CC_DBC->getAll($sql);
|
$rows = $CC_DBC->getAll($sql);
|
||||||
|
if(isset($rows["master_harbor_input_port"])){
|
||||||
|
$rows[] = (array("keyname" =>"master_harbor_input_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer"));
|
||||||
|
}
|
||||||
|
if(isset($rows["master_harbor_input_mount_point"])){
|
||||||
|
$rows[] = (array("keyname" =>"master_harbor_input_mount_point", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string"));
|
||||||
|
}
|
||||||
|
if(isset($rows["dj_harbor_input_port"])){
|
||||||
|
$rows[] = (array("keyname" =>"dj_harbor_input_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer"));
|
||||||
|
}
|
||||||
|
if(isset($rows["dj_harbor_input_mount_point"])){
|
||||||
|
$rows[] = (array("keyname" =>"dj_harbor_input_mount_point", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string"));
|
||||||
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,4 +252,36 @@ class Application_Model_StreamSetting {
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function SetMasterLiveSteamPort($value){
|
||||||
|
self::SetValue("master_live_stream_port", $value, "integer");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function GetMasterLiveSteamPort(){
|
||||||
|
return self::GetValue("master_live_stream_port");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function SetMasterLiveSteamMountPoint($value){
|
||||||
|
self::SetValue("master_live_stream_mp", $value, "string");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function GetMasterLiveSteamMountPoint(){
|
||||||
|
return self::GetValue("master_live_stream_mp");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function SetDJLiveSteamPort($value){
|
||||||
|
self::SetValue("dj_live_stream_port", $value, "integer");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function GetDJLiveSteamPort(){
|
||||||
|
return self::GetValue("dj_live_stream_port");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function SetDJLiveSteamMountPoint($value){
|
||||||
|
self::SetValue("dj_live_stream_mp", $value, "string");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function GetDJLiveSteamMountPoint(){
|
||||||
|
return self::GetValue("dj_live_stream_mp");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,29 +43,57 @@
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</dd>
|
</dd>
|
||||||
<dt id="harbor_input_port-label">
|
<dt id="master_harbor_input_port-label">
|
||||||
<label class="optional" for="harbor_input_port"><?php echo $this->element->getElement('harbor_input_port')->getLabel() ?> :
|
<label class="optional" for="master_harbor_input_port"><?php echo $this->element->getElement('master_harbor_input_port')->getLabel() ?> :
|
||||||
</label>
|
</label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd id="harbor_input_port-element">
|
<dd id="master_harbor_input_port-element">
|
||||||
<?php echo $this->element->getElement('harbor_input_port') ?>
|
<?php echo $this->element->getElement('master_harbor_input_port') ?>
|
||||||
<?php if($this->element->getElement('harbor_input_port')->hasErrors()) : ?>
|
<?php if($this->element->getElement('master_harbor_input_port')->hasErrors()) : ?>
|
||||||
<ul class='errors'>
|
<ul class='errors'>
|
||||||
<?php foreach($this->element->getElement('harbor_input_port')->getMessages() as $error): ?>
|
<?php foreach($this->element->getElement('master_harbor_input_port')->getMessages() as $error): ?>
|
||||||
<li><?php echo $error; ?></li>
|
<li><?php echo $error; ?></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</dd>
|
</dd>
|
||||||
<dt id="harbor_input_mount_point-label">
|
<dt id="master_harbor_input_mount_point-label">
|
||||||
<label class="optional" for="harbor_input_mount_point"><?php echo $this->element->getElement('harbor_input_mount_point')->getLabel() ?> :
|
<label class="optional" for="master_harbor_input_mount_point"><?php echo $this->element->getElement('master_harbor_input_mount_point')->getLabel() ?> :
|
||||||
</label>
|
</label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd id="harbor_input_mount_point-element">
|
<dd id="master_harbor_input_mount_point-element">
|
||||||
<?php echo $this->element->getElement('harbor_input_mount_point') ?>
|
<?php echo $this->element->getElement('master_harbor_input_mount_point') ?>
|
||||||
<?php if($this->element->getElement('harbor_input_mount_point')->hasErrors()) : ?>
|
<?php if($this->element->getElement('master_harbor_input_mount_point')->hasErrors()) : ?>
|
||||||
<ul class='errors'>
|
<ul class='errors'>
|
||||||
<?php foreach($this->element->getElement('harbor_input_mount_point')->getMessages() as $error): ?>
|
<?php foreach($this->element->getElement('master_harbor_input_mount_point')->getMessages() as $error): ?>
|
||||||
|
<li><?php echo $error; ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
|
</dd>
|
||||||
|
<dt id="dj_harbor_input_port-label">
|
||||||
|
<label class="optional" for="dj_harbor_input_port"><?php echo $this->element->getElement('dj_harbor_input_port')->getLabel() ?> :
|
||||||
|
</label>
|
||||||
|
</dt>
|
||||||
|
<dd id="dj_harbor_input_port-element">
|
||||||
|
<?php echo $this->element->getElement('dj_harbor_input_port') ?>
|
||||||
|
<?php if($this->element->getElement('dj_harbor_input_port')->hasErrors()) : ?>
|
||||||
|
<ul class='errors'>
|
||||||
|
<?php foreach($this->element->getElement('dj_harbor_input_port')->getMessages() as $error): ?>
|
||||||
|
<li><?php echo $error; ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
|
</dd>
|
||||||
|
<dt id="dj_harbor_input_mount_point-label">
|
||||||
|
<label class="optional" for="dj_harbor_input_mount_point"><?php echo $this->element->getElement('dj_harbor_input_mount_point')->getLabel() ?> :
|
||||||
|
</label>
|
||||||
|
</dt>
|
||||||
|
<dd id="dj_harbor_input_mount_point-element">
|
||||||
|
<?php echo $this->element->getElement('dj_harbor_input_mount_point') ?>
|
||||||
|
<?php if($this->element->getElement('dj_harbor_input_mount_point')->hasErrors()) : ?>
|
||||||
|
<ul class='errors'>
|
||||||
|
<?php foreach($this->element->getElement('dj_harbor_input_mount_point')->getMessages() as $error): ?>
|
||||||
<li><?php echo $error; ?></li>
|
<li><?php echo $error; ?></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -101,6 +101,4 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
|
||||||
#URL to update liquidsoap status
|
#URL to update liquidsoap status
|
||||||
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
||||||
|
|
||||||
#URL to check live stream auth
|
|
||||||
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%'
|
|
||||||
|
|
||||||
|
|
|
@ -95,23 +95,3 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
|
||||||
#URL to update liquidsoap status
|
#URL to update liquidsoap status
|
||||||
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
||||||
|
|
||||||
##############
|
|
||||||
# OBP config #
|
|
||||||
##############
|
|
||||||
|
|
||||||
# URL to get the version number of the server API
|
|
||||||
#version_url = 'api/pypo/status/json'
|
|
||||||
|
|
||||||
# Schedule export path.
|
|
||||||
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
|
||||||
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
|
||||||
|
|
||||||
# Update whether an item has been played.
|
|
||||||
#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%'
|
|
||||||
|
|
||||||
# Update whether an item is currently playing.
|
|
||||||
#update_start_playing_url = 'api/pypo/mod/medialibrary/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%'
|
|
||||||
|
|
||||||
# ???
|
|
||||||
#generate_range_url = 'api/pypo/generate_range_dp/'
|
|
||||||
|
|
||||||
|
|
|
@ -102,5 +102,5 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
|
||||||
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
||||||
|
|
||||||
#URL to check live stream auth
|
#URL to check live stream auth
|
||||||
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%'
|
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%'
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def check_live_stream_auth(self, username, password):
|
def check_live_stream_auth(self, username, password, dj_type):
|
||||||
#logger = logging.getLogger()
|
#logger = logging.getLogger()
|
||||||
response = ''
|
response = ''
|
||||||
try:
|
try:
|
||||||
|
@ -373,6 +373,7 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
|
|
||||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
url = url.replace("%%username%%", username)
|
url = url.replace("%%username%%", username)
|
||||||
|
url = url.replace("%%djtype%%", dj_type)
|
||||||
url = url.replace("%%password%%", password)
|
url = url.replace("%%password%%", password)
|
||||||
|
|
||||||
req = urllib2.Request(url)
|
req = urllib2.Request(url)
|
||||||
|
|
|
@ -12,8 +12,16 @@ except Exception, e:
|
||||||
|
|
||||||
api_clients = api_client.api_client_factory(config)
|
api_clients = api_client.api_client_factory(config)
|
||||||
|
|
||||||
username = sys.argv[1]
|
dj_type = sys.argv[1]
|
||||||
password = sys.argv[2]
|
username = sys.argv[2]
|
||||||
response = api_clients.check_live_stream_auth(username, password)
|
password = sys.argv[3]
|
||||||
|
|
||||||
|
type = ''
|
||||||
|
if dj_type == '--master':
|
||||||
|
type = 'master'
|
||||||
|
elif dj_type == '--dj':
|
||||||
|
type = 'dj'
|
||||||
|
|
||||||
|
response = api_clients.check_live_stream_auth(username, password, type)
|
||||||
|
|
||||||
print response['msg']
|
print response['msg']
|
|
@ -40,10 +40,11 @@ default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)
|
||||||
|
|
||||||
#live stream setup
|
#live stream setup
|
||||||
set("harbor.bind_addr", "0.0.0.0")
|
set("harbor.bind_addr", "0.0.0.0")
|
||||||
|
|
||||||
#auth function for live stream
|
#auth function for live stream
|
||||||
def check_client(user,password) =
|
def check_master_dj_client(user,password) =
|
||||||
#get the output of the php script
|
#get the output of the php script
|
||||||
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py #{user} #{password}")
|
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --master #{user} #{password}")
|
||||||
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
|
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
|
||||||
ret = list.hd(ret)
|
ret = list.hd(ret)
|
||||||
#return true to let the client transmit data, or false to tell harbor to decline
|
#return true to let the client transmit data, or false to tell harbor to decline
|
||||||
|
@ -54,17 +55,47 @@ def check_client(user,password) =
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_live(harbor_input_port, harbor_input_mount_point) =
|
def check_dj_client(user,password) =
|
||||||
if harbor_input_port != 0 and harbor_input_mount_point != "" then
|
#get the output of the php script
|
||||||
live = input.harbor(harbor_input_mount_point, port=harbor_input_port, auth=check_client)
|
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --dj #{user} #{password}")
|
||||||
fallback(track_sensitive=false, [live, queue, default])
|
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
|
||||||
|
ret = list.hd(ret)
|
||||||
|
#return true to let the client transmit data, or false to tell harbor to decline
|
||||||
|
if (ret == "True") then
|
||||||
|
true
|
||||||
else
|
else
|
||||||
fallback(track_sensitive=false, [queue, default])
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
s = configure_live(harbor_input_port, harbor_input_mount_point)
|
master_dj = ref default
|
||||||
|
dj_live = ref default
|
||||||
|
|
||||||
|
def append_master_dj_input(master_harbor_input_port, master_harbor_input_mount_point, s) =
|
||||||
|
if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then
|
||||||
|
master_dj := input.harbor(master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, buffer=7.,max=15.)
|
||||||
|
fallback(track_sensitive=false, [!master_dj, s])
|
||||||
|
else
|
||||||
|
s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def append_dj_input(dj_harbor_input_port, dj_harbor_input_mount_point, s) =
|
||||||
|
if dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then
|
||||||
|
dj_live := input.harbor(dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, buffer=7.,max=15.)
|
||||||
|
fallback(track_sensitive=false, [!dj_live, s])
|
||||||
|
else
|
||||||
|
s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
s = fallback(track_sensitive=false, [queue, default])
|
||||||
s = on_metadata(notify, s)
|
s = on_metadata(notify, s)
|
||||||
|
s = map_metadata(append_title, s)
|
||||||
|
s = append_dj_input(dj_live_stream_port, dj_live_stream_mp, s)
|
||||||
|
s = append_master_dj_input(master_live_stream_port, master_live_stream_mp, s)
|
||||||
|
|
||||||
|
|
||||||
s = crossfade(s)
|
s = crossfade(s)
|
||||||
# Attach a skip command to the source s:
|
# Attach a skip command to the source s:
|
||||||
|
|
||||||
|
@ -83,7 +114,6 @@ s = crossfade(s)
|
||||||
#)
|
#)
|
||||||
|
|
||||||
add_skip_command(s)
|
add_skip_command(s)
|
||||||
s = map_metadata(append_title, s)
|
|
||||||
|
|
||||||
if output_sound_device then
|
if output_sound_device then
|
||||||
|
|
||||||
|
@ -163,4 +193,6 @@ if s3_enable == true then
|
||||||
output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3", s3_connected)
|
output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3", s3_connected)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
output.dummy(fallible=true, !master_dj)
|
||||||
|
output.dummy(fallible=true, !dj_live)
|
||||||
ignore(output.dummy(blank()))
|
ignore(output.dummy(blank()))
|
||||||
|
|
|
@ -153,11 +153,12 @@ if __name__ == '__main__':
|
||||||
recorder.daemon = True
|
recorder.daemon = True
|
||||||
recorder.start()
|
recorder.start()
|
||||||
|
|
||||||
pmh.join()
|
# all join() are commented out becase we want to exit entire pypo
|
||||||
pfile.join()
|
# if pypofetch is exiting
|
||||||
|
#pmh.join()
|
||||||
|
#recorder.join()
|
||||||
|
#pp.join()
|
||||||
pf.join()
|
pf.join()
|
||||||
pp.join()
|
|
||||||
recorder.join()
|
|
||||||
|
|
||||||
logger.info("pypo fetch exit")
|
logger.info("pypo fetch exit")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
|
@ -111,7 +111,7 @@ class PypoFetch(Thread):
|
||||||
self.logger.debug(e)
|
self.logger.debug(e)
|
||||||
self.logger.debug('Could not connect to liquidsoap')
|
self.logger.debug('Could not connect to liquidsoap')
|
||||||
|
|
||||||
def regenerateLiquidsoapConf(self, setting):
|
def regenerateLiquidsoapConf(self, setting_p):
|
||||||
existing = {}
|
existing = {}
|
||||||
# create a temp file
|
# create a temp file
|
||||||
fh = open('/etc/airtime/liquidsoap.cfg', 'r')
|
fh = open('/etc/airtime/liquidsoap.cfg', 'r')
|
||||||
|
@ -146,8 +146,9 @@ class PypoFetch(Thread):
|
||||||
restart = False
|
restart = False
|
||||||
|
|
||||||
self.logger.info("Looking for changes...")
|
self.logger.info("Looking for changes...")
|
||||||
|
setting = sorted(setting_p.items())
|
||||||
# look for changes
|
# look for changes
|
||||||
for s in setting:
|
for k, s in setting:
|
||||||
if "output_sound_device" in s[u'keyname'] or "icecast_vorbis_metadata" in s[u'keyname']:
|
if "output_sound_device" in s[u'keyname'] or "icecast_vorbis_metadata" in s[u'keyname']:
|
||||||
dump, stream = s[u'keyname'].split('_', 1)
|
dump, stream = s[u'keyname'].split('_', 1)
|
||||||
state_change_restart[stream] = False
|
state_change_restart[stream] = False
|
||||||
|
@ -155,9 +156,9 @@ class PypoFetch(Thread):
|
||||||
if (existing[s[u'keyname']] != s[u'value']):
|
if (existing[s[u'keyname']] != s[u'value']):
|
||||||
self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
|
self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
|
||||||
restart = True;
|
restart = True;
|
||||||
elif "harbor_input_mount_point" in s[u'keyname'] or "harbor_input_port" in s[u'keyname']:
|
elif "master_live_stream_port" in s[u'keyname'] or "master_live_stream_mp" in s[u'keyname'] or "dj_live_stream_port" in s[u'keyname'] or "dj_live_stream_mp" in s[u'keyname']:
|
||||||
if (existing[s[u'keyname']] != s[u'value']):
|
if (existing[s[u'keyname']] != s[u'value']):
|
||||||
logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
|
self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
|
||||||
restart = True;
|
restart = True;
|
||||||
else:
|
else:
|
||||||
stream, dump = s[u'keyname'].split('_',1)
|
stream, dump = s[u'keyname'].split('_',1)
|
||||||
|
@ -194,7 +195,7 @@ class PypoFetch(Thread):
|
||||||
fh.write("################################################\n")
|
fh.write("################################################\n")
|
||||||
fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n")
|
fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n")
|
||||||
fh.write("################################################\n")
|
fh.write("################################################\n")
|
||||||
for d in setting:
|
for k, d in setting:
|
||||||
buffer = d[u'keyname'] + " = "
|
buffer = d[u'keyname'] + " = "
|
||||||
if(d[u'type'] == 'string'):
|
if(d[u'type'] == 'string'):
|
||||||
temp = d[u'value']
|
temp = d[u'value']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue