CC-1665: Scheduled stream rebroadcasting and recording

-webstreams now start and stop at the correct time.
This commit is contained in:
Martin Konecny 2012-07-25 16:56:33 -04:00
parent c90495d2d3
commit fbc5b72f14
4 changed files with 114 additions and 57 deletions

View file

@ -241,7 +241,7 @@ class PypoPush(Thread):
for mkey in sorted_keys:
media_item = media_schedule[mkey]
if media_item['type'] == "event":
if media_item['independent_event']:
chains.append([media_item])
elif len(current_chain) == 0:
current_chain.append(media_item)
@ -353,9 +353,55 @@ class PypoPush(Thread):
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")
elif media_item['type'] == "stream":
"""
Source is a stream that we need to being downloading to a file. Then we may simply
point Liquidsoap to play this file.
"""
self.start_web_stream(media_item)
elif media_item['type'] == "stream_end":
self.stop_web_stream(media_item)
except Exception, e:
self.logger.error('Pypo Push Exception: %s', e)
def start_web_stream(self, media_item):
try:
self.telnet_lock.acquire()
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
#dynamic_source.start http://87.230.101.24:80/top100station.mp3
msg = 'streams.scheduled_play_start\n'
tn.write(msg)
msg = 'dynamic_source.start %s\n' % media_item['uri'].encode('latin-1')
self.logger.debug(msg)
tn.write(msg)
tn.write("exit\n")
self.logger.debug(tn.read_all())
except Exception, e:
self.logger.error(str(e))
finally:
self.telnet_lock.release()
def stop_web_stream(self, media_item):
try:
self.telnet_lock.acquire()
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
#dynamic_source.stop http://87.230.101.24:80/top100station.mp3
msg = 'dynamic_source.stop %s\n' % media_item['uri'].encode('latin-1')
self.logger.debug(msg)
tn.write(msg)
tn.write("exit\n")
self.logger.debug(tn.read_all())
except Exception, e:
self.logger.error(str(e))
finally:
self.telnet_lock.release()
def clear_liquidsoap_queue(self):
self.logger.debug("Clearing Liquidsoap queue")
try: