def init_globals(self, argv): """Initialized globally used module variables. Needs to be called at start of each plugin instance!""" # IS_ADDON_FIRSTRUN: specifies if the add-on has been initialized for the first time # (reuseLanguageInvoker not used yet) self.IS_ADDON_FIRSTRUN = self.IS_ADDON_FIRSTRUN is None self.IS_ADDON_EXTERNAL_CALL = False # xbmcaddon.Addon must be created at every instance otherwise it does not read any new changes to the settings self.ADDON = xbmcaddon.Addon() self.URL = urlparse(argv[0]) self.REQUEST_PATH = unquote(self.URL[2][1:]) try: self.PARAM_STRING = argv[2][1:] except IndexError: self.PARAM_STRING = '' self.REQUEST_PARAMS = dict(parse_qsl(self.PARAM_STRING)) if self.IS_ADDON_FIRSTRUN: # Global variables that do not need to be generated at every instance self.ADDON_ID = self.ADDON.getAddonInfo('id') self.PLUGIN = self.ADDON.getAddonInfo('name') self.VERSION_RAW = self.ADDON.getAddonInfo('version') self.VERSION = remove_ver_suffix(self.VERSION_RAW) self.ICON = self.ADDON.getAddonInfo('icon') self.DEFAULT_FANART = self.ADDON.getAddonInfo('fanart') self.ADDON_DATA_PATH = self.ADDON.getAddonInfo( 'path') # Add-on folder self.DATA_PATH = self.ADDON.getAddonInfo( 'profile') # Add-on user data folder self.CACHE_PATH = os.path.join(self.DATA_PATH, 'cache') self.COOKIES_PATH = os.path.join(self.DATA_PATH, 'COOKIES') try: self.PLUGIN_HANDLE = int(argv[1]) self.IS_SERVICE = False self.BASE_URL = '{scheme}://{netloc}'.format( scheme=self.URL[0], netloc=self.URL[1]) except IndexError: self.PLUGIN_HANDLE = 0 self.IS_SERVICE = True self.BASE_URL = '{scheme}://{netloc}'.format( scheme='plugin', netloc=self.ADDON_ID) from resources.lib.common.kodi_ops import GetKodiVersion self.KODI_VERSION = GetKodiVersion() # Initialize the log from resources.lib.utils.logging import LOG LOG.initialize(self.ADDON_ID, self.PLUGIN_HANDLE, self.ADDON.getSettingBool('enable_debug'), self.ADDON.getSettingBool('enable_timing')) if self.IS_ADDON_FIRSTRUN: self.init_database() # Initialize the cache if self.IS_SERVICE: from resources.lib.services.cache_management import CacheManagement self.CACHE_MANAGEMENT = CacheManagement() self.CACHE = self.CACHE_MANAGEMENT from resources.lib.services.settings_monitor import SettingsMonitor self.SETTINGS_MONITOR = SettingsMonitor() else: from resources.lib.common.cache import Cache self.CACHE = Cache() self.IPC_OVER_HTTP = self.ADDON.getSettingBool('enable_ipc_over_http')
def start_services(self): """ Start the background services """ from resources.lib.services.playback.action_controller import ActionController from resources.lib.services.library_updater import LibraryUpdateService from resources.lib.services.settings_monitor import SettingsMonitor for server in self.SERVERS: server['instance'].server_activate() server['instance'].timeout = 1 server['thread'].start() info('[{}] Thread started'.format(server['name'])) self.controller = ActionController() self.library_updater = LibraryUpdateService() self.settings_monitor = SettingsMonitor() # Mark the service as active self._set_service_status('running') if not g.ADDON.getSettingBool('disable_startup_notification'): from resources.lib.kodi.ui import show_notification show_notification(get_local_string(30110))
def start_services(self): """ Start the background services """ from resources.lib.services.playback.action_controller import ActionController from resources.lib.services.library_updater import LibraryUpdateService from resources.lib.services.settings_monitor import SettingsMonitor for server in self.SERVERS: server['instance'].server_activate() server['instance'].timeout = 1 server['thread'].start() LOG.info('[{}] Thread started'.format(server['name'])) self.controller = ActionController() self.library_updater = LibraryUpdateService() self.settings_monitor = SettingsMonitor() # We reset the value in case of any eventuality (add-on disabled, update, etc) WndHomeProps[WndHomeProps.CURRENT_DIRECTORY] = None # Mark the service as active self._set_service_status('running') if not G.ADDON.getSettingBool('disable_startup_notification'): from resources.lib.kodi.ui import show_notification show_notification(get_local_string(30110))