コード例 #1
0
    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) + '\n' + '[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) + '\n' + "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 + '\n' + '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))
コード例 #2
0
    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

        response = tools.open_url(url, check=True)

        if not response:
            logging.log_notify(
                "[COLOR {0}]Instalador de Add-ons[/COLOR]".format(
                    CONFIG.COLOR1),
                '[COLOR {0}]{1}:[/COLOR] [COLOR {2}]URL inválido zip![/COLOR]'.
                format(CONFIG.COLOR1, plugin, CONFIG.COLOR2))
            return

        tools.ensure_folders(CONFIG.PACKAGES)

        self.progress_dialog.create(
            CONFIG.ADDONTITLE,
            '[COLOR {0}][B]Descargando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.
            format(CONFIG.COLOR2, CONFIG.COLOR1, plugin) + '\n' + '' + '\n' +
            '[COLOR {0}]Espere por Favor[/COLOR]'.format(CONFIG.COLOR2))
        urlsplits = url.split('/')
        lib = os.path.join(CONFIG.PACKAGES, urlsplits[-1])

        try:
            os.remove(lib)
        except:
            pass

        Downloader().download(url, lib)
        title = '[COLOR {0}][B]Instalando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(
            CONFIG.COLOR2, CONFIG.COLOR1, plugin)
        self.progress_dialog.update(
            0, title + '\n' + '' + '\n' +
            '[COLOR {0}]Espere por Favor[/COLOR]'.format(CONFIG.COLOR2))
        percent, errors, error = extract.all(lib, CONFIG.ADDONS, title=title)
        self.progress_dialog.update(
            0, title + '\n' + '' + '\n' +
            '[COLOR {0}]Instalando Dependencias[/COLOR]'.format(CONFIG.COLOR2))
        installed(plugin)
        installlist = db.grab_addons(lib)
        logging.log(str(installlist))
        db.addon_database(installlist, 1, True)
        self.install_dependency(plugin)
        self.progress_dialog.close()

        xbmc.executebuiltin('UpdateAddonRepos()')
        xbmc.executebuiltin('UpdateLocalAddons()')
        xbmc.executebuiltin('Container.Refresh()')

        for item in installlist:
            if item.startswith('skin.') and not item == 'skin.shortcuts':
                if not CONFIG.BUILDNAME == '' and CONFIG.DEFAULTIGNORE == 'true':
                    CONFIG.set_setting('defaultskinignore', 'true')
                skin.switch_to_skin(item, 'Skin Installer')
コード例 #3
0
def install_addon_from_url(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

    progress_dialog = xbmcgui.DialogProgress()

    response = tools.open_url(url, check=True)

    if not response:
        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 not os.path.exists(CONFIG.PACKAGES):
        os.makedirs(CONFIG.PACKAGES)

    progress_dialog.create(
        CONFIG.ADDONTITLE,
        '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(
            CONFIG.COLOR2, CONFIG.COLOR1,
            name), '', '[COLOR {0}]Please Wait[/COLOR]'.format(CONFIG.COLOR2))
    urlsplits = url.split('/')
    lib = os.path.join(CONFIG.PACKAGES, urlsplits[-1])
    try:
        os.remove(lib)
    except:
        pass
    Downloader().download(url, lib)
    title = '[COLOR {0}][B]Installing:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(
        CONFIG.COLOR2, CONFIG.COLOR1, name)
    progress_dialog.update(
        0, title, '', '[COLOR {0}]Please Wait[/COLOR]'.format(CONFIG.COLOR2))
    percent, errors, error = extract.all(lib, CONFIG.ADDONS, title=title)
    progress_dialog.update(
        0, title, '',
        '[COLOR {0}]Installing Dependencies[/COLOR]'.format(CONFIG.COLOR2))
    installed(name)
    installlist = db.grab_addons(lib)
    logging.log(str(installlist))
    db.addon_database(installlist, 1, True)
    install_dependency(name, progress_dialog)
    progress_dialog.close()

    xbmc.executebuiltin('UpdateAddonRepos()')
    xbmc.executebuiltin('UpdateLocalAddons()')
    xbmc.executebuiltin('Container.Refresh()')

    for item in installlist:
        if item.startswith('skin.') and not item == 'skin.shortcuts':
            if not CONFIG.BUILDNAME == '' and CONFIG.DEFAULTIGNORE == 'true':
                CONFIG.set_setting('defaultskinignore', 'true')
            skin.switch_to_skin(item, 'Skin Installer')
