diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index c5b9d9aca..5a5c6fa49 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -150,13 +150,15 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm if ($master_harbor_input_port == $dj_harbor_input_port && $master_harbor_input_port != "") { $element = $this->getElement("dj_harbor_input_port"); $element->addError("You cannot use same port as Master DJ port."); + $isValid = false; } if ($master_harbor_input_port != "") { if (is_numeric($master_harbor_input_port)) { if ($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()) { $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - $res = socket_bind($sock, 0, $master_harbor_input_port); - if (!$res) { + try { + socket_bind($sock, 0, $master_harbor_input_port); + } catch (Exception $e) { $element = $this->getElement("master_harbor_input_port"); $element->addError("Port '$master_harbor_input_port' is not available."); $isValid = false; @@ -171,8 +173,9 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm if (is_numeric($dj_harbor_input_port)) { if ($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()) { $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - $res = socket_bind($sock, 0, $dj_harbor_input_port); - if (!$res) { + try { + socket_bind($sock, 0, $dj_harbor_input_port); + } catch (Exception $e) { $element = $this->getElement("dj_harbor_input_port"); $element->addError("Port '$dj_harbor_input_port' is not available."); $isValid = false; diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 2c0441163..fa2a6c79b 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -687,7 +687,7 @@ SQL; 'end' => $end, 'show_name' => $item["show_name"], 'replay_gain' => is_null($item["replay_gain"]) ? "0": $item["replay_gain"], - 'independent_event' => true + 'independent_event' => false ); self::appendScheduleItem($data, $start, $schedule_item); } diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 5bcce21b6..0382b5e06 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -120,6 +120,10 @@ class PypoPush(Thread): next_media_item_chain = self.get_next_schedule_chain(chains, datetime.utcnow()) if next_media_item_chain is not None: + try: + chains.remove(next_media_item_chain) + except ValueError, e: + self.logger.error(str(e)) chain_start = datetime.strptime(next_media_item_chain[0]['start'], "%Y-%m-%d-%H-%M-%S") time_until_next_play = self.date_interval_to_seconds(chain_start - datetime.utcnow()) self.logger.debug("Blocking %s seconds until show start", time_until_next_play) @@ -405,8 +409,9 @@ class PypoPush(Thread): closest_chain = None for chain in chains: chain_start = datetime.strptime(chain[0]['start'], "%Y-%m-%d-%H-%M-%S") + chain_end = datetime.strptime(chain[-1]['end'], "%Y-%m-%d-%H-%M-%S") self.logger.debug("tnow %s, chain_start %s", tnow, chain_start) - if (closest_start == None or chain_start < closest_start) and chain_start > tnow: + if (closest_start == None or chain_start < closest_start) and (chain_start > tnow or (chain_start < tnow and chain_end > tnow)): closest_start = chain_start closest_chain = chain