def parse(file, foldername): getid = tools.parse_dom(file, 'addon', ret='id') getname = tools.parse_dom(file, 'addon', ret='name') addid = foldername if len(getid) == 0 else getid[0] title = foldername if len(getname) == 0 else getname[0] temp = title.replace('[', '<').replace(']', '>') temp = re.sub('<[^<]+?>', '', temp) return temp, addid
def kodi_17_fix(): from resources.libs.common import tools from resources.libs import update addonlist = glob.glob(os.path.join(CONFIG.ADDONS, '*/')) disabledAddons = [] for folder in sorted(addonlist, key=lambda x: x): addonxml = os.path.join(folder, 'addon.xml') if os.path.exists(addonxml): fold = folder.replace(CONFIG.ADDONS, '')[1:-1] aid = tools.parse_dom(tools.read_from_file(addonxml), 'addon', ret='id') try: if len(aid) > 0: addonid = aid[0] else: addonid = fold except: try: logging.log("{0} was disabled".format(aid[0])) disabledAddons.append(addonid) except: logging.log("Unable to enable: {0}".format(folder), level=xbmc.LOGERROR) if len(disabledAddons) > 0: addon_database(disabledAddons, 1, True) logging.log_notify( CONFIG.ADDONTITLE, "[COLOR {0}]Enabling Addons Complete![/COLOR]".format( CONFIG.COLOR2)) update.force_update() xbmc.executebuiltin("ReloadSkin()")
def unhide_password(): from resources.libs.common import tools from resources.libs.common import logging dialog = xbmcgui.Dialog() if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]Would you like to [COLOR {1}]unhide[/COLOR] all passwords when typing in the add-on settings menus?[/COLOR]".format(CONFIG.COLOR2, CONFIG.COLOR1), yeslabel="[B][COLOR springgreen]Unhide Passwords[/COLOR][/B]", nolabel="[B][COLOR red]No Cancel[/COLOR][/B]"): count = 0 for folder in glob.glob(os.path.join(CONFIG.ADDONS, '*/')): sett = os.path.join(folder, 'resources', 'settings.xml') if os.path.exists(sett): f = tools.read_from_file(sett) match = tools.parse_dom(f, 'addon', ret='id') for line in match: if 'pass' in line: if 'option="hidden"' in line: try: change = line.replace('option="hidden"', '') f.replace(line, change) count += 1 logging.log("[Unhide Passwords] found in {0} on {1}".format(sett.replace(CONFIG.HOME, ''), line)) except: pass tools.write_to_file(sett, f) logging.log_notify("[COLOR {0}]Unhide Passwords[/COLOR]".format(CONFIG.COLOR1), "[COLOR {0}]{1} items changed[/COLOR]".format(CONFIG.COLOR2, count)) logging.log("[Unhide Passwords] {0} items changed".format(count)) else: logging.log("[Unhide Passwords] Cancelled")
def installed(addon): url = os.path.join(CONFIG.ADDONS, addon, 'addon.xml') if os.path.exists(url): try: name = tools.parse_dom(tools.read_from_file(url), 'addon', ret='name', attrs={'id': addon}) icon = os.path.join(CONFIG.ADDONS, addon, 'icon.png') # read from infolabel? logging.log_notify('[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, name[0]), '[COLOR {0}]Add-on Enabled[/COLOR]'.format(CONFIG.COLOR2), '2000', icon) except: pass
def depends_list(plugin): addonxml = os.path.join(CONFIG.ADDONS, plugin, 'addon.xml') if os.path.exists(addonxml): match = tools.parse_dom(tools.read_from_file(addonxml), 'import', ret='addon') items = [] for depends in match: if not 'xbmc.python' in depends: items.append(depends) return items return []
def install_dependency(self, plugin): from resources.libs import db dep = os.path.join(CONFIG.ADDONS, plugin, 'addon.xml') if os.path.exists(dep): match = tools.parse_dom(tools.read_from_file(dep), 'import', ret='addon') for depends in match: if 'xbmc.python' not in depends: self.progress_dialog.update(0, '\n'+'[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, depends)) try: add = tools.get_addon_by_id(id=depends) name2 = tools.get_addon_info(add, 'name') except: db.create_temp(depends) db.addon_database(depends, 1)
def toggle_dependency(name, dp=None): from resources.libs.common import tools dep = os.path.join(CONFIG.ADDONS, name, 'addon.xml') if os.path.exists(dep): match = tools.parse_dom(tools.read_from_file(dep), 'import', ret='addon') for depends in match: if 'xbmc.python' not in depends: dependspath = os.path.join(CONFIG.ADDONS, depends) if dp is not None: dp.update("", "Checking Dependency [COLOR yellow]{0}[/COLOR] for [COLOR yellow]{1}[/COLOR]".format(depends, name), "") if os.path.exists(dependspath): toggle_addon(name, 'true') xbmc.sleep(100)
def IiiIII111iI(addon): IiII = os.path.join(CONFIG.ADDONS, addon, 'addon.xml') if os.path.exists(IiII): try: iI1Ii11111iIi = tools.parse_dom(tools.read_from_file(IiII), 'addon', ret='name', attrs={'id': addon}) i1i1II = os.path.join(CONFIG.ADDONS, addon, 'icon.png') logging.log_notify( '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, iI1Ii11111iIi[0]), '[COLOR {0}]Add-on ativado[/COLOR]'.format(CONFIG.COLOR2), '2000', i1i1II) except: pass if 96 - 96: o0OO0 - Oo0ooO0oo0oO.I1i1iI1i - o00ooo0 / Oo0ooO0oo0oO * Oo0Ooo if 16 - 16: oO0o % OOooOOo * o0OO0.OOooOOo / iIii1I11I1II1 * iIii1I11I1II1
def install_dependency(self, plugin): from resources.libs import db if 31 - 31: I11i - i1IIi * OOooOOo / OoooooooOO iI = os.path.join(CONFIG.ADDONS, plugin, 'addon.xml') if os.path.exists(iI): o00O = tools.parse_dom(tools.read_from_file(iI), 'import', ret='addon') for OOO0OOO00oo in o00O: if 'xbmc.python' not in OOO0OOO00oo: self.progress_dialog.update( 0, '\n' + '[COLOR {0}]{1}[/COLOR]'.format( CONFIG.COLOR1, OOO0OOO00oo)) if 31 - 31: II111iiii - OOooOOo.I1i1iI1i % OoOoOO00 - O0 try: i1 = tools.get_addon_by_id(id=OOO0OOO00oo) iii11 = tools.get_addon_info(i1, 'name') except: db.create_temp(OOO0OOO00oo) db.addon_database(OOO0OOO00oo, 1) if 58 - 58: OOooOOo * i11iIiiIii / OoOoOO00 % I1i1iI1i - I1ii11iIi11i / oO0o
def check_skin(): from resources.libs.common import logging from resources.libs.common import tools dialog = xbmcgui.Dialog() logging.log("[Build Check] Invalid Skin Check Start") gotoskin = False if not CONFIG.DEFAULTSKIN == '': if os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.DEFAULTSKIN)): if dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]It seems that the skin has been set back to [COLOR {1}]{2}[/COLOR]" .format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.SKIN[5:].title()), "Would you like to set the skin back to:[/COLOR]", '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.DEFAULTNAME)): gotoskin = CONFIG.DEFAULTSKIN gotoname = CONFIG.DEFAULTNAME else: logging.log("Skin was not reset") CONFIG.set_setting('defaultskinignore', 'true') gotoskin = False else: CONFIG.set_setting('defaultskin', '') CONFIG.set_setting('defaultskinname', '') CONFIG.DEFAULTSKIN = '' CONFIG.DEFAULTNAME = '' if CONFIG.DEFAULTSKIN == '': skinname = [] skinlist = [] for folder in glob.glob(os.path.join(CONFIG.ADDONS, 'skin.*/')): xml = "{0}/addon.xml".format(folder) if os.path.exists(xml): g = tools.read_from_file(xml).replace('\n', '').replace( '\r', '').replace('\t', '') match = tools.parse_dom(g, 'addon', ret='id') match2 = tools.parse_dom(g, 'addon', ret='name') logging.log("{0}: {1}".format(folder, str(match[0]))) if len(match) > 0: skinlist.append(str(match[0])) skinname.append(str(match2[0])) else: logging.log("ID not found for {0}".format(folder)) else: logging.log("ID not found for {0}".format(folder)) if len(skinlist) > 0: if len(skinlist) > 1: if dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]It seems that the skin has been set back to [COLOR {1}]{2}[/COLOR]" .format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.SKIN[5:].title()), "Would you like to view a list of avaliable skins?[/COLOR]" ): choice = dialog.select("Select skin to switch to!", skinname) if choice == -1: logging.log("Skin was not reset") CONFIG.set_setting('defaultskinignore', 'true') else: gotoskin = skinlist[choice] gotoname = skinname[choice] else: logging.log("Skin was not reset") CONFIG.set_setting('defaultskinignore', 'true') else: if dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]It seems that the skin has been set back to [COLOR {1}]{2}[/COLOR]" .format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.SKIN[5:].title()), "Would you like to set the skin back to:[/COLOR]", '[COLOR {0}]{1}[/COLOR]'.format( CONFIG.COLOR1, skinname[0])): gotoskin = skinlist[0] gotoname = skinname[0] else: logging.log("Skin was not reset") CONFIG.set_setting('defaultskinignore', 'true') else: logging.log("No skins found in addons folder.") CONFIG.set_setting('defaultskinignore', 'true') gotoskin = False if gotoskin: from resources.libs import skin if skin.switch_to_skin(gotoskin): skin.look_and_feel_data('restore') logging.log("[Build Check] Invalid Skin Check End")
def install_addon(plugin, url): from resources.libs.common import logging from resources.libs.common import tools if tools.open_url(CONFIG.ADDONFILE, check=True): from resources.libs import clear from resources.libs import db from resources.libs import extract from resources.libs import skin dialog = xbmcgui.Dialog() if url is None: url = CONFIG.ADDONFILE response = tools.open_url(url) if response: link = response.text.replace('\n', '').replace('\r', '').replace( '\t', '').replace('repository=""', 'repository="none"').replace( 'repositoryurl=""', 'repositoryurl="http://"').replace( 'repositoryxml=""', 'repositoryxml="http://"') match = re.compile( 'name="(.+?)".+?lugin="%s".+?rl="(.+?)".+?epository="(.+?)".+?epositoryxml="(.+?)".+?epositoryurl="(.+?)".+?con="(.+?)".+?anart="(.+?)".+?dult="(.+?)".+?escription="(.+?)"' % plugin).findall(link) if len(match) > 0: for name, url, repository, repositoryxml, repositoryurl, icon, fanart, adult, description in match: if os.path.exists(os.path.join(CONFIG.ADDONS, plugin)): do = ['Launch Addon', 'Remove Addon'] selected = dialog.select( "[COLOR {0}]Addon already installed what would you like to do?[/COLOR]" .format(CONFIG.COLOR2), do) if selected == 0: xbmc.executebuiltin( 'InstallAddon({0})'.format(plugin)) xbmc.sleep(500) return True elif selected == 1: tools.clean_house( os.path.join(CONFIG.ADDONS, plugin)) try: tools.remove_folder( os.path.join(CONFIG.ADDONS, plugin)) except: pass if dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]Would you like to remove the addon_data for:" .format(CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]?[/COLOR]".format( CONFIG.COLOR1, plugin), yeslabel= "[B][COLOR springgreen]Yes Remove[/COLOR][/B]", nolabel="[B][COLOR red]No Skip[/COLOR][/B]" ): clear.remove_addon_data(plugin) xbmc.executebuiltin('Container.Refresh()') return True else: return False repo = os.path.join(CONFIG.ADDONS, repository) if repository.lower() != 'none' and not os.path.exists( repo): logging.log("Repository not installed, installing it") if dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]Would you like to install the repository for [COLOR {1}]{2}[/COLOR]: " .format(CONFIG.COLOR2, CONFIG.COLOR1, plugin), "[COLOR {0}]{1}[/COLOR]?[/COLOR]".format( CONFIG.COLOR1, repository), yeslabel= "[B][COLOR springgreen]Yes Install[/COLOR][/B]", nolabel="[B][COLOR red]No Skip[/COLOR][/B]"): ver = tools.parse_dom( tools.open_url(repositoryxml).text, 'addon', ret='version', attrs={'id': repository}) if len(ver) > 0: repozip = '{0}{1}-{2}.zip'.format( repositoryurl, repository, ver[0]) logging.log(repozip) db.addon_database(repository, 1) install_addon(repository, repozip) xbmc.executebuiltin('UpdateAddonRepos()') logging.log("Installing Addon from Kodi") install = install_from_kodi(plugin) logging.log( "Install from Kodi: {0}".format(install)) if install: xbmc.executebuiltin('Container.Refresh()') return True else: logging.log( "[Addon Installer] Repository not installed: Unable to grab url! ({0})" .format(repository)) else: logging.log( "[Addon Installer] Repository for {0} not installed: {1}" .format(plugin, repository)) elif repository.lower() == 'none': logging.log("No repository, installing addon") pluginid = plugin zipurl = url install_addon_from_url(plugin, url) xbmc.executebuiltin('Container.Refresh()') return True else: logging.log("Repository installed, installing addon") install = install_from_kodi(plugin) if install: xbmc.executebuiltin('Container.Refresh()') return True if os.path.exists(os.path.join(CONFIG.ADDONS, plugin)): return True ver2 = tools.parse_dom(tools.open_url(repositoryxml), 'addon', ret='version', attrs={'id': plugin}) if len(ver2) > 0: url = "{0}{1}-{2}.zip".format(url, plugin, ver2[0]) logging.log(str(url)) db.addon_database(plugin, 1) install_addon_from_url(plugin, url) xbmc.executebuiltin('Container.Refresh()') else: logging.log("no match") return False else: logging.log("[Addon Installer] Invalid Format") else: logging.log("[Addon Installer] Text File: {0}".format( CONFIG.ADDONFILE)) else: logging.log("[Addon Installer] Not Enabled.")
def _backup_guifix(name=""): dialog = xbmcgui.Dialog() if name == "": guiname = tools.get_keyboard("", "Please enter a name for the GUI Fix zip") if not guiname: return False tools.convert_special(CONFIG.USERDATA, True) tools.ascii_check(CONFIG.USERDATA, True) else: guiname = name guiname = quote_plus(guiname) tempguizipname = '' guizipname = os.path.join(CONFIG.MYBUILDS, '{0}_guisettings.zip'.format(guiname)) if os.path.exists(CONFIG.GUISETTINGS): try: zipf = zipfile.ZipFile(guizipname, mode='w') except: try: tempguizipname = os.path.join(CONFIG.PACKAGES, '{0}_guisettings.zip'.format(guiname)) zipf = zipfile.ZipFile(tempguizipname, mode='w') except: logging.log("Unable to create {0}_guisettings.zip".format(guiname), level=xbmc.LOGERROR) if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]We are unable to write to the current backup directory, would you like to change the location?[/COLOR]".format(CONFIG.COLOR2), yeslabel="[B][COLOR springgreen]Change Directory[/COLOR][/B]", nolabel="[B][COLOR red]Cancel[/COLOR][/B]"): CONFIG.open_settings() return else: return try: zipf.write(CONFIG.GUISETTINGS, 'guisettings.xml', zipfile.ZIP_DEFLATED) zipf.write(CONFIG.PROFILES, 'profiles.xml', zipfile.ZIP_DEFLATED) match = glob.glob(os.path.join(CONFIG.ADDON_DATA, 'skin.*', '')) for fold in match: fd = os.path.split(fold[:-1])[1] if fd not in ['skin.confluence', 'skin.estuary', 'skin.estouchy']: if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]Would you like to add the following skin folder to the GUI Fix Zip File?[/COLOR]".format(CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, fd), yeslabel="[B][COLOR springgreen]Add Skin[/COLOR][/B]", nolabel="[B][COLOR red]Skip Skin[/COLOR][/B]"): for base, dirs, files in os.walk(os.path.join(CONFIG.ADDON_DATA, fold)): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.USERDATA):], zipfile.ZIP_DEFLATED) xml = os.path.join(CONFIG.ADDONS, fd, 'addon.xml') if os.path.exists(xml): matchxml = tools.parse_dom(tools.read_from_file(xml), 'import', ret='addon') if 'script.skinshortcuts' in matchxml: for base, dirs, files in os.walk(os.path.join(CONFIG.ADDON_DATA, 'script.skinshortcuts')): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.USERDATA):], zipfile.ZIP_DEFLATED) else: logging.log("[Back Up] Type = guifix: {0} ignored".format(fold)) except Exception as e: logging.log("[Back Up] Type = guifix: {0}".format(e)) pass zipf.close() if not tempguizipname == '': success = xbmcvfs.rename(tempguizipname, guizipname) if success == 0: xbmcvfs.copy(tempguizipname, guizipname) xbmcvfs.delete(tempguizipname) else: logging.log("[Back Up] Type = guifix: guisettings.xml not found") if name == "": dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]GUI Fix backup successful:[/COLOR]".format(CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, guizipname))
def _backup_build(name=""): dialog = xbmcgui.Dialog() progress_dialog = xbmcgui.DialogProgress() if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]Are you sure you wish to backup the current build?[/COLOR]".format(CONFIG.COLOR2), nolabel="[B][COLOR red]Cancel Backup[/COLOR][/B]", yeslabel="[B][COLOR springgreen]Backup Build[/COLOR][/B]"): if name == "": name = tools.get_keyboard("", "Please enter a name for the build zip") if not name: return False name = name.replace('\\', '').replace('/', '').replace(':', '').replace('*', '').replace('?', '').replace( '"', '').replace('<', '').replace('>', '').replace('|', '') name = quote_plus(name) tempzipname = '' zipname = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(name)) for_progress = 0 ITEM = [] exclude_dirs = CONFIG.EXCLUDE_DIRS if not dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]Do you want to include your addon_data folder?".format(CONFIG.COLOR2), "This contains [COLOR {0}]ALL[/COLOR] add-on settings including passwords but may also contain important information such as skin shortcuts. We recommend [COLOR {0}]MANUALLY[/COLOR] removing the addon_data folders that aren\'t required.".format(CONFIG.COLOR1, CONFIG.COLOR1), "[COLOR {0}]{1}[/COLOR] addon_data is ignored[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDON_ID), yeslabel='[B][COLOR springgreen]Include data[/COLOR][/B]', nolabel='[B][COLOR red]Don\'t Include[/COLOR][/B]'): exclude_dirs.append('addon_data') tools.convert_special(CONFIG.HOME, True) # tools.ascii_check(CONFIG.HOME, True) extractsize = 0 try: zipf = zipfile.ZipFile(xbmc.translatePath(zipname), mode='w') except: try: tempzipname = os.path.join(CONFIG.PACKAGES, '{0}.zip'.format(name)) zipf = zipfile.ZipFile(tempzipname, mode='w') except: logging.log("Unable to create {0}.zip".format(name), level=xbmc.LOGERROR) if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]We are unable to write to the current backup directory, would you like to change the location?[/COLOR]".format(CONFIG.COLOR2), yeslabel="[B][COLOR springgreen]Change Directory[/COLOR][/B]", nolabel="[B][COLOR red]Cancel[/COLOR][/B]"): CONFIG.open_settings() return else: return progress_dialog.create("[COLOR {0}]{1}[/COLOR][COLOR {2}]: Creating Zip[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Creating backup zip".format(CONFIG.COLOR2), "", "Please Wait...[/COLOR]") for base, dirs, files in os.walk(CONFIG.HOME): dirs[:] = [d for d in dirs if d not in exclude_dirs] files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: ITEM.append(file) N_ITEM = len(ITEM) picture = [] music = [] video = [] programs = [] repos = [] scripts = [] skins = [] fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/')) idlist = [] binaries = [] binidlist = [] for folder in sorted(fold, key=lambda x: x): foldername = os.path.split(folder[:-1])[1] if foldername == 'packages': continue binaryid, binaryname = db.find_binary_addons(addon=foldername) if binaryid: binaries.append(binaryname) binidlist.append(binaryid) xml = os.path.join(folder, 'addon.xml') if os.path.exists(xml): a = tools.read_from_file(xml) prov = re.compile("<provides>(.+?)</provides>").findall(a) match = tools.parse_dom(prov, 'addon', ret='id') addid = foldername if len(match) == 0 else match[0] if addid in idlist: continue idlist.append(addid) try: add = xbmcaddon.Addon(id=addid) aname = add.getAddonInfo('name') aname = aname.replace('[', '<').replace(']', '>') aname = str(re.sub('<[^<]+?>', '', aname)).lstrip() except: aname = foldername if len(prov) == 0: if foldername.startswith('skin'): skins.append(aname) elif foldername.startswith('repo'): repos.append(aname) else: scripts.append(aname) continue if not (prov[0]).find('executable') == -1: programs.append(aname) if not (prov[0]).find('video') == -1: video.append(aname) if not (prov[0]).find('audio') == -1: music.append(aname) if not (prov[0]).find('image') == -1: picture.append(aname) db.fix_metas() binarytxt = _backup_binaries(binidlist) for base, dirs, files in os.walk(CONFIG.HOME): dirs[:] = [d for d in dirs if d not in exclude_dirs] files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: try: for_progress += 1 progress = tools.percentage(for_progress, N_ITEM) progress_dialog.update(int(progress), '[COLOR {0}]Creating backup zip: [COLOR {1}]{2}[/COLOR] / [COLOR {3}]{4}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, for_progress, CONFIG.COLOR1, N_ITEM), '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, file), '') fn = os.path.join(base, file) if file in CONFIG.LOGFILES: logging.log("[Back Up] Type = build: Ignore {0} - Log File".format(file)) continue elif os.path.join(base, file) in CONFIG.EXCLUDE_FILES: logging.log("[Back Up] Type = build: Ignore {0} - Excluded File".format(file)) continue elif os.path.join('addons', 'packages') in fn: logging.log("[Back Up] Type = build: Ignore {0} - Packages Folder".format(file)) continue elif file.endswith('.csv'): logging.log("[Back Up] Type = build: Ignore {0} - CSV File".format(file)) continue elif file.endswith('.pyo'): continue elif file.endswith('.db') and 'Database' in base: temp = file.replace('.db', '') temp = ''.join([i for i in temp if not i.isdigit()]) if temp in CONFIG.DB_FILES: if not file == db.latest_db(temp): logging.log("[Back Up] Type = build: Ignore {0} - DB File".format(file)) continue skipbinary = False if len(binidlist) > 0: for id in binidlist: id = os.path.join(CONFIG.ADDONS, id) if id in fn: skipbinary = True if skipbinary: logging.log("[Back Up] Type = build: Ignore {0} - Binary Add-on".format(file)) continue try: zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) extractsize += os.path.getsize(fn) except Exception as e: logging.log("[Back Up] Type = build: Unable to backup {0}".format(file)) logging.log("{0} / {1}".format(Exception, e)) if progress_dialog.iscanceled(): progress_dialog.close() logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE), "[COLOR {0}]Backup Cancelled[/COLOR]".format(CONFIG.COLOR2)) sys.exit() except Exception as e: logging.log("[Back Up] Type = build: Unable to backup {0}".format(file)) logging.log("Build Backup Error: {0}".format(str(e))) if 'addon_data' in exclude_dirs: match = glob.glob(os.path.join(CONFIG.ADDON_DATA, 'skin.*', '')) for fold in match: fd = os.path.split(fold[:-1])[1] if fd not in ['skin.confluence', 'skin.estuary', 'skin.estouchy']: for base, dirs, files in os.walk(os.path.join(CONFIG.ADDON_DATA, fold)): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) extractsize += os.path.getsize(fn) xml = os.path.join(CONFIG.ADDONS, fd, 'addon.xml') if os.path.exists(xml): matchxml = tools.parse_dom(tools.read_from_file(xml), 'import', ret='addon') if 'script.skinshortcuts' in matchxml: for base, dirs, files in os.walk(os.path.join(CONFIG.ADDON_DATA, 'script.skinshortcuts')): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) extractsize += os.path.getsize(fn) zipf.close() xbmc.sleep(500) progress_dialog.close() backup('guifix', name) if not tempzipname == '': success = xbmcvfs.rename(tempzipname, zipname) if success == 0: xbmcvfs.copy(tempzipname, zipname) xbmcvfs.delete(tempzipname) if binarytxt is not None: bintxtpath = os.path.join(CONFIG.USERDATA, binarytxt) xbmcvfs.delete(bintxtpath) _backup_info(name, extractsize, programs, video, music, picture, repos, scripts, binaries) if len(binaries) > 0: dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]The following add-ons were excluded from the backup because they are platform specific:[/COLOR]".format(CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, ', '.join(binaries))) dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]{1}[/COLOR] [COLOR {2}]Backup successful:[/COLOR]".format(CONFIG.COLOR1, name, CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, zipname))
def _backup_addon_pack(name=""): dialog = xbmcgui.Dialog() progress_dialog = xbmcgui.DialogProgress() if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]Are you sure you wish to create an Addon Pack?[/COLOR]".format(CONFIG.COLOR2), nolabel="[B][COLOR red]Cancel Backup[/COLOR][/B]", yeslabel="[B][COLOR springgreen]Create Pack[/COLOR][/B]"): if name == "": name = tools.get_keyboard("", "Please enter a name for the add-on pack zip") if not name: return False name = quote_plus(name) name = '{0}.zip'.format(name) tempzipname = '' zipname = os.path.join(CONFIG.MYBUILDS, name) try: zipf = zipfile.ZipFile(xbmc.translatePath(zipname), mode='w') except: try: tempzipname = os.path.join(CONFIG.PACKAGES, '{0}.zip'.format(name)) zipf = zipfile.ZipFile(tempzipname, mode='w') except: logging.log("Unable to create {0}.zip".format(name), level=xbmc.LOGERROR) if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]We are unable to write to the current backup directory, would you like to change the location?[/COLOR]".format( CONFIG.COLOR2), yeslabel="[B][COLOR springgreen]Change Directory[/COLOR][/B]", nolabel="[B][COLOR red]Cancel[/COLOR][/B]"): CONFIG.open_settings() return else: return fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/')) addonnames = [] addonfolds = [] for folder in sorted(fold, key=lambda x: x): foldername = os.path.split(folder[:-1])[1] if foldername in CONFIG.EXCLUDES: continue elif foldername in CONFIG.DEFAULTPLUGINS: continue elif foldername == 'packages': continue xml = os.path.join(folder, 'addon.xml') if os.path.exists(xml): match = tools.parse_dom(tools.read_from_file(xml), 'addon', ret='name') if len(match) > 0: addonnames.append(match[0]) addonfolds.append(foldername) else: addonnames.append(foldername) addonfolds.append(foldername) selected = dialog.multiselect( "{0}: Select the add-ons you wish to add to the zip.".format(CONFIG.ADDONTITLE), addonnames) if selected is None: selected = [] logging.log(selected) progress_dialog.create(CONFIG.ADDONTITLE, '[COLOR {0}][B]Creating Zip File:[/B][/COLOR]'.format(CONFIG.COLOR2), '', 'Please Wait') if len(selected) > 0: added = [] for item in selected: added.append(addonfolds[item]) progress_dialog.update(0, "", "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, addonfolds[item])) for base, dirs, files in os.walk(os.path.join(CONFIG.ADDONS, addonfolds[item])): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: if file.endswith('.pyo'): continue progress_dialog.update(0, "", "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, addonfolds[item]), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, file)) fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.ADDONS):], zipfile.ZIP_DEFLATED) dep = os.path.join(CONFIG.ADDONS, addonfolds[item], 'addon.xml') if os.path.exists(dep): match = tools.parse_dom(tools.read_from_file(dep), 'import', ret='addon') for depends in match: if 'xbmc.python' in depends: continue if depends in added: continue progress_dialog.update(0, "", "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, depends)) for base, dirs, files in os.walk(os.path.join(CONFIG.ADDONS, depends)): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: if file.endswith('.pyo'): continue progress_dialog.update(0, "", "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, depends), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, file)) fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.ADDONS):], zipfile.ZIP_DEFLATED) added.append(depends) dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]{1}[/COLOR] [COLOR {2}]Backup successful:[/COLOR]".format(CONFIG.COLOR1, name, CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, zipname))
def check_skin(): from resources.libs.common import logging from resources.libs.common import tools dialog = xbmcgui.Dialog() logging.log( "[Verificación Build] Inicio de Comprobación del Skin Inválido") gotoskin = False if not CONFIG.DEFAULTSKIN == '': if os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.DEFAULTSKIN)): if dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]Parece que el skin se ha vuelto a poner [COLOR {1}]{2}[/COLOR]" .format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.SKIN[5:].title()) + '\n' + "Le gustaría volver a poner el skin en:[/COLOR]" + '\n' + '[COLOR {0}]{1}[/COLOR]'.format( CONFIG.COLOR1, CONFIG.DEFAULTNAME)): gotoskin = CONFIG.DEFAULTSKIN gotoname = CONFIG.DEFAULTNAME else: logging.log("El Skin no se reseteó") CONFIG.set_setting('defaultskinignore', 'true') gotoskin = False else: CONFIG.set_setting('defaultskin', '') CONFIG.set_setting('defaultskinname', '') CONFIG.DEFAULTSKIN = '' CONFIG.DEFAULTNAME = '' if CONFIG.DEFAULTSKIN == '': skinname = [] skinlist = [] for folder in glob.glob(os.path.join(CONFIG.ADDONS, 'skin.*/')): xml = "{0}/addon.xml".format(folder) if os.path.exists(xml): g = tools.read_from_file(xml).replace('\n', '').replace( '\r', '').replace('\t', '') match = tools.parse_dom(g, 'addon', ret='id') match2 = tools.parse_dom(g, 'addon', ret='name') logging.log("{0}: {1}".format(folder, str(match[0]))) if len(match) > 0: skinlist.append(str(match[0])) skinname.append(str(match2[0])) else: logging.log("ID no encontrado para {0}".format(folder)) else: logging.log("ID no encontrado para {0}".format(folder)) if len(skinlist) > 0: if len(skinlist) > 1: if dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]Parece que el skin se ha vuelto a poner [COLOR {1}]{2}[/COLOR]" .format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.SKIN[5:].title()) + '\n' + "Le gustaría ver una lista de skins disponibles?[/COLOR]" ): choice = dialog.select( "Seleccione el skin para cambiarlo!", skinname) if choice == -1: logging.log("El Skin no se reseteó") CONFIG.set_setting('defaultskinignore', 'true') else: gotoskin = skinlist[choice] gotoname = skinname[choice] else: logging.log("El Skin no se reseteó") CONFIG.set_setting('defaultskinignore', 'true') else: if dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]Parece que el skin se ha vuelto a poner [COLOR {1}]{2}[/COLOR]" .format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.SKIN[5:].title()) + '\n' + "Le gustaría volver a poner el skin en:[/COLOR]" + '\n' + '[COLOR {0}]{1}[/COLOR]'.format( CONFIG.COLOR1, skinname[0])): gotoskin = skinlist[0] gotoname = skinname[0] else: logging.log("El Skin no se reseteó") CONFIG.set_setting('defaultskinignore', 'true') else: logging.log("No se encontraron skins en la carpeta de addons.") CONFIG.set_setting('defaultskinignore', 'true') gotoskin = False if gotoskin: from resources.libs import skin if skin.switch_to_skin(gotoskin): skin.look_and_feel_data('restore') logging.log("[Verificación Build] Fin de Comprobación del Skin Invalido")
def _backup_theme(name=""): dialog = xbmcgui.Dialog() if not dialog.yesno('[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to create a theme backup?[/COLOR]".format(CONFIG.COLOR2), yeslabel="[B][COLOR springgreen]Continue[/COLOR][/B]", nolabel="[B][COLOR red]No Cancel[/COLOR][/B]"): logging.log_notify("Theme Backup", "Cancelled!") return False if name == "": themename = tools.get_keyboard("", "Please enter a name for the theme zip") if not themename: return False else: themename = name themename = quote_plus(themename) tempzipname = '' zipname = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(themename)) try: zipf = zipfile.ZipFile(zipname, mode='w') except: try: tempzipname = os.path.join(CONFIG.PACKAGES, '{0}.zip'.format(themename)) zipf = zipfile.ZipFile(tempzipname, mode='w') except: logging.log("Unable to create {0}.zip".format(themename), level=xbmc.LOGERROR) if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]We are unable to write to the current backup directory, would you like to change the location?[/COLOR]".format(CONFIG.COLOR2), yeslabel="[B][COLOR springgreen]Change Directory[/COLOR][/B]", nolabel="[B][COLOR red]Cancel[/COLOR][/B]"): CONFIG.open_settings() return else: return tools.convert_special(CONFIG.USERDATA, True) tools.ascii_check(CONFIG.USERDATA, True) try: if not CONFIG.SKIN not in ['skin.confluence', 'skin.estuary', 'skin.estouchy']: skinfold = os.path.join(CONFIG.SKIN, 'media') match2 = glob.glob(os.path.join(skinfold, '*.xbt')) if len(match2) > 1: if dialog.yesno('[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to go through the Texture Files for?[/COLOR]".format(CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.SKIN), yeslabel="[B][COLOR springgreen]Add Textures[/COLOR][/B]", nolabel="[B][COLOR red]Skip Textures[/COLOR][/B]"): for xbt in match2: if dialog.yesno( '[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to add the Texture File [COLOR {1}]{2}[/COLOR]?".format( CONFIG.COLOR1, CONFIG.COLOR2, xbt.replace(skinfold, "")[1:]), "from [COLOR {0}]{1}[/COLOR][/COLOR]".format(CONFIG.COLOR1, CONFIG.SKIN), yeslabel="[B][COLOR springgreen]Add Textures[/COLOR][/B]", nolabel="[B][COLOR red]Skip Textures[/COLOR][/B]"): fn = xbt fn2 = fn.replace(CONFIG.HOME, "") zipf.write(fn, fn2, zipfile.ZIP_DEFLATED) else: for xbt in match2: if dialog.yesno( '[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to add the Texture File [COLOR {1}]{2}[/COLOR]?".format( CONFIG.COLOR2, CONFIG.COLOR1, xbt.replace(skinfold, "")[1:]), "from [COLOR {0}]{1}[/COLOR][/COLOR]".format(CONFIG.COLOR1, CONFIG.SKIN), yeslabel="[B][COLOR springgreen]Add Textures[/COLOR][/B]", nolabel="[B][COLOR red]Skip Textures[/COLOR][/B]"): fn = xbt fn2 = fn.replace(CONFIG.HOME, "") zipf.write(fn, fn2, zipfile.ZIP_DEFLATED) ad_skin = os.path.join(CONFIG.ADDON_DATA, CONFIG.SKIN, 'settings.xml') if os.path.exists(ad_skin): if dialog.yesno('[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to go add the [COLOR {1}]settings.xml[/COLOR] in [COLOR {2}]/addon_data/[/COLOR] for?".format( CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.COLOR1), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.SKIN), yeslabel="[B][COLOR springgreen]Add Settings[/COLOR][/B]", nolabel="[B][COLOR red]Skip Settings[/COLOR][/B]"): ad_skin2 = ad_skin.replace(CONFIG.HOME, "") zipf.write(ad_skin, ad_skin2, zipfile.ZIP_DEFLATED) match = tools.parse_dom(tools.read_from_file(os.path.join(CONFIG.SKIN, 'addon.xml')), 'import', ret='addon') if 'script.skinshortcuts' in match: if dialog.yesno('[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to go add the [COLOR {1}]settings.xml[/COLOR] for [COLOR {2}]script.skinshortcuts[/COLOR]?".format( CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.COLOR1), yeslabel="[B][COLOR springgreen]Add Settings[/COLOR][/B]", nolabel="[B][COLOR red]Skip Settings[/COLOR][/B]"): for base, dirs, files in os.walk(os.path.join(CONFIG.ADDON_DATA, 'script.skinshortcuts')): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) if dialog.yesno('[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to include a [COLOR {1}]Backgrounds[/COLOR] folder?[/COLOR]".format( CONFIG.COLOR2, CONFIG.COLOR1), yeslabel="[B][COLOR springgreen]Yes Include[/COLOR][/B]", nolabel="[B][COLOR red]No Continue[/COLOR][/B]"): fn = dialog.browse(0, 'Select location of backgrounds', 'files', '', True, False, CONFIG.HOME, False) if not fn == CONFIG.HOME: for base, dirs, files in os.walk(fn): dirs[:] = [d for d in dirs if d not in CONFIG.EXCLUDE_DIRS] files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: try: fn2 = os.path.join(base, file) zipf.write(fn2, fn2[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) except Exception as e: logging.log("[Back Up] Type = theme: Unable to backup {0}".format(file)) logging.log("Backup Error: {0}".format(str(e))) text = db.latest_db('Textures') if dialog.yesno('[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to include the [COLOR {1}]{2}[/COLOR]?[/COLOR]".format( CONFIG.COLOR2, CONFIG.COLOR1, text), yeslabel="[B][COLOR springgreen]Yes Include[/COLOR][/B]", nolabel="[B][COLOR red]No Continue[/COLOR][/B]"): zipf.write(os.path.join(CONFIG.DATABASE, text), '/userdata/Database/{0}'.format(text), zipfile.ZIP_DEFLATED) if dialog.yesno('[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to include any addons?[/COLOR]".format(CONFIG.COLOR2), yeslabel="[B][COLOR springgreen]Yes Include[/COLOR][/B]", nolabel="[B][COLOR red]No Continue[/COLOR][/B]"): fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/')) addonnames = [] addonfolds = [] for folder in sorted(fold, key=lambda x: x): foldername = os.path.split(folder[:-1])[1] if foldername in CONFIG.EXCLUDES: continue elif foldername in CONFIG.DEFAULTPLUGINS: continue elif foldername == 'packages': continue xml = os.path.join(folder, 'addon.xml') if os.path.exists(xml): match = tools.parse_dom(tools.read_from_file(xml), 'addon', ret='name') if len(match) > 0: addonnames.append(match[0]) addonfolds.append(foldername) else: addonnames.append(foldername) addonfolds.append(foldername) selected = dialog.multiselect("{0}: Select the add-ons you wish to add to the zip.".format(CONFIG.ADDONTITLE), addonnames) if selected is None: selected = [] if len(selected) > 0: added = [] for item in selected: added.append(addonfolds[item]) for base, dirs, files in os.walk(os.path.join(CONFIG.ADDONS, addonfolds[item])): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: if file.endswith('.pyo'): continue fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) dep = os.path.join(CONFIG.ADDONS, addonfolds[item], 'addon.xml') if os.path.exists(dep): match = tools.parse_dom(tools.read_from_file(dep), 'import', ret='addon') for depends in match: if 'xbmc.python' in depends: continue if depends in added: continue for base, dirs, files in os.walk(os.path.join(CONFIG.ADDONS, depends)): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: if file.endswith('.pyo'): continue fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) added.append(depends) if dialog.yesno('[COLOR {0}]{1}[/COLOR][COLOR {2}]: Theme Backup[/COLOR]'.format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Would you like to include the [COLOR {1}]guisettings.xml[/COLOR]?[/COLOR]".format( CONFIG.COLOR2, CONFIG.COLOR1), yeslabel="[B][COLOR springgreen]Yes Include[/COLOR][/B]", nolabel="[B][COLOR red]No Continue[/COLOR][/B]"): zipf.write(CONFIG.GUISETTINGS, '/userdata/guisettings.xml', zipfile.ZIP_DEFLATED) except Exception as e: zipf.close() logging.log("[Back Up] Type = theme: {0}".format(str(e))) dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]{1}[/COLOR][COLOR {2}] theme zip failed:[/COLOR]".format(CONFIG.COLOR1, themename, CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, str(e))) if not tempzipname == '': try: os.remove(tempzipname) except Exception as e: logging.log(str(e)) else: try: os.remove(zipname) except Exception as e: logging.log(str(e)) return zipf.close() if not tempzipname == '': success = xbmcvfs.rename(tempzipname, zipname) if success == 0: xbmcvfs.copy(tempzipname, zipname) xbmcvfs.delete(tempzipname) dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]{1}[/COLOR][COLOR {2}] theme zip successful:[/COLOR]".format(CONFIG.COLOR1, themename, CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, zipname))
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")