コード例 #4
0
    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

        progress_dialog = xbmcgui.DialogProgress()

        response = tools.open_url(url, check=False)

        if not response:
            logging.log_notify(
                "[COLOR {0}]Instalador de Add-ons[/COLOR]".format(
                    CONFIG.COLOR1),
                '[COLOR {0}]{1}:[/COLOR] [COLOR {2}]Url del Zip Inválida![/COLOR]'
                .format(CONFIG.COLOR1, name, CONFIG.COLOR2))
            return

        if not os.path.exists(CONFIG.PACKAGES):
            os.makedirs(CONFIG.PACKAGES)

        progress_dialog.create(
            CONFIG.ADDONTITLE,
            '[COLOR {0}][B]Descargando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.
            format(CONFIG.COLOR2, CONFIG.COLOR1, name) + '\n' + '' + '\n' +
            '[COLOR {0}]Espere por Favor[/COLOR]'.format(CONFIG.COLOR2))

        urlsplits = url.split('/')
        lib = xbmc.makeLegalFilename(
            os.path.join(CONFIG.PACKAGES, urlsplits[-1]))
        try:
            os.remove(lib)
        except:
            pass
        Downloader().download(url, lib)
        title = '[COLOR {0}][B]Instalando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(
            CONFIG.COLOR2, CONFIG.COLOR1, name)
        progress_dialog.update(
            0, title + '\n' + '' + '\n' +
            '[COLOR {0}]Espere por Favor[/COLOR]'.format(CONFIG.COLOR2))
        percent, errors, error = extract.all(lib, CONFIG.HOME, title=title)
        installed = db.grab_addons(lib)
        db.addon_database(installed, 1, True)
        progress_dialog.close()
        logging.log_notify(
            "[COLOR {0}]Instalador de Add-ons[/COLOR]".format(CONFIG.COLOR1),
            '[COLOR {0}]{1}: Instalado![/COLOR]'.format(CONFIG.COLOR2, name))
        xbmc.executebuiltin('UpdateAddonRepos()')
        xbmc.executebuiltin('UpdateLocalAddons()')
        for item in installed:
            if item.startswith('skin.') and not item == 'skin.shortcuts':
                if not CONFIG.BUILDNAME == '' and CONFIG.DEFAULTIGNORE == 'true':
                    CONFIG.set_setting('defaultskinignore', 'true')
                skin.switch_to_skin(item, 'Skin Installer')
        xbmc.executebuiltin('Container.Refresh()')
コード例 #5
0
 def install_addon_pack(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.common import tools
     if 64 - 64: o00ooo0 / OoOoOO00 - O0 - I11i
     O0oOoOOOoOO = xbmcgui.DialogProgress()
     if 38 - 38: I1i1iI1i
     oo0Ooo0 = tools.open_url(url, check=True)
     if 7 - 7: O0.o0OO0 % I1ii11iIi11i - I1IiiI - iIii1I11I1II1
     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 36 - 36: Oo0ooO0oo0oO % o00ooo0 % Oo0Ooo - I1ii11iIi11i
     if not os.path.exists(CONFIG.PACKAGES):
         os.makedirs(CONFIG.PACKAGES)
         if 22 - 22: iIii1I11I1II1 / Oo0Ooo * I1ii11iIi11i % o0OO0
     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))
     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.ADDONS,
                                                      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}: Instalado![/COLOR]'.format(CONFIG.COLOR2, name))
     xbmc.executebuiltin('UpdateAddonRepos()')
     xbmc.executebuiltin('UpdateLocalAddons()')
     xbmc.executebuiltin('Container.Refresh()')
     if 85 - 85: oO0o % i11iIiiIii - o0OO0 * OoooooooOO / I1IiiI % I1IiiI
     if 1 - 1: OoO0O00 - oO0o.I11i.OoO0O00 / Oo0Ooo + I11i
コード例 #6
0
    def install_addon_pack(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.common import tools

        progress_dialog = xbmcgui.DialogProgress()

        response = tools.open_url(url, check=True)

        if not response:
            logging.log_notify(
                "[COLOR {0}]Instalador de Add-ons[/COLOR]".format(
                    CONFIG.COLOR1),
                '[COLOR {0}]{1}:[/COLOR] [COLOR {2}]Url del Zip Inválida![/COLOR]'
                .format(CONFIG.COLOR1, name, CONFIG.COLOR2))
            return

        if not os.path.exists(CONFIG.PACKAGES):
            os.makedirs(CONFIG.PACKAGES)

        progress_dialog.create(
            CONFIG.ADDONTITLE,
            '[COLOR {0}][B]Descargando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.
            format(CONFIG.COLOR2, CONFIG.COLOR1, name) + '\n' + '' + '\n' +
            '[COLOR {0}]Espere por Favor[/COLOR]'.format(CONFIG.COLOR2))
        urlsplits = url.split('/')
        lib = xbmc.makeLegalFilename(
            os.path.join(CONFIG.PACKAGES, urlsplits[-1]))
        try:
            os.remove(lib)
        except:
            pass
        Downloader().download(url, lib)
        title = '[COLOR {0}][B]Instalando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(
            CONFIG.COLOR2, CONFIG.COLOR1, name)
        progress_dialog.update(
            0, title + '\n' + '' + '\n' +
            '[COLOR {0}]Espere por Favor[/COLOR]'.format(CONFIG.COLOR2))
        percent, errors, error = extract.all(lib, CONFIG.ADDONS, title=title)
        installed = db.grab_addons(lib)
        db.addon_database(installed, 1, True)
        progress_dialog.close()
        logging.log_notify(
            "[COLOR {0}]Instalador de Add-ons[/COLOR]".format(CONFIG.COLOR1),
            '[COLOR {0}]{1}: Instalado![/COLOR]'.format(CONFIG.COLOR2, name))
        xbmc.executebuiltin('UpdateAddonRepos()')
        xbmc.executebuiltin('UpdateLocalAddons()')
        xbmc.executebuiltin('Container.Refresh()')
コード例 #7
0
    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)
コード例 #8
0
 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
コード例 #9
0
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.")
コード例 #10
0
    def install_addon(self, plugin, urls, over=False):
        from resources.libs import db

        install = None

        if not over:        
            if xbmc.getCondVisibility('System.HasAddon({0})'.format(plugin)):
                install = self.dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]{1}[/COLOR] already installed. Would you like to reinstall it?'.format(CONFIG.COLOR1, plugin))
            else:
                install = self.dialog.yesno(CONFIG.ADDONTITLE, 'Would you like to install [COLOR {0}]{1}[/COLOR]?'.format(CONFIG.COLOR1, plugin))
        else:
            install = True
            
        if not install:
            return
            
        url_response = tools.open_url(urls[0], check=True)
        repositoryurl_response = tools.open_url(urls[2], check=True)
        repositoryxml_response = tools.open_url(urls[3])
        
        if False not in [repositoryxml_response, repositoryurl_response]:
        
            repo_id = urls[1]
        
            if not xbmc.getCondVisibility('System.HasAddon({0})'.format(repo_id)):
                logging.log("Repository not installed, installing it")

                from xml.etree import ElementTree
                root = ElementTree.fromstring(repositoryxml_response.text.encode('ascii', 'backslashreplace'))
                entries = root.findall('addon')
                version = None

                for entry in entries:
                    if entry.attrib['id'] == repo_id:
                        version = entry.attrib['version']

                if version:
                    repozip = '{0}{1}-{2}.zip'.format(urls[2], repo_id, version)
                    logging.log(repozip)
                    db.addon_database(repo_id, 1)
                    self.install_addon(repo_id, repozip, over=True)
                    xbmc.executebuiltin('UpdateAddonRepos()')
                    install = install_from_kodi(plugin)
                    if install:
                        xbmc.executebuiltin('Container.Refresh()')
                        return True
                else:
                    logging.log(
                        "[Addon Installer] Repository not installed: Unable to grab url! ({0})".format(urls[1]))
            else:
                logging.log("Repository installed, installing addon")
                install = install_from_kodi(plugin)
                if install:
                    xbmc.executebuiltin('Container.Refresh()')
                    return True
        elif url_response:
            logging.log("No repository, installing addon")
            self.install_addon_from_url(plugin, urls[0])

            if os.path.exists(os.path.join(CONFIG.ADDONS, plugin)):
                return True

            from xml.etree import ElementTree
            root = ElementTree.parse(repositoryxml_response.text)
            entries = root.findall('addon')
            version = None

            for entry in entries:
                if entry.attrib['id'] == repo_id:
                    version = entry.attrib['version']

            if version > 0:
                url = "{0}{1}-{2}.zip".format(urls[0], plugin, version)
                logging.log(str(url))
                db.addon_database(plugin, 1)
                self.install_addon_from_url(plugin, url)
                xbmc.executebuiltin('Container.Refresh()')
            else:
                logging.log("no match")
                return False
