def github_install(): if kodi.arg('rtype') == 'web': from libs import github_installer from libs.github_api import master_url full_name = "%s/%s" % (kodi.arg('user'), kodi.arg('repo')) c = kodi.dialog_confirm("Confirm Install", full_name, yes="Install", no="Cancel") if not c: return url = master_url % (kodi.arg('user'), kodi.arg('repo')) github_installer.GitHub_Installer(kodi.arg('repo'), url, full_name, kodi.vfs.join("special://home", "addons"), True) 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') else: import re from libs import github_installer from libs import github_api c = kodi.dialog_confirm("Confirm Install", kodi.arg('file'), yes="Install", no="Cancel") if not c: return addon_id = re.sub("-[\d\.]+zip$", "", kodi.arg('file')) github_installer.GitHub_Installer(addon_id, kodi.arg('url'), kodi.arg('full_name'), kodi.vfs.join("special://home", "addons")) 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')
def github_results(url): import json from libs import github_installer from libs.github_installer import github_api from libs.github_installer import kodi as _kodi args = json.loads(url) #viewsetter.set_view("list") if args['rtype'] == 'web': from libs.github_installer import kodi as _kodi full_name = "%s/%s" % (args['user'], args['repo']) c = _kodi.dialog_confirm("Confirm Install", full_name, yes="Install", no="Cancel") if not c: return url = "https://github.com/%s/%s/archive/master.zip" % (args['user'], args['repo']) Ins = github_installer.GitHub_Installer(args['repo'], url, full_name, _kodi.vfs.join("special://home", "addons"), True) return results = github_api.find_zips(args['user'], args['repo']) if results is None: return for r in results['items']: if r['repository']['name'] != args['repo']: continue url = github_api.content_url % (r['repository']['full_name'], r['path']) kodi.addItem(r['name'], json.dumps({'file': r['name'], "url": url, "full_name": r['repository']['full_name']}), 'github_install', '', description="")
def github_install(url): import re import json from libs.github_installer import kodi as _kodi from libs import github_installer from libs.github_installer import github_api args = json.loads(url) if 'file' in args: #viewsetter.set_view("list") c = _kodi.dialog_confirm("Confirm Install", args['file']) if not c: return addon_id = re.sub("-[\d\.]+zip$", "", args['file']) github_installer.GitHub_Installer(addon_id, args['url'], args['full_name'], _kodi.vfs.join("special://home", "addons")) if not dialog.yesno(siteTitle, ' Click Continue to install more addons or', ' Restart button to finalize addon installation', " Brought To You By %s " % siteTitle, nolabel='Restart', yeslabel='Continue'): xbmc.executebuiltin('ShutDown') #viewsetter.set_view("list") else: pass
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')