def update_addons(quiet=True): from distutils.version import LooseVersion if not quiet: kodi.open_busy_dialog() sources = DB.query("SELECT addon_id, source FROM install_history") update_count = 0 for source in sources: addon_id = source[0] source = json.loads(source[1]) if kodi.get_condition_visiblity("System.HasAddon(%s)" % addon_id): if source['type'] == SOURCES.ZIP: url, filename, full_name, version = github.find_zip(source['user'], addon_id) current_version = kodi.get_addon(addon_id).getAddonInfo('version') if LooseVersion(version) > LooseVersion(current_version): GitHub_Installer(addon_id, url, full_name, kodi.vfs.join("special://home", "addons"), False, quiet) update_count += 1 elif source['type'] == SOURCES.REPO: full_name = sources['user'] + '/' + sources['repo'] xml_str = github.find_xml(full_name) xml = BeautifulSoup(xml_str) addon = xml.find('addon') current_version = kodi.get_addon(addon_id).getAddonInfo('version') if LooseVersion(addon['version']) > LooseVersion(current_version): GitHub_Installer(addon_id, source['url'], full_name, kodi.vfs.join("special://home", "addons"), True, quiet) update_count += 1 if not quiet: kodi.close_busy_dialog() if update_count > 0: kodi.notify("Update complete",'Some addons may require restarting kodi.') else: kodi.notify("Update complete",'No updates found.')
def user_resolver(user, unmet): dep_url, dep_filename, dep_full_name, version = github.find_zip(user, unmet) if dep_url: kodi.log("%s found in %s repo" % (unmet, user)) self.met_addons.append(unmet) user, repo = dep_full_name.split("/") self.sources[unmet] = {"type": SOURCES.ZIP, "url": dep_url, "user": user, "repo": repo, "version": ""} kodi.log("%s dependency met in %s" % (unmet, dep_url)) return True return False
def install_batch(): import xbmcgui from libs import github from libs import github_installer if kodi.mode == 'install_batch': url = kodi.arg('url') xml, zip_ref = github.batch_installer(url) else: url = kodi.dialog_file_browser('Select a install file', mask='.zip') if not github.re_installer.search(url): return xml, zip_ref = github.batch_installer(url, True) if not kodi.dialog_confirm('Batch Installer?', "Click YES to proceed.", "This will install a list of addons.", "Some configuration files and settings may be overwritten."): return if not xml: return # Install each addon as instructed installed_list = [] count = 0 for a in xml.findAll('addon'): count +=1 PB = kodi.ProgressBar() PB.new('Batch Installer - Progress', count) for a in xml.findAll('addon'): addon_id = a.find('addon_id') username = a.find('username') if addon_id is None or username is None: continue username = username.text addon_id = addon_id.text PB.next(addon_id) if not kodi.get_condition_visiblity("System.HasAddon(%s)"% addon_id): if PB.is_canceled(): return kodi.log("Batch install " + addon_id) url, filename, full_name, version = github.find_zip(username, addon_id) installed_list += github_installer.GitHub_Installer(addon_id, url, full_name, kodi.vfs.join("special://home", "addons"), quiet=True, batch=True, installed_list=installed_list).installed_list kodi.sleep(1000) # Look for config files. # Need to add error checking for missing config files configs= xml.find('configs') if configs is not None and 'dir' in configs.attrs[0]: config_dir = configs['dir'] for config in configs.findAll('config'): source = config.find('source') destination = config.find('destination') if source is None or destination is None: continue source = source.text destination = destination.text if not kodi.vfs.exists(destination): kodi.vfs.mkdir(destination, True) kodi.vfs.write_file(kodi.vfs.join(destination, source), zip_ref.read(config_dir + '/' + source)) # Now look for individual setting key and value pairs # Set them as instructed settings= xml.find('settings') if settings is not None: for setting in settings.findAll('setting'): if 'addon_id' in setting.attrs[0]: addon_id = setting['addon_id'] k = setting.find('key') v = setting.find('value') if k is None or v is None: continue kodi.set_setting(k.text, v.text, addon_id) builtins= xml.find('builtins') if builtins is not None: for cmd in builtins.findAll('command'): cmd = cmd.text kodi.run_command(cmd) jsonrpc= xml.find('jsonrpc') if jsonrpc is not None: from ast import literal_eval for cmd in jsonrpc.findAll('command'): method = cmd.find('method').text params = literal_eval(cmd.find('params').text) id = cmd.find('id').text kodi.kodi_json_request(method, params, id) # Now clean up zip_ref.close() PB.close() r = kodi.dialog_confirm(kodi.get_name(), 'Click Continue to install more addons or', 'Restart button to finalize addon installation', yes='Restart', no='Continue') if r: import sys import xbmc if sys.platform in ['linux', 'linux2', 'win32']: xbmc.executebuiltin('RestartApp') else: xbmc.executebuiltin('ShutDown')