def init_globals(self): """Initialized globally used module variables. Needs to be called at start of each plugin instance!""" # xbmcaddon.Addon must be created at every instance otherwise it does not read any new changes to the settings self.ADDON = xbmcaddon.Addon() self.ADDON_ID = self.ADDON.getAddonInfo('id') self.PLUGIN = self.ADDON.getAddonInfo('name') self.ICON = self.ADDON.getAddonInfo('icon') self.ADDON_DATA_PATH = self.ADDON.getAddonInfo('path') # Add-on folder self.DATA_PATH = self.ADDON.getAddonInfo( 'profile') # Add-on user data folder try: self.IS_SERVICE = False except IndexError: self.IS_SERVICE = True # Initialize the log from resources.lib.helpers.logging import LOG LOG.initialize(self.ADDON_ID, G.ADDON.getSettingBool('enable_debug'), G.ADDON.getSettingBool('debug_dial_server'), G.ADDON.getSettingBool('debug_ssdp_server'), G.ADDON.getSettingBool('debug_apps')) # Set SSDP server variables self.SP_FRIENDLY_NAME = xbmc.getInfoLabel( "System.FriendlyName") or 'Kodi (AppCast)' self.SP_MODEL_NAME = 'MyDeviceModel' self.SP_MANUFACTURER_NAME = ' ' self.DEVICE_UUID = get_system_appcast_uuid()
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 # 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.ADDON_DATA_PATH = self.ADDON.getAddonInfo('path') # Add-on folder self.DATA_PATH = self.ADDON.getAddonInfo('profile') # Add-on user data folder 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) # Initialize the log from resources.lib.helpers.logging import LOG LOG.initialize(self.ADDON_ID, self.PLUGIN_HANDLE, self.ADDON.getSettingString('debug_log_level'), self.ADDON.getSettingBool('enable_timing')) # Temporary file path (use to download and run the installer) from resources.lib.helpers.file_ops import translate_path self.INSTALLER_TEMP_PATH = translate_path(G.DATA_PATH) + 'temp/' self.INSTALLER_TEMP_NAME = 'KodiInstaller.exe' # Mush be equal to all scripts self.DOWNLOADS_PATH = translate_path(G.DATA_PATH) + 'downloads/'