CC-3449: Live Stream: Kick out live dj at the end of the show
- done
This commit is contained in:
parent
d12ef1c7a2
commit
4f5d7efaa1
|
@ -633,11 +633,28 @@ class Application_Model_Schedule {
|
||||||
|
|
||||||
$data["status"] = array();
|
$data["status"] = array();
|
||||||
$data["media"] = array();
|
$data["media"] = array();
|
||||||
$data["harbor"] = 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");
|
||||||
|
|
||||||
$data["harbor"]['next_live_dj_show_end'] = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ();
|
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
|
||||||
$data["harbor"]['transition_fade'] = Application_Model_Preference::GetDefaultTransitionFade();
|
$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){
|
foreach ($items as $item){
|
||||||
|
|
||||||
|
@ -662,6 +679,7 @@ class Application_Model_Schedule {
|
||||||
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
|
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
|
||||||
$data["media"][$start] = array(
|
$data["media"][$start] = array(
|
||||||
'id' => $storedFile->getGunid(),
|
'id' => $storedFile->getGunid(),
|
||||||
|
'type' => "file",
|
||||||
'row_id' => $item["id"],
|
'row_id' => $item["id"],
|
||||||
'uri' => $uri,
|
'uri' => $uri,
|
||||||
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),
|
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),
|
||||||
|
|
|
@ -376,6 +376,7 @@ class PypoFetch(Thread):
|
||||||
def process_schedule(self, schedule_data):
|
def process_schedule(self, schedule_data):
|
||||||
self.logger.debug(schedule_data)
|
self.logger.debug(schedule_data)
|
||||||
media = schedule_data["media"]
|
media = schedule_data["media"]
|
||||||
|
media_filtered = {}
|
||||||
|
|
||||||
# Download all the media and put playlists in liquidsoap "annotate" format
|
# Download all the media and put playlists in liquidsoap "annotate" format
|
||||||
try:
|
try:
|
||||||
|
@ -391,13 +392,14 @@ class PypoFetch(Thread):
|
||||||
|
|
||||||
for key in media:
|
for key in media:
|
||||||
media_item = media[key]
|
media_item = media[key]
|
||||||
|
if(media_item['type'] == 'file'):
|
||||||
fileExt = os.path.splitext(media_item['uri'])[1]
|
fileExt = os.path.splitext(media_item['uri'])[1]
|
||||||
dst = os.path.join(download_dir, media_item['id']+fileExt)
|
dst = os.path.join(download_dir, media_item['id']+fileExt)
|
||||||
media_item['dst'] = dst
|
media_item['dst'] = dst
|
||||||
|
media_filtered[key] = media_item
|
||||||
|
|
||||||
self.media_prepare_queue.put(copy.copy(media))
|
self.media_prepare_queue.put(copy.copy(media_filtered))
|
||||||
self.prepare_media(media)
|
self.prepare_media(media_filtered)
|
||||||
except Exception, e: self.logger.error("%s", e)
|
except Exception, e: self.logger.error("%s", e)
|
||||||
|
|
||||||
# Send the data to pypo-push
|
# Send the data to pypo-push
|
||||||
|
|
|
@ -9,6 +9,7 @@ import telnetlib
|
||||||
import calendar
|
import calendar
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
|
from pypofetch import PypoFetch
|
||||||
|
|
||||||
from Queue import Empty
|
from Queue import Empty
|
||||||
|
|
||||||
|
@ -204,7 +205,9 @@ class PypoPush(Thread):
|
||||||
|
|
||||||
for mkey in sorted_keys:
|
for mkey in sorted_keys:
|
||||||
media_item = media_schedule[mkey]
|
media_item = media_schedule[mkey]
|
||||||
if len(current_chain) == 0:
|
if media_item['type'] == "event":
|
||||||
|
chains.append([media_item])
|
||||||
|
elif len(current_chain) == 0:
|
||||||
current_chain.append(media_item)
|
current_chain.append(media_item)
|
||||||
elif media_item['start'] == current_chain[-1]['end']:
|
elif media_item['start'] == current_chain[-1]['end']:
|
||||||
current_chain.append(media_item)
|
current_chain.append(media_item)
|
||||||
|
@ -240,7 +243,6 @@ class PypoPush(Thread):
|
||||||
tnow = datetime.utcnow()
|
tnow = datetime.utcnow()
|
||||||
current_chain = []
|
current_chain = []
|
||||||
|
|
||||||
|
|
||||||
for chain in chains:
|
for chain in chains:
|
||||||
iteration = 0
|
iteration = 0
|
||||||
for link in chain:
|
for link in chain:
|
||||||
|
@ -284,7 +286,13 @@ class PypoPush(Thread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for media_item in media_item_chain:
|
for media_item in media_item_chain:
|
||||||
self.telnet_to_liquidsoap(media_item)
|
if media_item['type'] == "file":
|
||||||
|
self.telnet_to_liquidsoap(media_item)
|
||||||
|
elif media_item['type'] == "event":
|
||||||
|
if media_item['event_type'] == "kick_out":
|
||||||
|
PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj")
|
||||||
|
elif media_item['event_type'] == "switch_off":
|
||||||
|
PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off")
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logger.error('Pypo Push Exception: %s', e)
|
self.logger.error('Pypo Push Exception: %s', e)
|
||||||
|
|
||||||
|
@ -400,7 +408,7 @@ class PypoPush(Thread):
|
||||||
def create_liquidsoap_annotation(self, media):
|
def create_liquidsoap_annotation(self, media):
|
||||||
return 'annotate:media_id="%s",liq_cue_in="%s",liq_cue_out="%s",schedule_table_id="%s":%s' \
|
return 'annotate:media_id="%s",liq_cue_in="%s",liq_cue_out="%s",schedule_table_id="%s":%s' \
|
||||||
% (media['id'], float(media['cue_in']), float(media['cue_out']), media['row_id'], media['dst'])
|
% (media['id'], float(media['cue_in']), float(media['cue_out']), media['row_id'], media['dst'])
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try: self.main()
|
try: self.main()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
Loading…
Reference in New Issue