示例#1
0
    def push_to_liquidsoap(self, event_chain):

        try:
            for media_item in event_chain:
                if media_item['type'] == "file":

                    """
                    Wait maximum 5 seconds (50 iterations) for file to become ready, otherwise
                    give up on it.
                    """
                    iter_num = 0
                    while not media_item['file_ready'] and iter_num < 50:
                        time.sleep(0.1)
                        iter_num += 1

                    if media_item['file_ready']:
                        self.telnet_to_liquidsoap(media_item)
                    else:
                        self.logger.warn("File %s did not become ready in less than 5 seconds. Skipping...", media_item['dst'])
                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:
            self.logger.error('Pypo Push Exception: %s', e)
示例#2
0
 def handle_event_type(self, media_item):
     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")
示例#3
0
    def push_to_liquidsoap(self, event_chain):

        try:
            for media_item in event_chain:
                if media_item['type'] == "file":
                    """
                    Wait maximum 5 seconds (50 iterations) for file to become ready, otherwise
                    give up on it.
                    """
                    iter_num = 0
                    while not media_item['file_ready'] and iter_num < 50:
                        time.sleep(0.1)
                        iter_num += 1

                    if media_item['file_ready']:
                        self.telnet_to_liquidsoap(media_item)
                    else:
                        self.logger.warn(
                            "File %s did not become ready in less than 5 seconds. Skipping...",
                            media_item['dst'])
                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:
            self.logger.error('Pypo Push Exception: %s', e)
示例#4
0
 def push_to_liquidsoap(self, event_chain):
     
     try:
         for media_item in event_chain:
             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:
         self.logger.error('Pypo Push Exception: %s', e)
示例#5
0
    def push_to_liquidsoap(self, event_chain):

        try:
            for media_item in event_chain:
                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:
            self.logger.error('Pypo Push Exception: %s', e)
示例#6
0
    def push_to_liquidsoap(self, event_chain):

        try:
            for media_item in event_chain:
                if media_item['type'] == "file":

                    """
                    Wait maximum 5 seconds (50 iterations) for file to become ready, otherwise
                    give up on it.
                    """
                    iter_num = 0
                    while not media_item['file_ready'] and iter_num < 50:
                        time.sleep(0.1)
                        iter_num += 1

                    if media_item['file_ready']:
                        self.telnet_to_liquidsoap(media_item)
                    else:
                        self.logger.warn("File %s did not become ready in less than 5 seconds. Skipping...", media_item['dst'])
                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")
                elif media_item['type'] == 'stream_buffer_start':
                    self.start_web_stream_buffer(media_item)
                elif media_item['type'] == "stream_output_start":
                    if media_item['row_id'] != self.current_prebuffering_stream_id:
                        #this is called if the stream wasn't scheduled sufficiently ahead of time
                        #so that the prebuffering stage could take effect. Let's do the prebuffering now.
                        self.start_web_stream_buffer(media_item)
                    self.start_web_stream(media_item)
                elif media_item['type'] == "stream_buffer_end":
                    self.stop_web_stream_buffer(media_item)
                elif media_item['type'] == "stream_output_end":
                    self.stop_web_stream_output(media_item)
        except Exception, e:
            self.logger.error('Pypo Push Exception: %s', e)
示例#7
0
 def handle_event_type(self, media_item):
     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")