CC-3449: Live Stream: Kick out live dj at the end of the show
- fixed so airtime sends series of kick_out events according to cached_ahead value in cfg file.
This commit is contained in:
parent
7510e4c029
commit
7325d51ada
|
@ -634,26 +634,29 @@ class Application_Model_Schedule {
|
||||||
$data["status"] = array();
|
$data["status"] = array();
|
||||||
$data["media"] = array();
|
$data["media"] = array();
|
||||||
|
|
||||||
$kick_time = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ();
|
$kick_times = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ($range_start, $range_end);
|
||||||
$temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade());
|
foreach($kick_times as $kick_time_info){
|
||||||
// we round down transition time since PHP cannot handle millisecond. We need to
|
$kick_time = $kick_time_info['ends'];
|
||||||
// handle this better in the future
|
$temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade());
|
||||||
$transition_time = intval($temp[0]);
|
// we round down transition time since PHP cannot handle millisecond. We need to
|
||||||
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
|
// handle this better in the future
|
||||||
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S'));
|
$transition_time = intval($temp[0]);
|
||||||
$switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
|
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
|
||||||
|
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S'));
|
||||||
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
|
$switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
|
||||||
$data["media"][$kick_start]['start'] = $kick_start;
|
|
||||||
$data["media"][$kick_start]['end'] = $kick_start;
|
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
|
||||||
$data["media"][$kick_start]['event_type'] = "kick_out";
|
$data["media"][$kick_start]['start'] = $kick_start;
|
||||||
$data["media"][$kick_start]['type'] = "event";
|
$data["media"][$kick_start]['end'] = $kick_start;
|
||||||
|
$data["media"][$kick_start]['event_type'] = "kick_out";
|
||||||
if($kick_time !== $switch_off_time){
|
$data["media"][$kick_start]['type'] = "event";
|
||||||
$data["media"][$switch_start]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
|
||||||
$data["media"][$switch_start]['end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
if($kick_time !== $switch_off_time){
|
||||||
$data["media"][$switch_start]['event_type'] = "switch_off";
|
$data["media"][$switch_start]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
||||||
$data["media"][$switch_start]['type'] = "event";
|
$data["media"][$switch_start]['end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
||||||
|
$data["media"][$switch_start]['event_type'] = "switch_off";
|
||||||
|
$data["media"][$switch_start]['type'] = "event";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($items as $item){
|
foreach ($items as $item){
|
||||||
|
|
|
@ -829,19 +829,16 @@ class Application_Model_ShowInstance {
|
||||||
return $CC_DBC->GetOne($sql);
|
return $CC_DBC->GetOne($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this returns end timestamp of next show that has live DJ set up
|
// this returns end timestamp of all shows that are in the range and has live DJ set up
|
||||||
public static function GetEndTimeOfNextShowWithLiveDJ(){
|
public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$date = new Application_Model_DateHelper;
|
|
||||||
$utcTimeNow = $date->getUtcTimestamp();
|
|
||||||
|
|
||||||
$sql = "SELECT ends
|
$sql = "SELECT ends
|
||||||
FROM cc_show_instances as si
|
FROM cc_show_instances as si
|
||||||
JOIN cc_show as sh ON si.show_id = sh.id
|
JOIN cc_show as sh ON si.show_id = sh.id
|
||||||
WHERE si.ends > '$utcTimeNow' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth)
|
WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth)
|
||||||
ORDER BY si.ends";
|
ORDER BY si.ends";
|
||||||
|
|
||||||
return $CC_DBC->GetOne($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,7 +562,10 @@ class PypoFetch(Thread):
|
||||||
message = self.fetch_queue.get(block=True, timeout=3600)
|
message = self.fetch_queue.get(block=True, timeout=3600)
|
||||||
self.handle_message(message)
|
self.handle_message(message)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logger.error("Exception, %s", e)
|
import traceback
|
||||||
|
top = traceback.format_exc()
|
||||||
|
self.logger.error('Exception: %s', e)
|
||||||
|
self.logger.error("traceback: %s", top)
|
||||||
|
|
||||||
success, self.schedule_data = self.api_client.get_schedule()
|
success, self.schedule_data = self.api_client.get_schedule()
|
||||||
if success:
|
if success:
|
||||||
|
|
Loading…
Reference in New Issue