def run(self):
<EOL>self.show_streams()<EOL>while True:<EOL><INDENT>self.s.refresh()<EOL>self.check_stopped_streams()<EOL>souts = self.q.get_stdouts()<EOL>souts.append(sys.stdin)<EOL>try:<EOL><INDENT>(r, w, x) = select.select(souts, [], [], <NUM_LIT:1>)<EOL><DEDENT>except select.error:<EOL><INDENT>continue<EOL><DEDENT>if not r:<EOL><INDENT>if self.config.CHECK_ONLINE_INTERVAL <= <NUM_LIT:0>: continue<EOL>cur_time = int(time())<EOL>time_delta = cur_time - self.last_autocheck<EOL>if time_delta > self.config.CHECK_ONLINE_INTERVAL:<EOL><INDENT>self.check_online_streams()<EOL>self.set_status('<STR_LIT>'.format(<EOL>strftime('<STR_LIT>', localtime(time() + self.config.CHECK_ONLINE_INTERVAL))<EOL>))<EOL><DEDENT>continue<EOL><DEDENT>for fd in r:<EOL><INDENT>if fd != sys.stdin:<EOL><INDENT>msg = fd.readline()<EOL>if msg:<EOL><INDENT>self.set_status(msg[:-<NUM_LIT:1>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>c = self.pads[self.current_pad].getch()<EOL>if c == curses.KEY_UP or c == ord('<STR_LIT:k>'):<EOL><INDENT>self.move(-<NUM_LIT:1>)<EOL><DEDENT>elif c == curses.KEY_DOWN or c == ord('<STR_LIT>'):<EOL><INDENT>self.move(<NUM_LIT:1>)<EOL><DEDENT>elif c == ord('<STR_LIT:f>'):<EOL><INDENT>if self.current_pad == '<STR_LIT>':<EOL><INDENT>self.filter_streams()<EOL><DEDENT><DEDENT>elif c == ord('<STR_LIT:F>'):<EOL><INDENT>if self.current_pad == '<STR_LIT>':<EOL><INDENT>self.clear_filter()<EOL><DEDENT><DEDENT>elif c == ord('<STR_LIT:g>'):<EOL><INDENT>if self.got_g:<EOL><INDENT>self.move(<NUM_LIT:0>, absolute=True)<EOL>self.got_g = False<EOL>continue<EOL><DEDENT>self.got_g = True<EOL><DEDENT>elif c == ord('<STR_LIT>'):<EOL><INDENT>self.move(len(self.filtered_streams)-<NUM_LIT:1>, absolute=True)<EOL><DEDENT>elif c == ord('<STR_LIT:q>'):<EOL><INDENT>if self.current_pad == '<STR_LIT>':<EOL><INDENT>self.q.terminate()<EOL>return<EOL><DEDENT>else:<EOL><INDENT>self.show_streams()<EOL><DEDENT><DEDENT>elif c == <NUM_LIT>: <EOL><INDENT>if self.current_pad != '<STR_LIT>':<EOL><INDENT>self.show_streams()<EOL><DEDENT><DEDENT>if self.current_pad == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>elif c == <NUM_LIT:10>:<EOL><INDENT>self.play_stream()<EOL><DEDENT>elif c == ord('<STR_LIT:s>'):<EOL><INDENT>self.stop_stream()<EOL><DEDENT>elif c == ord('<STR_LIT:c>'):<EOL><INDENT>self.reset_stream()<EOL><DEDENT>elif c == ord('<STR_LIT:n>'):<EOL><INDENT>self.edit_stream('<STR_LIT:name>')<EOL><DEDENT>elif c == ord('<STR_LIT:r>'):<EOL><INDENT>self.edit_stream('<STR_LIT>')<EOL><DEDENT>elif c == ord('<STR_LIT:u>'):<EOL><INDENT>self.edit_stream('<STR_LIT:url>')<EOL><DEDENT>elif c == ord('<STR_LIT:l>'):<EOL><INDENT>self.show_commandline()<EOL><DEDENT>elif c == ord('<STR_LIT:L>'):<EOL><INDENT>self.shift_commandline()<EOL><DEDENT>elif c == ord('<STR_LIT:a>'):<EOL><INDENT>self.prompt_new_stream()<EOL><DEDENT>elif c == ord('<STR_LIT:d>'):<EOL><INDENT>self.delete_stream()<EOL><DEDENT>elif c == ord('<STR_LIT:o>'):<EOL><INDENT>self.show_offline_streams ^= True<EOL>self.refilter_streams()<EOL><DEDENT>elif c == ord('<STR_LIT:O>'):<EOL><INDENT>self.check_online_streams()<EOL><DEDENT>elif c == ord('<STR_LIT:h>') or c == ord('<STR_LIT:?>'):<EOL><INDENT>self.show_help()<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Main event loop