def theme(self, name, theme, over=False): installtheme = False if not theme: themefile = check.check_build(name, 'theme') response = tools.open_url(themefile, check=True) if response: from resources.libs.gui.build_menu import BuildMenu themes = BuildMenu().theme_count(name, False) if len(themes) > 0: if self.dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]The Build [COLOR {1}]{2}[/COLOR] comes with [COLOR {3}]{4}[/COLOR] different themes".format( CONFIG.COLOR2, CONFIG.COLOR1, name, CONFIG.COLOR1, len(themes)), "Would you like to install one now?[/COLOR]", yeslabel="[B][COLOR springgreen]Install Theme[/COLOR][/B]", nolabel="[B][COLOR red]Cancel Themes[/COLOR][/B]"): logging.log("Theme List: {0}".format(str(themes))) ret = self.dialog.select(CONFIG.ADDONTITLE, themes) logging.log("Theme install selected: {0}".format(ret)) if not ret == -1: theme = themes[ret] installtheme = True else: logging.log_notify(CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: Cancelled![/COLOR]'.format(CONFIG.COLOR2)) return else: logging.log_notify(CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: Cancelled![/COLOR]'.format(CONFIG.COLOR2)) return else: logging.log_notify(CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: None Found![/COLOR]'.format(CONFIG.COLOR2)) else: installtheme = self.dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]Would you like to install the theme:'.format(CONFIG.COLOR2), '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, theme), 'for [COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]'.format(CONFIG.COLOR1, name, check.check_build(name, 'version')), yeslabel="[B][COLOR springgreen]Install Theme[/COLOR][/B]", nolabel="[B][COLOR red]Cancel Themes[/COLOR][/B]") if installtheme: themezip = check.check_theme(name, theme, 'url') zipname = name.replace('\\', '').replace('/', '').replace(':', '').replace('*', '').replace('?', '').replace('"', '').replace('<', '').replace('>', '').replace('|', '') response = tools.open_url(themezip, check=True) if not response: logging.log_notify(CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: Invalid Zip Url![/COLOR]'.format(CONFIG.COLOR2)) return False self.dialogProgress.create(CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, theme), '', 'Please Wait') lib = os.path.join(CONFIG.PACKAGES, '{0}.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(themezip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return self.dialogProgress.update(0, "", "Installing {0}".format(name)) test1 = False test2 = False from resources.libs import skin from resources.libs import test test1 = test.test_theme(lib) if CONFIG.SKIN not in skin.DEFAULT_SKINS else False test2 = test.test_gui(lib) if CONFIG.SKIN not in skin.DEFAULT_SKINS else False if test1: skin.look_and_feel_data('save') swap = skin.skin_to_default('Theme Install') if not swap: return False xbmc.sleep(500) title = '[COLOR {0}][B]Installing Theme:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, theme) self.dialogProgress.update(0, title, '', 'Please Wait') percent, errors, error = extract.all(lib, CONFIG.HOME, title=title) CONFIG.set_setting('buildtheme', theme) logging.log('INSTALLED {0}: [ERRORS:{1}]'.format(percent, errors)) self.dialogProgress.close() db.force_check_updates(over=True) installed = db.grab_addons(lib) db.addon_database(installed, 1, True) if test2: skin.look_and_feel_data('save') skin.skin_to_default("Theme Install") gotoskin = CONFIG.get_setting('defaultskin') skin.switch_to_skin(gotoskin, "Theme Installer") skin.look_and_feel_data('restore') elif test1: skin.look_and_feel_data('save') skin.skin_to_default("Theme Install") gotoskin = CONFIG.get_setting('defaultskin') skin.switch_to_skin(gotoskin, "Theme Installer") skin.look_and_feel_data('restore') else: xbmc.executebuiltin("ReloadSkin()") xbmc.sleep(1000) xbmc.executebuiltin("Container.Refresh()") else: logging.log_notify(CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: Cancelled![/COLOR]'.format(CONFIG.COLOR2))
def install_apk(name, url): from resources.libs.downloader import Downloader from resources.libs.common import logging from resources.libs.common import tools from resources.libs.gui import window dialog = xbmcgui.Dialog() progress_dialog = xbmcgui.DialogProgress() addon = xbmcaddon.Addon() path = addon.getSetting('apk_path') apk = os.path.basename(url).replace('\\', '').replace('/', '').replace( ':', '').replace('*', '').replace('?', '').replace('"', '').replace( '<', '').replace('>', '').replace('|', '') apk = apk if apk.endswith('.apk') else '{}.apk'.format(apk) lib = os.path.join(path, apk) if not xbmc.getCondVisibility( 'System.HasAddon(script.kodi.android.update)'): from resources.libs.gui import addon_menu addon_menu.install_from_kodi('script.kodi.android.update') try: updater = xbmcaddon.Addon('script.kodi.android.update') except RuntimeError as e: return False file_manager = int(updater.getSetting('File_Manager')) custom_manager = updater.getSetting('Custom_Manager') use_manager = { 0: 'com.android.documentsui', 1: custom_manager }[file_manager] if tools.platform() == 'android': redownload = True yes = True if os.path.exists(lib): redownload = dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {}]{}[/COLOR] already exists. Would you like to redownload it?' .format(CONFIG.COLOR1, apk), yeslabel="[B]Redownload[/B]", nolabel="[B]Install[/B]") yes = False else: yes = dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]Would you like to download and install: ".format( CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, name), yeslabel="[B][COLOR springgreen]Download[/COLOR][/B]", nolabel="[B][COLOR red]Cancel[/COLOR][/B]") if not yes: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]ERROR: Install Cancelled[/COLOR]'.format( CONFIG.COLOR2)) return if yes or redownload: response = tools.open_url(url, check=True) if not response: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]APK Installer: Invalid Apk Url![/COLOR]'. format(CONFIG.COLOR2)) return progress_dialog.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1, apk), '', 'Please Wait') try: os.remove(lib) except: pass Downloader().download(url, lib) xbmc.sleep(100) progress_dialog.close() dialog.ok( CONFIG.ADDONTITLE, '[COLOR {}]{}[/COLOR] downloaded to [COLOR {}]{}[/COLOR]. If installation doesn\'t start by itself, navigate to that location to install the APK.' .format(CONFIG.COLOR1, apk, CONFIG.COLOR1, path)) logging.log('Opening {} with {}'.format(lib, use_manager), level=xbmc.LOGINFO) xbmc.executebuiltin('StartAndroidActivity({},,,"content://{}")'.format( use_manager, lib)) else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]ERROR: None Android Device[/COLOR]'.format( CONFIG.COLOR2))
def gui(self, name, over=False): if name == CONFIG.get_setting('buildname'): if over: yes_pressed = 1 else: yes_pressed = self.dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]Would you like to apply the guifix for:'.format(CONFIG.COLOR2), '[COLOR {0}]{1}[/COLOR]?[/COLOR]'.format(CONFIG.COLOR1, name), nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Apply Fix[/COLOR][/B]') else: yes_pressed = self.dialog.yesno("{0} - [COLOR red]WARNING!![/COLOR]".format(CONFIG.ADDONTITLE), "[COLOR {0}][COLOR {1}]{2}[/COLOR] community build is not currently installed.".format( CONFIG.COLOR2, CONFIG.COLOR1, name), "Would you like to apply the guiFix anyways?.[/COLOR]", nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Apply Fix[/COLOR][/B]') if yes_pressed: guizip = check.check_build(name, 'gui') zipname = name.replace('\\', '').replace('/', '').replace(':', '').replace('*', '').replace('?', '').replace('"', '').replace('<', '').replace('>', '').replace('|', '') response = tools.open_url(guizip, check=True) if not response: logging.log_notify(CONFIG.ADDONTITLE, '[COLOR {0}]GuiFix: Invalid Zip Url![/COLOR]'.format(CONFIG.COLOR2)) return self.dialogProgress.create(CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading GuiFix:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name), '', 'Please Wait') lib = os.path.join(CONFIG.PACKAGES, '{0}_guisettings.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(guizip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return title = '[COLOR {0}][B]Installing:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name) self.dialogProgress.update(0, title, '', 'Please Wait') extract.all(lib, CONFIG.USERDATA, title=title) self.dialogProgress.close() skin.skin_to_default('Build Install') skin.look_and_feel_data('save') installed = db.grab_addons(lib) db.addon_database(installed, 1, True) self.dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]To save changes you now need to force close Kodi, Press OK to force close Kodi[/COLOR]".format(CONFIG.COLOR2)) tools.kill_kodi(over=True) else: logging.log_notify(CONFIG.ADDONTITLE, '[COLOR {0}]GuiFix: Cancelled![/COLOR]'.format(CONFIG.COLOR2))
def install_addon_from_url(self, plugin, url): from resources.libs.downloader import Downloader from resources.libs import db from resources.libs import extract from resources.libs import skin if 50 - 50: I1IiiI oo0Ooo0 = tools.open_url(url, check=True) if 34 - 34: I1IiiI * II111iiii % o0OO0 * OoOoOO00 - I1IiiI if not oo0Ooo0: logging.log_notify( "[COLOR {0}]Addon Installer[/COLOR]".format(CONFIG.COLOR1), '[COLOR {0}]{1}:[/COLOR] [COLOR {2}]Invalid Zip Url![/COLOR]'. format(CONFIG.COLOR1, plugin, CONFIG.COLOR2)) return if 33 - 33: o0oOOo0O0Ooo + OOooOOo * OoO0O00 - Oo0Ooo / oO0o % Ii1I tools.ensure_folders(CONFIG.PACKAGES) if 21 - 21: OoO0O00 * iIii1I11I1II1 % oO0o * i1IIi self.progress_dialog.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Baixando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'. format(CONFIG.COLOR2, CONFIG.COLOR1, plugin) + '\n' + '' + '\n' + '[COLOR {0}]Por favor, aguarde[/COLOR]'.format(CONFIG.COLOR2)) Ii11Ii1I = url.split('/') O00oO = os.path.join(CONFIG.PACKAGES, Ii11Ii1I[-1]) if 39 - 39: Oo0ooO0oo0oO - II111iiii * OoO0O00 % o0oOOo0O0Ooo * II111iiii % II111iiii try: os.remove(O00oO) except: pass if 59 - 59: iIii1I11I1II1 + I1IiiI - o0oOOo0O0Ooo - I1IiiI + OOooOOo / I1ii11iIi11i Downloader().download(url, O00oO) I1 = '[COLOR {0}][B]Baixando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, plugin) self.progress_dialog.update( 0, I1 + '\n' + '' + '\n' + '[COLOR {0}]Por favor, aguarde[/COLOR]'.format(CONFIG.COLOR2)) OO00Oo, O0OOO0OOoO0O, O00Oo000ooO0 = extract.all(O00oO, CONFIG.ADDONS, title=I1) self.progress_dialog.update( 0, I1 + '\n' + '' + '\n' + '[COLOR {0}]Baixando Dependencies[/COLOR]'.format(CONFIG.COLOR2)) IiiIII111iI(plugin) OoO0O00IIiII = db.grab_addons(O00oO) logging.log(str(OoO0O00IIiII)) db.addon_database(OoO0O00IIiII, 1, True) self.install_dependency(plugin) self.progress_dialog.close() if 80 - 80: Oo0ooO0oo0oO.oO0o xbmc.executebuiltin('UpdateAddonRepos()') xbmc.executebuiltin('UpdateLocalAddons()') xbmc.executebuiltin('Container.Refresh()') if 25 - 25: OoOoOO00.II111iiii / o0OO0.OOooOOo * OoO0O00.I1IiiI for Oo0oOOo in OoO0O00IIiII: if Oo0oOOo.startswith('skin.') and not Oo0oOOo == 'skin.shortcuts': if not CONFIG.BUILDNAME == '' and CONFIG.DEFAULTIGNORE == 'true': CONFIG.set_setting('defaultskinignore', 'true') skin.switch_to_skin(Oo0oOOo, 'Skin Installer') if 58 - 58: II111iiii * OOooOOo * I1ii11iIi11i / OOooOOo
def install_skin(self, name, url): from resources.libs.downloader import Downloader from resources.libs import db from resources.libs import extract from resources.libs.common import logging from resources.libs import skin from resources.libs.common import tools if 78 - 78: O0.oO0o.II111iiii % OOooOOo O0oOoOOOoOO = xbmcgui.DialogProgress() if 49 - 49: Ii1I / OoO0O00.II111iiii oo0Ooo0 = tools.open_url(url, check=False) if 68 - 68: i11iIiiIii % I1ii11iIi11i + i11iIiiIii if not oo0Ooo0: logging.log_notify( "[COLOR {0}]Addon Installer[/COLOR]".format(CONFIG.COLOR1), '[COLOR {0}]{1}:[/COLOR] [COLOR {2}]Invalid Zip Url![/COLOR]'. format(CONFIG.COLOR1, name, CONFIG.COLOR2)) return if 31 - 31: II111iiii.I1IiiI if not os.path.exists(CONFIG.PACKAGES): os.makedirs(CONFIG.PACKAGES) if 1 - 1: Oo0Ooo / o0oOOo0O0Ooo % o0OO0 * Oo0ooO0oo0oO.i11iIiiIii O0oOoOOOoOO.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Baixando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'. format(CONFIG.COLOR2, CONFIG.COLOR1, name) + '\n' + '' + '\n' + '[COLOR {0}]Por favor, aguarde[/COLOR]'.format(CONFIG.COLOR2)) if 2 - 2: I1ii11iIi11i * I11i - iIii1I11I1II1 + I1IiiI.oO0o % o0OO0 Ii11Ii1I = url.split('/') O00oO = xbmc.makeLegalFilename( os.path.join(CONFIG.PACKAGES, Ii11Ii1I[-1])) try: os.remove(O00oO) except: pass Downloader().download(url, O00oO) I1 = '[COLOR {0}][B]Baixando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name) O0oOoOOOoOO.update( 0, I1 + '\n' + '' + '\n' + '[COLOR {0}]Por favor, aguarde[/COLOR]'.format(CONFIG.COLOR2)) OO00Oo, O0OOO0OOoO0O, O00Oo000ooO0 = extract.all(O00oO, CONFIG.HOME, title=I1) IiiIII111iI = db.grab_addons(O00oO) db.addon_database(IiiIII111iI, 1, True) O0oOoOOOoOO.close() logging.log_notify( "[COLOR {0}]Addon Installer[/COLOR]".format(CONFIG.COLOR1), '[COLOR {0}]{1}: Installed![/COLOR]'.format(CONFIG.COLOR2, name)) xbmc.executebuiltin('UpdateAddonRepos()') xbmc.executebuiltin('UpdateLocalAddons()') for Oo0oOOo in IiiIII111iI: if Oo0oOOo.startswith('skin.') and not Oo0oOOo == 'skin.shortcuts': if not CONFIG.BUILDNAME == '' and CONFIG.DEFAULTIGNORE == 'true': CONFIG.set_setting('defaultskinignore', 'true') skin.switch_to_skin(Oo0oOOo, 'Skin Installer') xbmc.executebuiltin('Container.Refresh()') # Team KelTec Media'Play
def wizard_update(startup=None): from resources.libs import check from resources.libs.common import logging from resources.libs.common import tools from resources.libs.gui import window dialog = xbmcgui.Dialog() progress_dialog = xbmcgui.DialogProgress() response = tools.open_url(CONFIG.BUILDFILE, check=True) if response: try: wid, ver, zip = check.check_wizard('all') except: return if ver > CONFIG.ADDON_VERSION: yes = dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}]There is a new version of the {1}!'.format( CONFIG.COLOR2, CONFIG.ADDONTITLE), 'Would you like to download [COLOR {0}]v{1}[/COLOR]?[/COLOR]'. format(CONFIG.COLOR1, ver), nolabel='[B][COLOR red]Remind Me Later[/COLOR][/B]', yeslabel="[B][COLOR springgreen]Update Wizard[/COLOR][/B]") if yes: from resources.libs import db from resources.libs.common import tools logging.log( "[Auto Update Wizard] Installing wizard v{0}".format(ver)) progress_dialog.create( CONFIG.ADDONTITLE, '[COLOR {0}]Downloading Update...'.format(CONFIG.COLOR2), '', 'Please Wait[/COLOR]') lib = os.path.join(CONFIG.PACKAGES, '{0}-{1}.zip'.format(CONFIG.ADDON_ID, ver)) try: os.remove(lib) except: pass from resources.libs.downloader import Downloader from resources.libs import extract Downloader().download(zip, lib) xbmc.sleep(2000) progress_dialog.update( 0, "", "Installing {0} update".format(CONFIG.ADDONTITLE)) percent, errors, error = extract.all(lib, CONFIG.ADDONS, True) progress_dialog.close() xbmc.sleep(1000) db.force_check_updates(auto=True, over=True) xbmc.sleep(1000) logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Add-on updated[/COLOR]'.format(CONFIG.COLOR2)) logging.log( "[Auto Update Wizard] Wizard updated to v{0}".format(ver)) tools.remove_file( os.path.join(CONFIG.ADDONDATA, 'settings.xml')) window.show_save_data_settings() if startup: xbmc.executebuiltin('RunScript({0}/startup.py)'.format( CONFIG.PLUGIN)) return else: logging.log( "[Auto Update Wizard] Install New Wizard Ignored: {0}". format(ver)) else: if not startup: logging.log_notify( CONFIG.ADDONTITLE, "[COLOR {0}]No New Version of Wizard[/COLOR]".format( CONFIG.COLOR2)) logging.log("[Auto Update Wizard] No New Version v{0}".format(ver)) else: logging.log( "[Auto Update Wizard] Url for wizard file not valid: {0}".format( CONFIG.BUILDFILE))
def install_apk(apk, url): from resources.libs.downloader import Downloader from resources.libs.common import logging from resources.libs.common import tools from resources.libs.gui import window dialog = xbmcgui.Dialog() progress_dialog = xbmcgui.DialogProgress() logging.log(apk) logging.log(url) if tools.platform() == 'android': yes = dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]Would you like to download and install: ".format( CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, apk), yeslabel="[B][COLOR springgreen]Download[/COLOR][/B]", nolabel="[B][COLOR red]Cancel[/COLOR][/B]") if not yes: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]ERROR: Install Cancelled[/COLOR]'.format( CONFIG.COLOR2)) return display = apk if not os.path.exists(CONFIG.PACKAGES): os.makedirs(CONFIG.PACKAGES) response = tools.open_url(url, check=True) if not response: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]APK Installer: Invalid Apk Url![/COLOR]'.format( CONFIG.COLOR2)) return progress_dialog.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'. format(CONFIG.COLOR2, CONFIG.COLOR1, display), '', 'Please Wait') lib = os.path.join( CONFIG.PACKAGES, "{0}.apk".format( apk.replace('\\', '').replace('/', '').replace( ':', '').replace('*', '').replace('?', '').replace( '"', '').replace('<', '').replace('>', '').replace('|', ''))) try: os.remove(lib) except: pass Downloader().download(url, lib) xbmc.sleep(100) progress_dialog.close() window.show_apk_warning(apk) xbmc.executebuiltin( 'StartAndroidActivity("","android.intent.action.VIEW","application/vnd.android.package-archive","file:{0}")' .format(lib)) else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]ERROR: None Android Device[/COLOR]'.format( CONFIG.COLOR2))
def auto_install_repo(): if not os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.REPOID)): response = tools.open_url(CONFIG.REPOADDONXML) if response: from xml.etree import ElementTree root = ElementTree.fromstring(response.text) repoaddon = root.findall('addon') repoversion = [ tag.get('version') for tag in repoaddon if tag.get('id') == CONFIG.REPOID ] if repoversion: installzip = '{0}-{1}.zip'.format(CONFIG.REPOID, repoversion[0]) url = CONFIG.REPOZIPURL + installzip repo_response = tools.open_url(url, check=True) if repo_response: progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(CONFIG.ADDONTITLE, 'Downloading Repo...', '', 'Please Wait') tools.ensure_folders(CONFIG.PACKAGES) lib = os.path.join(CONFIG.PACKAGES, installzip) # Remove the old zip if there is one tools.remove_file(lib) from resources.libs.downloader import Downloader from resources.libs import extract Downloader().download(url, lib) extract.all(lib, CONFIG.ADDONS) try: repoxml = os.path.join(CONFIG.ADDONS, CONFIG.REPOID, 'addon.xml') root = ElementTree.parse(repoxml).getroot() reponame = root.get('name') logging.log_notify( "{1}".format(CONFIG.COLOR1, reponame), "[COLOR {0}]Add-on updated[/COLOR]".format( CONFIG.COLOR2), icon=os.path.join(CONFIG.ADDONS, CONFIG.REPOID, 'icon.png')) except Exception as e: logging.log(str(e), level=xbmc.LOGERROR) # Add wizard to add-on database db.addon_database(CONFIG.REPOID, 1) progress_dialog.close() xbmc.sleep(500) logging.log("[Auto Install Repo] Successfully Installed", level=xbmc.LOGNOTICE) else: logging.log_notify( "[COLOR {0}]Repo Install Error[/COLOR]".format( CONFIG.COLOR1), "[COLOR {0}]Invalid URL for zip![/COLOR]".format( CONFIG.COLOR2)) logging.log( "[Auto Install Repo] Was unable to create a working URL for repository. {0}" .format(url), level=xbmc.LOGERROR) else: logging.log("Invalid URL for Repo zip", level=xbmc.LOGERROR) else: logging.log_notify( "[COLOR {0}]Repo Install Error[/COLOR]".format(CONFIG.COLOR1), "[COLOR {0}]Invalid addon.xml file![/COLOR]".format( CONFIG.COLOR2)) logging.log( "[Auto Install Repo] Unable to read the addon.xml file.", level=xbmc.LOGERROR) elif not CONFIG.AUTOINSTALL == 'Yes': logging.log("[Auto Install Repo] Not Enabled", level=xbmc.LOGNOTICE) elif os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.REPOID)): logging.log("[Auto Install Repo] Repository already installed")
def build(self, name, over=False): # if action == 'normal': # if CONFIG.KEEPTRAKT == 'true': # from resources.libs import traktit # traktit.auto_update('all') # CONFIG.set_setting('traktnextsave', tools.get_date(days=3, formatted=True)) # if CONFIG.KEEPDEBRID == 'true': # from resources.libs import debridit # debridit.auto_update('all') # CONFIG.set_setting('debridnextsave', tools.get_date(days=3, formatted=True)) # if CONFIG.KEEPLOGIN == 'true': # from resources.libs import loginit # loginit.auto_update('all') # CONFIG.set_setting('loginnextsave', tools.get_date(days=3, formatted=True)) temp_kodiv = int(CONFIG.KODIV) buildv = int(float(check.check_build(name, 'kodi'))) if not temp_kodiv == buildv: warning = True else: warning = False if warning: yes_pressed = self.dialog.yesno( "{0} - [COLOR red]WARNING!![/COLOR]".format(CONFIG.ADDONTITLE), '[COLOR {0}]There is a chance that the skin will not appear correctly' .format(CONFIG.COLOR2) + '\n' + 'When installing a {0} build on a Kodi {1} install'.format( check.check_build(name, 'kodi'), CONFIG.KODIV) + '\n' + 'Would you still like to install: [COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]' .format(CONFIG.COLOR1, name, check.check_build( name, 'version')), nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Yes, Install[/COLOR][/B]') else: if over: yes_pressed = 1 else: yes_pressed = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}]Would you like to Download and Install: '. format(CONFIG.COLOR2) + '[COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]'.format( CONFIG.COLOR1, name, check.check_build( name, 'version')), nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Yes, Install[/COLOR][/B]') if yes_pressed: CONFIG.clear_setting('build') buildzip = check.check_build(name, 'url') zipname = name.replace('\\', '').replace('/', '').replace( ':', '').replace('*', '').replace('?', '').replace('"', '').replace( '<', '').replace('>', '').replace('|', '') self.dialogProgress.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) + '\n' + 'Please Wait') lib = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(buildzip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return install.wipe() skin.look_and_feel_data('save') title = '[COLOR {0}][B]Installing:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) self.dialogProgress.update(0, title + '\n' + 'Please Wait') percent, errors, error = extract.all(lib, CONFIG.HOME, title=title) skin.skin_to_default('Build Install') if int(float(percent)) > 0: db.fix_metas() CONFIG.set_setting('buildname', name) CONFIG.set_setting('buildversion', check.check_build(name, 'version')) CONFIG.set_setting('buildtheme', '') CONFIG.set_setting('latestversion', check.check_build(name, 'version')) CONFIG.set_setting( 'nextbuildcheck', tools.get_date(days=CONFIG.UPDATECHECK, formatted=True)) CONFIG.set_setting('installed', 'true') CONFIG.set_setting('extract', percent) CONFIG.set_setting('errors', errors) logging.log('INSTALLED {0}: [ERRORS:{1}]'.format( percent, errors)) try: os.remove(lib) except: pass if int(float(errors)) > 0: yes_pressed = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}][COLOR {1}]{2} v{3}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) + '\n' + 'Completed: [COLOR {0}]{1}{2}[/COLOR] [Errors:[COLOR {3}]{4}[/COLOR]]' .format(CONFIG.COLOR1, percent, '%', CONFIG.COLOR1, errors) + '\n' + 'Would you like to view the errors?[/COLOR]', nolabel='[B][COLOR red]No Thanks[/COLOR][/B]', yeslabel='[B][COLOR springgreen]View Errors[/COLOR][/B]' ) if yes_pressed: from resources.libs.gui import window window.show_text_box("Viewing Build Install Errors", error) self.dialogProgress.close() from resources.libs.gui.build_menu import BuildMenu themecount = BuildMenu().theme_count(name) if themecount > 0: self.theme(name, 'theme') db.addon_database(CONFIG.ADDON_ID, 1) db.force_check_updates(over=True) if os.path.exists(os.path.join(CONFIG.USERDATA, '.enableall')): CONFIG.set_setting('enable_all', 'true') self.dialog.ok( CONFIG.ADDONTITLE, "[COLOR {0}]To save changes you now need to force close Kodi, Press OK to force close Kodi[/COLOR]" .format(CONFIG.COLOR2)) tools.kill_kodi(over=True) else: from resources.libs.gui import window window.show_text_box("Viewing Build Install Errors", error) else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Build Install: Cancelled![/COLOR]'.format( CONFIG.COLOR2))
def auto_install_repo(): if not os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.REPOID)): response = tools.open_url(CONFIG.REPOADDONXML) if response: from xml.etree import ElementTree root = ElementTree.fromstring(response.text) repoaddon = root.findall('addon') repoversion = [ tag.get('version') for tag in repoaddon if tag.get('id') == CONFIG.REPOID ] if repoversion: installzip = '{0}-{1}.zip'.format(CONFIG.REPOID, repoversion[0]) url = CONFIG.REPOZIPURL + installzip repo_response = tools.open_url(url, check=True) if repo_response: progress_dialog = xbmcgui.DialogProgress() progress_dialog.create( CONFIG.ADDONTITLE, 'Descargando Repo...' + '\n' + 'Espere por favor') tools.ensure_folders(CONFIG.PACKAGES) lib = os.path.join(CONFIG.PACKAGES, installzip) # Remove the old zip if there is one tools.remove_file(lib) from resources.libs.downloader import Downloader from resources.libs import extract Downloader().download(url, lib) extract.all(lib, CONFIG.ADDONS) try: repoxml = os.path.join(CONFIG.ADDONS, CONFIG.REPOID, 'addon.xml') root = ElementTree.parse(repoxml).getroot() reponame = root.get('name') logging.log_notify( "{1}".format(CONFIG.COLOR1, reponame), "[COLOR {0}]Add-on actualizado[/COLOR]".format( CONFIG.COLOR2), icon=os.path.join(CONFIG.ADDONS, CONFIG.REPOID, 'icon.png')) except Exception as e: logging.log(str(e), level=xbmc.LOGERROR) # Add wizard to add-on database db.addon_database(CONFIG.REPOID, 1) progress_dialog.close() xbmc.sleep(500) logging.log("[Auto Install Repo] Instalado exitosamente", level=xbmc.LOGINFO) else: logging.log_notify( "[COLOR {0}]Error de instalación del repositorio[/COLOR]" .format(CONFIG.COLOR1), "[COLOR {0}]URL no válida para zip.[/COLOR]".format( CONFIG.COLOR2)) logging.log( "[Auto Install Repo] No se pudo crear una URL funcional para el repositorio.. {0}" .format(url), level=xbmc.LOGERROR) else: logging.log("URL no válida para el zip del repositorio", level=xbmc.LOGERROR) else: logging.log_notify( "[COLOR {0}]Error de instalación del repositorio[/COLOR]". format(CONFIG.COLOR1), "[COLOR {0}]Archivo addon.xml no válido![/COLOR]".format( CONFIG.COLOR2)) logging.log( "[Auto Install Repo] No se puede leer el archivo addon.xml.", level=xbmc.LOGERROR) elif not CONFIG.AUTOINSTALL == 'Yes': logging.log("[Auto Install Repo] No habilitado", level=xbmc.LOGINFO) elif os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.REPOID)): logging.log("[Auto Install Repo] Repositorio ya instalado")
def auto_install_repo(): if not os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.REPOID)): response = tools.open_url(CONFIG.REPOADDONXML) if response: ver = tools.parse_dom(response.text, 'addon', ret='version', attrs={'id': CONFIG.REPOID}) if len(ver) > 0: installzip = '{0}-{1}.zip'.format(CONFIG.REPOID, ver[0]) repo_response = tools.open_url(CONFIG.REPOZIPURL + installzip) if repo_response: progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(CONFIG.ADDONTITLE, 'Downloading Repo...', '', 'Please Wait') tools.ensure_folders(CONFIG.PACKAGES) lib = os.path.join(CONFIG.PACKAGES, installzip) # Remove the old zip if there is one tools.remove_file(lib) from resources.libs.downloader import Downloader from resources.libs import extract Downloader().download(CONFIG.REPOZIPURL + installzip, lib) extract.all(lib, CONFIG.ADDONS) try: repoxml = os.path.join(CONFIG.ADDONS, CONFIG.REPOID, 'addon.xml') name = tools.parse_dom(tools.read_from_file(repoxml), 'addon', ret='name', attrs={'id': CONFIG.REPOID}) logging.log_notify( "[COLOR {0}]{1}[/COLOR]".format( CONFIG.COLOR1, name[0]), "[COLOR {0}]Add-on updated[/COLOR]".format( CONFIG.COLOR2), icon=os.path.join(CONFIG.ADDONS, CONFIG.REPOID, 'icon.png')) except Exception as e: logging.log(str(e), level=xbmc.LOGERROR) # Add wizard to add-on database db.addon_database(CONFIG.REPOID, 1) progress_dialog.close() xbmc.sleep(500) logging.log("[Auto Install Repo] Successfully Installed", level=xbmc.LOGNOTICE) else: logging.log_notify( "[COLOR {0}]Repo Install Error[/COLOR]".format( CONFIG.COLOR1), "[COLOR {0}]Invalid URL for zip![/COLOR]".format( CONFIG.COLOR2)) logging.log( "[Auto Install Repo] Was unable to create a working URL for repository. {0}" .format(repo_response.text), level=xbmc.LOGERROR) else: logging.log("Invalid URL for Repo zip", level=xbmc.LOGERROR) else: logging.log_notify( "[COLOR {0}]Repo Install Error[/COLOR]".format(CONFIG.COLOR1), "[COLOR {0}]Invalid addon.xml file![/COLOR]".format( CONFIG.COLOR2)) logging.log( "[Auto Install Repo] Unable to read the addon.xml file.", level=xbmc.LOGERROR) elif not CONFIG.AUTOINSTALL == 'Yes': logging.log("[Auto Install Repo] Not Enabled", level=xbmc.LOGNOTICE) elif os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.REPOID)): logging.log("[Auto Install Repo] Repository already installed")
def install(self, name): CONFIG.clear_setting('build') if CONFIG.get_setting('choicelink') == 'true': buildzip = check.check_data(name,'url') elif CONFIG.get_setting('choicelink') == 'false': buildzip = check.check_data(name,'url') zipname = name.replace('\\', '').replace('/', '').replace(':', '').replace('*', '').replace('?', '').replace('"', '').replace('<', '').replace('>', '').replace('|', '') self.dialogProgress.create(CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name) + '\n' + 'Please Wait') lib = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(buildzip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return # install.wipe() # skin.look_and_feel_data('save') title = '[COLOR {0}][B]Installing:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) self.dialogProgress.update(0, title + '\n' + 'Please Wait') percent, errors, error = extract.all(lib, CONFIG.HOME, title=title) # skin.skin_to_default('Build Install') if int(float(percent)) > 0: # db.fix_metas() # CONFIG.set_setting('buildname', name) # CONFIG.set_setting('buildversion', check.check_build(name, 'version')) # CONFIG.set_setting('buildtheme', '') # CONFIG.set_setting('latestversion', check.check_build(name, 'version')) # CONFIG.set_setting('nextbuildcheck', tools.get_date(days=CONFIG.UPDATECHECK, formatted=True)) # CONFIG.set_setting('installed', 'true') # CONFIG.set_setting('extract', percent) # CONFIG.set_setting('errors', errors) logging.log('INSTALLED {0}: [ERRORS:{1}]'.format(percent, errors)) try: os.remove(lib) except: pass if int(float(errors)) > 0: yes_pressed = self.dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}][COLOR {1}]{2} v{3}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')), 'Completed: [COLOR {0}]{1}{2}[/COLOR] [Errors:[COLOR {3}]{4}[/COLOR]]'.format( CONFIG.COLOR1, percent, '%', CONFIG.COLOR1, errors), 'Would you like to view the errors?[/COLOR]', nolabel='[B][COLOR red]No Thanks[/COLOR][/B]', yeslabel='[B][COLOR springgreen]View Errors[/COLOR][/B]') if yes_pressed: from resources.libs.gui import window window.show_text_box("Viewing Build Install Errors", error) self.dialogProgress.close() # from resources.libs.gui.build_menu import BuildMenu # themecount = BuildMenu().theme_count(name) # if themecount > 0: # self.theme(name, 'theme') # db.addon_database(CONFIG.ADDON_ID, 1) # #db.force_check_updates(over=True) self.dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]Khôi phục xong, nhấn OK và thưởng thức ^^[/COLOR]".format(CONFIG.COLOR2)) # tools.kill_kodi(over=True) else: from resources.libs.gui import window window.show_text_box("Viewing Build Install Errors", error)