コード例 #11
0
ファイル: wizard.py プロジェクト: gtkingbuild/Repo-Prueba
    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]ADVERTENCIA!![/COLOR]".format(
                    CONFIG.ADDONTITLE),
                '[COLOR {0}]Existe la posibilidad de que el Skin no se vea correctamente'
                .format(CONFIG.COLOR2) + '\n' +
                'Al instalar una {0} build en un Kodi {1} instalado'.format(
                    check.check_build(name, 'kodi'), CONFIG.KODIV) + '\n' +
                'Todavia te gustaria instalar: [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}][B]La Instalación Sobreescribirá los datos de su Kodi Actual ![/B] '
                    .format(CONFIG.COLOR2) + '\n' +
                    '[COLOR {0}]Le gustaria Descargar e Instalar: '.format(
                        CONFIG.COLOR2) +
                    '[COLOR {0}]{1} v{2} [/COLOR]?[/COLOR]'.format(
                        CONFIG.COLOR1, name, check.check_build(
                            name, 'version')),
                    nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]',
                    yeslabel='[B][COLOR springgreen]Si, Instalar[/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]Descargando:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1, name,
                        check.check_build(name, 'version')) + '\n' +
                'Espere por Favor')

            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]Instalando:[/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' + 'Espere por Favor')
            percent, errors, error = extract.all(lib, CONFIG.HOME, title=title)

            skin.skin_to_default('Instalar Build')

            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('INSTALADO {0}: [ERRORES:{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' +
                        'Completado: [COLOR {0}]{1}{2}[/COLOR] [Errores:[COLOR {3}]{4}[/COLOR]]'
                        .format(CONFIG.COLOR1, percent, '%', CONFIG.COLOR1,
                                errors) + '\n' +
                        'Le gustaria ver los errores?[/COLOR]',
                        nolabel='[B][COLOR red]No, Gracias[/COLOR][/B]',
                        yeslabel='[B][COLOR springgreen]Ver Errores[/COLOR][/B]'
                    )
                    if yes_pressed:
                        from resources.libs.gui import window
                        window.show_text_box(
                            "Visualizacion de Errores de Instalacion de la Build",
                            error)
                self.dialogProgress.close()

                from resources.libs.gui.build_menu import BuildMenu
                themecount = BuildMenu().theme_count(name)

                if themecount > 0:
                    self.theme(name)

                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}]Para guardar los cambios, ahora necesita Forzar el Cierre de Kodi. \nPresione [B]OK[/B] para Forzar el Cierre de Kodi.[/COLOR]"
                    .format(CONFIG.COLOR2))
                tools.kill_kodi(over=True)
            else:
                from resources.libs.gui import window
                window.show_text_box(
                    "Visualizacion de Errores de Instalacion de la Build",
                    error)
        else:
            logging.log_notify(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Instalacion Build:[/COLOR] [COLOR gold]Cancelado![/COLOR]'
                .format(CONFIG.COLOR2))
