CC-2089: create "cancel show" command for pypo
- removed comments
This commit is contained in:
parent
ed5b7bca5f
commit
17e7e9b80a
|
@ -39,27 +39,6 @@ except Exception, e:
|
||||||
logger.error('Error loading config file: %s', e)
|
logger.error('Error loading config file: %s', e)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
"""
|
|
||||||
Handle a message from RabbitMQ, put it into our yucky global var.
|
|
||||||
Hopefully there is a better way to do this.
|
|
||||||
"""
|
|
||||||
"""def handle_message(body, message):
|
|
||||||
logger = logging.getLogger('fetch')
|
|
||||||
global SCHEDULE_PUSH_MSG
|
|
||||||
logger.info("Received event from RabbitMQ: " + message.body)
|
|
||||||
|
|
||||||
m = json.loads(message.body)
|
|
||||||
command = m['event_type']
|
|
||||||
logger.info("Handling command: " + command)
|
|
||||||
|
|
||||||
if(command == 'update_schedule'):
|
|
||||||
SCHEDULE_PUSH_MSG = m['schedule']
|
|
||||||
elif (command == 'update_stream_setting'):
|
|
||||||
logger.info("Updating stream setting: %s", m['setting'])
|
|
||||||
|
|
||||||
# ACK the message to take it off the queue
|
|
||||||
message.ack()"""
|
|
||||||
|
|
||||||
class PypoFetch(Thread):
|
class PypoFetch(Thread):
|
||||||
def __init__(self, q):
|
def __init__(self, q):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
|
@ -236,42 +215,6 @@ class PypoFetch(Thread):
|
||||||
self.cache_dir = config["cache_dir"] + self.export_source + '/'
|
self.cache_dir = config["cache_dir"] + self.export_source + '/'
|
||||||
logger.info("Creating cache directory at %s", self.cache_dir)
|
logger.info("Creating cache directory at %s", self.cache_dir)
|
||||||
|
|
||||||
"""
|
|
||||||
def get_currently_scheduled(self, playlistsOrMedias, str_tnow_s):
|
|
||||||
for key in playlistsOrMedias:
|
|
||||||
start = playlistsOrMedias[key]['start']
|
|
||||||
end = playlistsOrMedias[key]['end']
|
|
||||||
|
|
||||||
if start <= str_tnow_s and str_tnow_s < end:
|
|
||||||
return key
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def handle_shows_currently_scheduled(self, playlists):
|
|
||||||
logger = logging.getLogger('fetch')
|
|
||||||
|
|
||||||
dtnow = datetime.today()
|
|
||||||
tnow = dtnow.timetuple()
|
|
||||||
str_tnow_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tnow[0], tnow[1], tnow[2], tnow[3], tnow[4], tnow[5])
|
|
||||||
|
|
||||||
current_pkey = self.get_currently_scheduled(playlists, str_tnow_s)
|
|
||||||
if current_pkey is not None:
|
|
||||||
logger.debug("FOUND CURRENT PLAYLIST %s", current_pkey)
|
|
||||||
# So we have found that a playlist if currently scheduled
|
|
||||||
# even though we just started pypo. Perhaps there was a
|
|
||||||
# system crash. Lets calculate what position in the playlist
|
|
||||||
# we are supposed to be in.
|
|
||||||
medias = playlists[current_pkey]["medias"]
|
|
||||||
current_mkey = self.get_currently_scheduled(medias, str_tnow_s)
|
|
||||||
if current_mkey is not None:
|
|
||||||
mkey_split = map(int, current_mkey.split('-'))
|
|
||||||
media_start = datetime(mkey_split[0], mkey_split[1], mkey_split[2], mkey_split[3], mkey_split[4], mkey_split[5])
|
|
||||||
logger.debug("Found media item that started at %s.", media_start)
|
|
||||||
|
|
||||||
delta = dtnow - media_start #we get a TimeDelta object from this operation
|
|
||||||
logger.info("Starting media item at %d second point", delta.seconds)
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Process the schedule
|
Process the schedule
|
||||||
- Reads the scheduled entries of a given range (actual time +/- "prepare_ahead" / "cache_for")
|
- Reads the scheduled entries of a given range (actual time +/- "prepare_ahead" / "cache_for")
|
||||||
|
|
|
@ -49,10 +49,6 @@ class PypoPush(Thread):
|
||||||
self.push_ahead = 10
|
self.push_ahead = 10
|
||||||
self.push_ahead2 = self.push_ahead -5
|
self.push_ahead2 = self.push_ahead -5
|
||||||
|
|
||||||
#toggle between "stop" and "play". Keeps track of the state of
|
|
||||||
#liquidsoap
|
|
||||||
#self.liquidsoap_state_play = True
|
|
||||||
|
|
||||||
def set_export_source(self, export_source):
|
def set_export_source(self, export_source):
|
||||||
self.export_source = export_source
|
self.export_source = export_source
|
||||||
self.cache_dir = config["cache_dir"] + self.export_source + '/'
|
self.cache_dir = config["cache_dir"] + self.export_source + '/'
|
||||||
|
@ -80,7 +76,6 @@ class PypoPush(Thread):
|
||||||
schedule = self.schedule
|
schedule = self.schedule
|
||||||
playlists = self.playlists
|
playlists = self.playlists
|
||||||
|
|
||||||
#currently_on_air = False
|
|
||||||
if schedule:
|
if schedule:
|
||||||
playedItems = self.load_schedule_tracker()
|
playedItems = self.load_schedule_tracker()
|
||||||
|
|
||||||
|
@ -101,8 +96,6 @@ class PypoPush(Thread):
|
||||||
logger.debug('Preparing to push playlist scheduled at: %s', pkey)
|
logger.debug('Preparing to push playlist scheduled at: %s', pkey)
|
||||||
playlist = schedule[pkey]
|
playlist = schedule[pkey]
|
||||||
|
|
||||||
#currently_on_air = True
|
|
||||||
|
|
||||||
# We have a match, replace the current playlist and
|
# We have a match, replace the current playlist and
|
||||||
# force liquidsoap to refresh.
|
# force liquidsoap to refresh.
|
||||||
if (self.push_liquidsoap(pkey, schedule, playlists) == 1):
|
if (self.push_liquidsoap(pkey, schedule, playlists) == 1):
|
||||||
|
@ -122,26 +115,9 @@ class PypoPush(Thread):
|
||||||
|
|
||||||
show_start = schedule[pkey]['show_start']
|
show_start = schedule[pkey]['show_start']
|
||||||
show_end = schedule[pkey]['show_end']
|
show_end = schedule[pkey]['show_end']
|
||||||
|
|
||||||
"""if show_start <= str_tnow_s and str_tnow_s < show_end:
|
|
||||||
currently_on_air = True"""
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
"""if not currently_on_air and self.liquidsoap_state_play:
|
|
||||||
logger.debug('Notifying Liquidsoap to stop playback.')
|
|
||||||
try:
|
|
||||||
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
|
|
||||||
tn.write('source.skip\n')
|
|
||||||
tn.write('exit\n')
|
|
||||||
tn.read_all()
|
|
||||||
except Exception, e:
|
|
||||||
logger.debug(e)
|
|
||||||
logger.debug('Could not connect to liquidsoap')
|
|
||||||
|
|
||||||
self.liquidsoap_state_play = False"""
|
|
||||||
|
|
||||||
|
|
||||||
def push_liquidsoap(self, pkey, schedule, playlists):
|
def push_liquidsoap(self, pkey, schedule, playlists):
|
||||||
logger = logging.getLogger('push')
|
logger = logging.getLogger('push')
|
||||||
|
|
||||||
|
@ -190,8 +166,6 @@ class PypoPush(Thread):
|
||||||
tn.write("exit\n")
|
tn.write("exit\n")
|
||||||
logger.debug(tn.read_all())
|
logger.debug(tn.read_all())
|
||||||
|
|
||||||
#self.liquidsoap_state_play = True
|
|
||||||
|
|
||||||
status = 1
|
status = 1
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.error('%s', e)
|
logger.error('%s', e)
|
||||||
|
|
Loading…
Reference in New Issue