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["media"] = array();
|
||||
|
||||
$kick_time = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ();
|
||||
$temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade());
|
||||
// we round down transition time since PHP cannot handle millisecond. We need to
|
||||
// handle this better in the future
|
||||
$transition_time = intval($temp[0]);
|
||||
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
|
||||
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S'));
|
||||
$switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
|
||||
|
||||
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
|
||||
$data["media"][$kick_start]['start'] = $kick_start;
|
||||
$data["media"][$kick_start]['end'] = $kick_start;
|
||||
$data["media"][$kick_start]['event_type'] = "kick_out";
|
||||
$data["media"][$kick_start]['type'] = "event";
|
||||
|
||||
if($kick_time !== $switch_off_time){
|
||||
$data["media"][$switch_start]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
||||
$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";
|
||||
$kick_times = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ($range_start, $range_end);
|
||||
foreach($kick_times as $kick_time_info){
|
||||
$kick_time = $kick_time_info['ends'];
|
||||
$temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade());
|
||||
// we round down transition time since PHP cannot handle millisecond. We need to
|
||||
// handle this better in the future
|
||||
$transition_time = intval($temp[0]);
|
||||
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
|
||||
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S'));
|
||||
$switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
|
||||
|
||||
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
|
||||
$data["media"][$kick_start]['start'] = $kick_start;
|
||||
$data["media"][$kick_start]['end'] = $kick_start;
|
||||
$data["media"][$kick_start]['event_type'] = "kick_out";
|
||||
$data["media"][$kick_start]['type'] = "event";
|
||||
|
||||
if($kick_time !== $switch_off_time){
|
||||
$data["media"][$switch_start]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
||||
$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){
|
||||
|
|
|
@ -829,19 +829,16 @@ class Application_Model_ShowInstance {
|
|||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
// this returns end timestamp of next show that has live DJ set up
|
||||
public static function GetEndTimeOfNextShowWithLiveDJ(){
|
||||
// this returns end timestamp of all shows that are in the range and has live DJ set up
|
||||
public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$utcTimeNow = $date->getUtcTimestamp();
|
||||
|
||||
$sql = "SELECT ends
|
||||
FROM cc_show_instances as si
|
||||
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";
|
||||
|
||||
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)
|
||||
self.handle_message(message)
|
||||
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()
|
||||
if success:
|
||||
|
|
Loading…
Reference in New Issue