def load_trailers() -> None: """ Start up the configured trailer discovery threads. Called whenever settings have changed to start any threads that have just ben enabled. :return: """ module_logger.enter() if Settings.get_include_library_trailers(): lib_instance = DiscoverLibraryMovies() lib_instance.discover_basic_information() # Manufacture trailer entries for folders which contain trailer # files. Note that files are assumed to be videos. if Settings.get_include_trailer_folders(): DiscoverFolderTrailers().discover_basic_information() if Settings.get_include_itunes_trailers(): DiscoverItunesMovies().discover_basic_information() if Settings.get_include_tmdb_trailers(): DiscoverTmdbMovies().discover_basic_information() if Settings.is_include_tfh_trailers(): DiscoverTFHMovies().discover_basic_information() Monitor.throw_exception_if_abort_requested(timeout=1.0) Monitor.set_startup_complete()
def run(self): # type: () -> None """ :return: """ local_class = DiscoverFolderTrailers if local_class.logger.isEnabledFor(LazyLogger.DEBUG): try: import resource memory = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss local_class.logger.debug(': memory: ' + str(memory)) except ImportError: pass start_time = datetime.datetime.now() try: finished = False while not finished: try: self.discover_basic_information_worker( Settings.get_trailers_paths()) self.wait_until_restart_or_shutdown() except RestartDiscoveryException: # Restart discovery if local_class.logger.isEnabledFor(LazyLogger.DEBUG): local_class.logger.debug('Restarting discovery') self.prepare_for_restart_discovery() if not Settings.get_include_trailer_folders(): finished = True self.remove_self() except AbortException: return # Just exit thread except Exception: local_class.logger.exception('') self.finished_discovery() duration = datetime.datetime.now() - start_time if local_class.logger.isEnabledFor(LazyLogger.DEBUG): local_class.logger.debug('Time to discover:', duration.seconds, 'seconds', trace=Trace.STATS)
def on_settings_changed(self): # type: () -> None """ Settings changes only impact Folder Trailers to stop it. Since we are here, Folder Trailer discover was active prior to the settings change, therefore, only do something if we are no longer active. """ local_class = DiscoverFolderTrailers local_class.logger.enter() try: stop_thread = not Settings.get_include_trailer_folders() if stop_thread: self.restart_discovery(stop_thread) except Exception as e: local_class.logger.exception('')