diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 96f99e0ec..66309b091 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -807,8 +807,6 @@ class ApiController extends Zend_Controller_Action } $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; } @@ -988,6 +986,7 @@ class ApiController extends Zend_Controller_Action $username = $request->getParam('username'); $password = $request->getParam('password'); + $djtype = $request->getParam('djtype'); if (!in_array($api_key, $CC_CONFIG["apiKey"])) { @@ -995,11 +994,57 @@ class ApiController extends Zend_Controller_Action print 'You are not allowed to access this resource.'; exit; } - //check against master - if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){ - $this->view->msg = true; - }else{ - $this->view->msg = false; + + Logging::log("user:".$username." pass:".$password." type:".$djtype); + + if($djtype == 'master'){ + //check against master + if($username == Application_Model_Preference::GetLiveSteamMasterUsername() && $password == Application_Model_Preference::GetLiveSteamMasterPassword()){ + Logging::log("master 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{ + $this->view->msg = false; + } } } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 2d64effbb..1192c3775 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -205,23 +205,29 @@ class PreferenceController extends Zend_Controller_Action $values['streamFormat'] = $form->getValue('streamFormat'); 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 Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); Application_Model_Preference::SetLiveSteamAutoEnable($values["auto_enable_live_stream"]); Application_Model_Preference::SetLiveSteamMasterUsername($values["master_username"]); 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 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); $this->view->statusMsg = "
Stream Setting Updated.
"; } diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php index 8c79f5274..bebd88cd4 100644 --- a/airtime_mvc/application/forms/AddShowLiveStream.php +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -37,7 +37,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm ->setFilters(array('StringTrim')) ->setValidators(array( new ConditionalNotEmpty(array("cb_custom_auth"=>"1")))) - ->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) ->setDecorators(array('ViewHelper')); $this->addElement($custom_username); @@ -51,7 +50,6 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm ->setFilters(array('StringTrim')) ->setValidators(array( new ConditionalNotEmpty(array("cb_custom_auth"=>"1")))) - //fix//->setValue(Application_Model_Preference::GetLiveSteamMasterUsername()) ->setDecorators(array('ViewHelper')); $this->addElement($custom_password); diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index ce210343f..a9e4847ba 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -39,17 +39,34 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $this->addElement($master_password); //liquidsoap harbor.input port - $port = new Zend_Form_Element_Text('harbor_input_port'); - $port->setLabel("Port to Connect") - ->setValue(Application_Model_Preference::GetLiveSteamPort()) + $port = new Zend_Form_Element_Text('master_harbor_input_port'); + $port->setLabel("Master DJ Port") + ->setValue(Application_Model_StreamSetting::GetMasterLiveSteamPort()) ->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('harbor_input_mount_point'); - $mount->setLabel("Mount Point to Connect") - ->setValue(Application_Model_Preference::GetLiveSteamMountPoint()) + $mount = new Zend_Form_Element_Text('master_harbor_input_mount_point'); + $mount->setLabel("Master DJ Mount Point") + ->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( array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index d2b82e74b..d5d708418 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -728,22 +728,6 @@ class Application_Model_Preference public static function GetLiveSteamMasterPassword(){ 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 */ } diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 47a5fcdd2..0159b4487 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -104,6 +104,19 @@ class Application_Model_Show { 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. public function delete() @@ -785,6 +798,8 @@ class Application_Model_Show { $info['allow_live_stream_override'] = $ccShow->getDbAllowLiveStream(); $info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth(); $info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth(); + $info['custom_username'] = $ccShow->getDbLiveStreamUser(); + $info['custom_password'] = $ccShow->getDbLiveStreamPass(); return $info; } } @@ -1698,9 +1713,13 @@ class Application_Model_Show { * @param String $timeNow - current time (in UTC) * @return array - show being played right now */ - public static function GetCurrentShow($timeNow) + public static function GetCurrentShow($timeNow=null) { 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 $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" diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 0ae84a009..e2a8d0989 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -1,5 +1,48 @@ 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 * example of the array returned in JSON notation is ["s1", "s2", "s3"] */ @@ -63,6 +106,18 @@ class Application_Model_StreamSetting { ." WHERE keyname not like '%_error'"; $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; } @@ -197,4 +252,36 @@ class Application_Model_StreamSetting { } 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"); + } } diff --git a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml index 1dda30647..9fd67479b 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml @@ -43,29 +43,57 @@ -
-
+
-
- element->getElement('harbor_input_port') ?> - element->getElement('harbor_input_port')->hasErrors()) : ?> +
+ element->getElement('master_harbor_input_port') ?> + element->getElement('master_harbor_input_port')->hasErrors()) : ?>
-
-
+
-
- element->getElement('harbor_input_mount_point') ?> - element->getElement('harbor_input_mount_point')->hasErrors()) : ?> +
+ element->getElement('master_harbor_input_mount_point') ?> + element->getElement('master_harbor_input_mount_point')->hasErrors()) : ?> + +
+
+ +
+
+ element->getElement('dj_harbor_input_port') ?> + element->getElement('dj_harbor_input_port')->hasErrors()) : ?> + + +
+
+ +
+
+ element->getElement('dj_harbor_input_mount_point') ?> + element->getElement('dj_harbor_input_mount_point')->hasErrors()) : ?> + diff --git a/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 b/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 index ba0987022..7aa4cc883 100644 --- a/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 +++ b/install_minimal/upgrades/airtime-2.0.1/api_client.cfg.201 @@ -101,6 +101,4 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #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%%' -#URL to check live stream auth -check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%' diff --git a/install_minimal/upgrades/airtime-2.0.2/api_client.cfg.202 b/install_minimal/upgrades/airtime-2.0.2/api_client.cfg.202 index 2d51bb2d2..f7c63bee8 100644 --- a/install_minimal/upgrades/airtime-2.0.2/api_client.cfg.202 +++ b/install_minimal/upgrades/airtime-2.0.2/api_client.cfg.202 @@ -95,23 +95,3 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #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%%' -############## -# 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/' - diff --git a/python_apps/api_clients/api_client.cfg b/python_apps/api_clients/api_client.cfg index ba0987022..e02dc3cac 100644 --- a/python_apps/api_clients/api_client.cfg +++ b/python_apps/api_clients/api_client.cfg @@ -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%%' #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%%' diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index de73fc68a..2faeaec97 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -365,7 +365,7 @@ class AirTimeApiClient(ApiClientInterface): return response - def check_live_stream_auth(self, username, password): + def check_live_stream_auth(self, username, password, dj_type): #logger = logging.getLogger() response = '' try: @@ -373,6 +373,7 @@ class AirTimeApiClient(ApiClientInterface): url = url.replace("%%api_key%%", self.config["api_key"]) url = url.replace("%%username%%", username) + url = url.replace("%%djtype%%", dj_type) url = url.replace("%%password%%", password) req = urllib2.Request(url) diff --git a/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py b/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py index 57bf6e709..a7955add9 100644 --- a/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py +++ b/python_apps/pypo/liquidsoap_scripts/liquidsoap_auth.py @@ -12,8 +12,16 @@ except Exception, e: api_clients = api_client.api_client_factory(config) -username = sys.argv[1] -password = sys.argv[2] -response = api_clients.check_live_stream_auth(username, password) +dj_type = sys.argv[1] +username = sys.argv[2] +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'] \ No newline at end of file diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index a4c1ac92f..cc3b485ba 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -40,10 +40,11 @@ default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default) #live stream setup set("harbor.bind_addr", "0.0.0.0") + #auth function for live stream -def check_client(user,password) = +def check_master_dj_client(user,password) = #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 = list.hd(ret) #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 -def configure_live(harbor_input_port, harbor_input_mount_point) = - if harbor_input_port != 0 and harbor_input_mount_point != "" then - live = input.harbor(harbor_input_mount_point, port=harbor_input_port, auth=check_client) - fallback(track_sensitive=false, [live, queue, default]) +def check_dj_client(user,password) = + #get the output of the php script + ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --dj #{user} #{password}") + #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 + false + end +end + +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 - fallback(track_sensitive=false, [queue, default]) + s end end -s = configure_live(harbor_input_port, harbor_input_mount_point) +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 = 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) # Attach a skip command to the source s: @@ -83,7 +114,6 @@ s = crossfade(s) #) add_skip_command(s) -s = map_metadata(append_title, s) 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) end +output.dummy(fallible=true, !master_dj) +output.dummy(fallible=true, !dj_live) ignore(output.dummy(blank())) diff --git a/python_apps/pypo/pypocli.py b/python_apps/pypo/pypocli.py index 265d141d9..9eeb15a6f 100644 --- a/python_apps/pypo/pypocli.py +++ b/python_apps/pypo/pypocli.py @@ -153,11 +153,12 @@ if __name__ == '__main__': recorder.daemon = True recorder.start() - pmh.join() - pfile.join() + # all join() are commented out becase we want to exit entire pypo + # if pypofetch is exiting + #pmh.join() + #recorder.join() + #pp.join() pf.join() - pp.join() - recorder.join() logger.info("pypo fetch exit") sys.exit() diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 86d68694c..d216611b0 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -111,7 +111,7 @@ class PypoFetch(Thread): self.logger.debug(e) self.logger.debug('Could not connect to liquidsoap') - def regenerateLiquidsoapConf(self, setting): + def regenerateLiquidsoapConf(self, setting_p): existing = {} # create a temp file fh = open('/etc/airtime/liquidsoap.cfg', 'r') @@ -146,8 +146,9 @@ class PypoFetch(Thread): restart = False self.logger.info("Looking for changes...") + setting = sorted(setting_p.items()) # 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']: dump, stream = s[u'keyname'].split('_', 1) state_change_restart[stream] = False @@ -155,9 +156,9 @@ class PypoFetch(Thread): if (existing[s[u'keyname']] != s[u'value']): self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname']) 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']): - 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; else: stream, dump = s[u'keyname'].split('_',1) @@ -194,7 +195,7 @@ class PypoFetch(Thread): fh.write("################################################\n") fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n") fh.write("################################################\n") - for d in setting: + for k, d in setting: buffer = d[u'keyname'] + " = " if(d[u'type'] == 'string'): temp = d[u'value']