def _render_recordings_tables_rows_template(self, is_server_secure, authorization_required, client_uuid, server_hostname, server_port): recordings_table_row_template = self._environment.get_template( 'recordings_table_row.html') recordings = PVR.get_recordings() recording_table_rows = {'live': [], 'persisted': [], 'scheduled': []} for recording in recordings: spacing_and_control_spans_display = 'display: none;' recording_source = None if recording.status == RecordingStatus.PERSISTED.value: spacing_and_control_spans_display = 'display: inline-block;' recording_source = { 'type': 'vod', 'hls': { 'videoSource': '{0}'.format( PVR.generate_vod_recording_playlist_url( is_server_secure, server_hostname, server_port, client_uuid, recording.id, self._configuration['SERVER_PASSWORD'] if authorization_required else None)) } } recordings_table_row_template_fields = { 'recording_id': recording.id, 'spacing_span_display': spacing_and_control_spans_display, 'recording_source_data_json': json.dumps(recording_source), 'control_span_display': spacing_and_control_spans_display, 'recording_channel_number': recording.channel_number, 'recording_channel_name': html.escape(recording.channel_name), 'recording_program_title': html.escape(recording.program_title), 'recording_start_date_time_in_utc': recording.start_date_time_in_utc.astimezone( tzlocal.get_localzone()).strftime('%Y-%m-%d %H:%M:%S'), 'recording_end_date_time_in_utc': recording.end_date_time_in_utc.astimezone( tzlocal.get_localzone()).strftime('%Y-%m-%d %H:%M:%S') } recording_table_rows[recording.status].append( recordings_table_row_template.render( recordings_table_row_template_fields)) return recording_table_rows
def shutdown_proxy(cls): cls._shutdown_proxy_event.set() ProvidersController.terminate() CacheManager.cancel_cleanup_cache_timer() PVR.cancel_start_recording_timer() PVR.stop() if cls._http_server_thread: cls._http_server_thread.stop() if cls._https_server_thread: cls._https_server_thread.stop() Configuration.stop_configuration_file_watchdog_observer() OptionalSettings.stop_optional_settings_file_watchdog_observer() Logging.stop_logging_configuration_file_watchdog_observer()
def start_proxy( cls, configuration_file_path, optional_settings_file_path, db_file_path, log_file_path, recordings_directory_path, certificate_file_path, key_file_path, ): Configuration.set_configuration_file_path(configuration_file_path) OptionalSettings.set_optional_settings_file_path( optional_settings_file_path) Database.set_database_file_path(db_file_path) Logging.set_log_file_path(log_file_path) PVR.set_recordings_directory_path(recordings_directory_path) SecurityManager.set_certificate_file_path(certificate_file_path) SecurityManager.set_key_file_path(key_file_path) ProvidersController.initialize() OptionalSettings.read_optional_settings_file() Database.initialize() SecurityManager.initialize() Configuration.read_configuration_file() CacheManager.initialize() HTMLTemplateEngine.initialize() HTTPRequestHandler.initialize() PVR.initialize() Configuration.start_configuration_file_watchdog_observer() OptionalSettings.start_optional_settings_file_watchdog_observer() Logging.start_logging_configuration_file_watchdog_observer() cls.start_http_server() cls.start_https_server() PVR.start() while not cls._shutdown_proxy_event.is_set(): if cls._http_server_thread: cls._http_server_thread.join() if cls._https_server_thread: cls._https_server_thread.join() cls._shutdown_proxy_event.wait(0.5) Configuration.join_configuration_file_watchdog_observer() OptionalSettings.join_optional_settings_file_watchdog_observer() Logging.join_logging_configuration_file_watchdog_observer()