コード例 #12
0
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")
コード例 #13
0
ファイル: wizard.py プロジェクト: gtkingbuild/Repo-Prueba
    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}][B]La Build [COLOR {1}]{2}[/COLOR] viene con [COLOR {3}]{4}[/COLOR] Parches diferentes[/B]"
                            .format(CONFIG.COLOR2, CONFIG.COLOR1, name,
                                    CONFIG.COLOR1, len(themes)) + '\n\n' +
                            "Le gustaria instalar uno ahora?[/COLOR]",
                            yeslabel=
                            "[B][COLOR cyan]Instalar Parche[/COLOR][/B]",
                            nolabel="[B][COLOR red]Cancelar Parche[/COLOR][/B]"
                    ):
                        logging.log("Lista de Parches: {0}".format(
                            str(themes)))
                        ret = self.dialog.select(CONFIG.ADDONTITLE, themes)
                        logging.log(
                            "[B]Selecciona un Parche para Instalar:[/B] {0}".
                            format(ret))
                        if not ret == -1:
                            theme = themes[ret]
                            installtheme = True
                        else:
                            logging.log_notify(
                                CONFIG.ADDONTITLE,
                                '[COLOR {0}]Instalación:[/COLOR] [COLOR gold]Cancelado![/COLOR]'
                                .format(CONFIG.COLOR2))
                            return
                    else:
                        logging.log_notify(
                            CONFIG.ADDONTITLE,
                            '[COLOR {0}]Instalación Parche:[/COLOR] [COLOR gold]Cancelado![/COLOR]'
                            .format(CONFIG.COLOR2))
                        return
            else:
                logging.log_notify(
                    CONFIG.ADDONTITLE,
                    '[COLOR {0}]Instalación Parche:[/COLOR] [COLOR gold]Nada Encontrado![/COLOR]'
                    .format(CONFIG.COLOR2))
        else:
            installtheme = self.dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {0}][B]Te gustaría instalar uno de los Parches que hay en:[/B]'
                .format(CONFIG.COLOR2) + ' \n' +
                '[COLOR dodgerblue][B]PARCHES MATRIX[/B][/COLOR]'.format(
                    CONFIG.COLOR1, theme) + '\n' +
                '[B]para [COLOR {0}]{1} v{2}[/COLOR]?[/B][/COLOR]'.format(
                    CONFIG.COLOR1, name, check.check_build(name, 'version')),
                yeslabel="[B][COLOR cyan]Instalar Parche[/COLOR][/B]",
                nolabel="[B][COLOR red]Cancelar Parche[/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}]Instalación Parche:[/COLOR] [COLOR gold]Url Zip Inválido![/COLOR]'
                    .format(CONFIG.COLOR2))
                return False

            self.dialogProgress.create(
                CONFIG.ADDONTITLE,
                '[COLOR {0}][B]Descargando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1, zipname) + ' \n' +
                'Espere por Favor')

            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, '\n' + "Instalando {0}".format(name))
            from resources.libs import skin
            from resources.libs import test
            title = '[COLOR {0}][B]Instalando Parche:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(
                CONFIG.COLOR2, CONFIG.COLOR1, theme)
            self.dialogProgress.update(0, title + '\n' + 'Espere por Favor')
            percent, errors, error = extract.all(lib, CONFIG.HOME, title=title)
            CONFIG.set_setting('buildtheme', theme)
            logging.log('INSTALADO {0}: [ERRORES:{1}]'.format(percent, errors))
            self.dialogProgress.close()
            installed = db.grab_addons(lib)
            db.addon_database(installed, 1, True)
            xbmc.executebuiltin("ReloadSkin()")
            xbmc.sleep(1000)
            xbmc.executebuiltin("Container.Refresh()")
        else:
            logging.log_notify(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Instalación Parche:[/COLOR] [COLOR gold]Cancelado![/COLOR]'
                .format(CONFIG.COLOR2))
コード例 #14
0
    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)) + '\n' +
                            "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) + ' \n' +
                '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, theme) + '\n' +
                '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, zipname) + ' \n' +
                '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, '\n' + "Installing {0}".format(name))

            title = '[COLOR {0}][B]Installing Theme:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(
                CONFIG.COLOR2, CONFIG.COLOR1, theme)
            self.dialogProgress.update(0, title + '\n' + '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)
            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))
コード例 #15
0
 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
