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 on_settings_changed(self): # type: () -> None """ Rediscover trailers if the changed settings impacts this manager. By being here, TMDB discover is currently running. Only restart if there is a change. """ clz = DiscoverTFHMovies clz.logger.enter() if Settings.is_tfh_loading_settings_changed(): stop_thread = not Settings.is_include_tfh_trailers() self.restart_discovery(stop_thread)
def run(self): # type: () -> None """ Thread run method that is started as a result of running discover_basic_information This method acts as a wrapper around run_worker. This wrapper is able to restart discovery and to handle a few details after discovery is complete. :return: # type: None """ clz = DiscoverTFHMovies start_time = datetime.datetime.now() try: finished = False while not finished: try: self.run_worker() self.wait_until_restart_or_shutdown() except (RestartDiscoveryException): # Restart discovery if clz.logger.isEnabledFor(LazyLogger.DEBUG): clz.logger.debug('Restarting discovery') self.prepare_for_restart_discovery() if not Settings.is_include_tfh_trailers(): finished = True self.remove_self() self.finished_discovery() duration = datetime.datetime.now() - start_time if clz.logger.isEnabledFor(LazyLogger.DEBUG): clz.logger.debug('Time to discover:', duration.seconds, ' seconds', trace=Trace.STATS) except AbortException: return except Exception as e: clz.logger.exception('')