コード例 #16
0
 def install_addon(self, plugin, urls, over=False):
     from resources.libs import db
     if 75 - 75: oO0o
     I1III = None
     if 63 - 63: OOooOOo % oO0o * oO0o * OoO0O00 / I1ii11iIi11i
     if not over:
         if xbmc.getCondVisibility('System.HasAddon({0})'.format(plugin)):
             I1III = self.dialog.yesno(
                 CONFIG.ADDONTITLE,
                 '[COLOR {0}]{1}[/COLOR] já instalado. Você gostaria de reinstalá-lo?'
                 .format(CONFIG.COLOR1, plugin))
         else:
             I1III = self.dialog.yesno(
                 CONFIG.ADDONTITLE,
                 'Você gostaria de instalar [COLOR {0}]{1}[/COLOR]?'.format(
                     CONFIG.COLOR1, plugin))
     else:
         I1III = True
         if 74 - 74: II111iiii
     if not I1III:
         return
         if 75 - 75: o0oOOo0O0Ooo.o00ooo0
     I1I11I1I1I = tools.open_url(urls[0], check=True)
     Oo0O00Oo0o0 = tools.open_url(urls[2], check=True)
     O00O0oOO00O00 = tools.open_url(urls[3])
     if 11 - 11: Oo0ooO0oo0oO.I1ii11iIi11i
     if False not in [O00O0oOO00O00, Oo0O00Oo0o0]:
         if 92 - 92: o0OO0.I1i1iI1i
         i1i = urls[1]
         if 50 - 50: Oo0ooO0oo0oO
         if not xbmc.getCondVisibility('System.HasAddon({0})'.format(i1i)):
             logging.log("Repositório não instalado, instalando-o")
             if 14 - 14: I11i % OoO0O00 * I11i
             from xml.etree import ElementTree
             iII = ElementTree.fromstring(
                 O00O0oOO00O00.text.encode('ascii', 'backslashreplace'))
             oO00o0 = iII.findall('addon')
             OOoo0O = None
             if 67 - 67: i11iIiiIii - i1IIi % I1ii11iIi11i.O0
             for o0oo in oO00o0:
                 if o0oo.attrib['id'] == i1i:
                     OOoo0O = o0oo.attrib['version']
                     if 91 - 91: Oo0ooO0oo0oO
             if OOoo0O:
                 iiIii = '{0}{1}-{2}.zip'.format(urls[2], i1i, OOoo0O)
                 logging.log(iiIii)
                 db.addon_database(i1i, 1)
                 self.install_addon(i1i, iiIii, over=True)
                 xbmc.executebuiltin('UpdateAddonRepos()')
                 I1III = II1iI(plugin)
                 if I1III:
                     xbmc.executebuiltin('Container.Refresh()')
                     return True
             else:
                 logging.log(
                     "[Addon Installer] Repositório não instalado: Incapaz de obter url! ({0})"
                     .format(urls[1]))
         else:
             logging.log("Repositório instalado, instalando addon")
             I1III = II1iI(plugin)
             if I1III:
                 xbmc.executebuiltin('Container.Refresh()')
                 return True
     elif I1I11I1I1I:
         logging.log("Sem repositório, instalando addon")
         self.install_addon_from_url(plugin, urls[0])
         if 79 - 79: OoooooooOO / O0
         if os.path.exists(os.path.join(CONFIG.ADDONS, plugin)):
             return True
             if 75 - 75: OoOoOO00 % o0oOOo0O0Ooo % o0oOOo0O0Ooo.I1i1iI1i
         from xml.etree import ElementTree
         iII = ElementTree.parse(O00O0oOO00O00.text)
         oO00o0 = iII.findall('addon')
         OOoo0O = None
         if 5 - 5: o0oOOo0O0Ooo * o00ooo0 + OoOoOO00.OOooOOo + OoOoOO00
         for o0oo in oO00o0:
             if o0oo.attrib['id'] == i1i:
                 OOoo0O = o0oo.attrib['version']
                 if 91 - 91: O0
         if OOoo0O > 0:
             IiII = "{0}{1}-{2}.zip".format(urls[0], plugin, OOoo0O)
             logging.log(str(IiII))
             db.addon_database(plugin, 1)
             self.install_addon_from_url(plugin, IiII)
             xbmc.executebuiltin('Container.Refresh()')
         else:
             logging.log("no match")
             return False
             if 61 - 61: II111iiii
コード例 #17
0
ファイル: wizard.py プロジェクト: elchocolate/repotvchopo
    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}]Existe la posibilidad de que la piel no se vea correctamente'
                .format(CONFIG.COLOR2) + '\n' +
                'Al instalar un {0} build sobre un Kodi {1} Instalar'.format(
                    check.check_build(name, 'kodi'), CONFIG.KODIV) + '\n' +
                '¿Todavía te gustaría instalar: [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]SI, INSTALAR[/COLOR][/B]')
        else:
            if over:
                yes_pressed = 1
            else:
                yes_pressed = self.dialog.yesno(
                    CONFIG.ADDONTITLE,
                    '[COLOR {0}]¿Le gustaría descargar e instalar: '.format(
                        CONFIG.COLOR2) +
                    '[COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]'.format(
                        CONFIG.COLOR1, name, check.check_build(
                            name, 'version')),
                    nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]',
                    yeslabel='[B][COLOR springgreen]si, instalar[/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]descargando:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1, name,
                        check.check_build(name, 'version')) + '\n' +
                'espere por favor')

            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

            yes_fresh = self.dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {0}][COLOR {1}]¿Desea borrar todos los datos antes de instalar?[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1),
                nolabel='[B][COLOR red]No gracias[/COLOR][/B]',
                yeslabel='[B][COLOR springgreen]si[/COLOR][/B]')
            if yes_fresh:
                install.wipe()

            skin.look_and_feel_data('save')

            title = '[COLOR {0}][B]instalando:[/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' + 'espere por favor')
            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' +
                        'Completado: [COLOR {0}]{1}{2}[/COLOR] [Errors:[COLOR {3}]{4}[/COLOR]]'
                        .format(CONFIG.COLOR1, percent, '%', CONFIG.COLOR1,
                                errors) + '\n' +
                        '¿Le gustaría ver los errores?[/COLOR]',
                        nolabel='[B][COLOR red]No [/COLOR][/B]',
                        yeslabel='[B][COLOR springgreen]si[/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}]Para guardar los cambios, ahora necesita forzar el cierre de Kodi, presione OK para forzar el cierre de 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}]Instalación de compilación: cancelada.[/COLOR]'.
                format(CONFIG.COLOR2))
コード例 #18
0
    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
コード例 #19
0
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...' + '\n' + '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.LOGINFO)
                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.LOGINFO)
    elif os.path.exists(os.path.join(CONFIG.ADDONS, CONFIG.REPOID)):
        logging.log("[Auto Install Repo] Repository already installed")
コード例 #20
0
ファイル: wizard.py プロジェクト: gtkingbuild/Repo-Prueba
    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}]Le gustaria aplicar la correccion de interfaz gráfica de usuario para:'
                    .format(CONFIG.COLOR2) + '\n' +
                    '[COLOR {0}]{1}[/COLOR]?[/COLOR]'.format(
                        CONFIG.COLOR1, name),
                    nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]',
                    yeslabel=
                    '[B][COLOR springgreen]Aplicar Correccion[/COLOR][/B]')
        else:
            yes_pressed = self.dialog.yesno(
                "[B]{0} - [COLOR red]ADVERTENCIA!![/COLOR][/B]".format(
                    CONFIG.ADDONTITLE),
                "[COLOR {0}][COLOR {1}]{2}[/COLOR] [B]La Build de la comunidad no está instalada actualmente."
                .format(CONFIG.COLOR2, CONFIG.COLOR1, name) + '\n' +
                "Le gustaría aplicar la Corrección Gui ([COLOR azure]de la interfaz gráfica de usuario[/COLOR]) de todos modos?[/B][/COLOR]",
                nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]',
                yeslabel='[B][COLOR springgreen]Aplicar Correccion[/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}]Corrección Gui: Url Zip Inválido![/COLOR]'.
                    format(CONFIG.COLOR2))
                return

            self.dialogProgress.create(
                CONFIG.ADDONTITLE,
                '[COLOR {0}][B]Descargando Correccion Gui:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1,
                        name), '', 'Espere por Favor')

            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]Instalando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(
                CONFIG.COLOR2, CONFIG.COLOR1, name)
            self.dialogProgress.update(0, title + '\n' + 'Espere por Favor')
            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}][B]Para guardar los cambios, ahora necesita Forzar el Cierre de Kodi.[/B] \n\nPresione [B]OK[/B] para Forzar el Cierre de Kodi.[/COLOR]"
                .format(CONFIG.COLOR2))
            tools.kill_kodi(over=True)
        else:
            logging.log_notify(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Corrección Gui:[/COLOR] [COLOR gold]Cancelado![/COLOR]'
                .format(CONFIG.COLOR2))
コード例 #21
0
    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

            yes_fresh = self.dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {0}][COLOR {1}]Do you wish to erase all data before installing?[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1),
                nolabel='[B][COLOR red]No Thanks[/COLOR][/B]',
                yeslabel='[B][COLOR springgreen]Fresh Install[/COLOR][/B]')
            if yes_fresh:
                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)

                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))
コード例 #22
0
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")