Пример #1
0
def view_advanced():
    from resources.libs.common import tools
    from resources.libs.gui import window

    window.show_text_box(
        CONFIG.ADDONTITLE,
        tools.read_from_file(CONFIG.ADVANCED).replace('\t', '    '))
Пример #2
0
def check_repos():
    from resources.libs.common import logging
    from resources.libs.common import tools

    progress_dialog = xbmcgui.DialogProgress()

    progress_dialog.create(
        CONFIG.ADDONTITLE,
        '[COLOR {0}]Comprobación de Repositorios...[/COLOR]'.format(
            CONFIG.COLOR2))
    badrepos = []
    xbmc.executebuiltin('UpdateAddonRepos')
    repolist = glob.glob(os.path.join(CONFIG.ADDONS, 'repo*'))
    if len(repolist) == 0:
        progress_dialog.close()
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]No se Encontraron Repositorios![/COLOR]".format(
                CONFIG.COLOR2))
        return
    sleeptime = len(repolist)
    start = 0
    while start < sleeptime:
        start += 1
        if progress_dialog.iscanceled():
            break
        perc = int(tools.percentage(start, sleeptime))
        progress_dialog.update(
            perc, '\n' +
            '[COLOR {0}]Comprobando: [/COLOR][COLOR {1}]{2}[/COLOR]'.format(
                CONFIG.COLOR2, CONFIG.COLOR1, repolist[start - 1].replace(
                    CONFIG.ADDONS, '')[1:]))
        xbmc.sleep(1000)
    if progress_dialog.iscanceled():
        progress_dialog.close()
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Habilitación de Addons Cancelado[/COLOR]".format(
                CONFIG.COLOR2))
        sys.exit()
    progress_dialog.close()
    logfile = logging.grab_log()
    fails = re.compile('CRepositoryUpdateJob(.+?)failed').findall(logfile)
    for item in fails:
        logging.log("Repositorio Incorrecto: {0} ".format(item))
        brokenrepo = item.replace('[', '').replace(']', '').replace(
            ' ', '').replace('/', '').replace('\\', '')
        if brokenrepo not in badrepos:
            badrepos.append(brokenrepo)
    if len(badrepos) > 0:
        msg = "[COLOR {0}]A continuación se muestra una lista de Repositorios que no se resolvieron.  Esto no significa que estén Depreciados, a veces los hosts caen por un período corto de tiempo.  Realice varios escaneos de su lista de repositorios antes de eliminar un repositorio, solo para asegurarse de que esté roto.[/COLOR][CR][CR][COLOR {1}]".format(
            CONFIG.COLOR2, CONFIG.COLOR1)
        msg += '[CR]'.join(badrepos)
        msg += '[/COLOR]'
        window.show_text_box("Visualización de Repositorios Rotos", msg)
    else:
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Todos los Repositorios Funcionan![/COLOR]".format(
                CONFIG.COLOR2))
Пример #3
0
    def _view_errors(self, percent, errors, error, file):
        if int(errors) >= 1:
            if self.dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}][COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, file) + '\n' + 'Concluído: [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]Não, obrigado[/COLOR][/B]',
                                 yeslabel='[B][COLOR springgreen]Ver erros[/COLOR][/B]'):

                from resources.libs.gui import window
                window.show_text_box("Viewing Errors", error.replace('\t', ''))
Пример #4
0
def check_repos():
    from resources.libs.common import logging
    from resources.libs.common import tools

    progress_dialog = xbmcgui.DialogProgress()

    progress_dialog.create(
        CONFIG.ADDONTITLE,
        '[COLOR {0}]Checking Repositories...[/COLOR]'.format(CONFIG.COLOR2))
    badrepos = []
    xbmc.executebuiltin('UpdateAddonRepos')
    repolist = glob.glob(os.path.join(CONFIG.ADDONS, 'repo*'))
    if len(repolist) == 0:
        progress_dialog.close()
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]No Repositories Found![/COLOR]".format(CONFIG.COLOR2))
        return
    sleeptime = len(repolist)
    start = 0
    while start < sleeptime:
        start += 1
        if progress_dialog.iscanceled():
            break
        perc = int(tools.percentage(start, sleeptime))
        progress_dialog.update(
            perc, '',
            '[COLOR {0}]Checking: [/COLOR][COLOR {1}]{2}[/COLOR]'.format(
                CONFIG.COLOR2, CONFIG.COLOR1,
                repolist[start - 1].replace(CONFIG.ADDONS, '')[1:]))
        xbmc.sleep(1000)
    if progress_dialog.iscanceled():
        progress_dialog.close()
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Enabling Addons Cancelled[/COLOR]".format(
                CONFIG.COLOR2))
        sys.exit()
    progress_dialog.close()
    logfile = logging.grab_log()
    fails = re.compile('CRepositoryUpdateJob(.+?)failed').findall(logfile)
    for item in fails:
        logging.log("Bad Repository: {0} ".format(item))
        brokenrepo = item.replace('[', '').replace(']', '').replace(
            ' ', '').replace('/', '').replace('\\', '')
        if brokenrepo not in badrepos:
            badrepos.append(brokenrepo)
    if len(badrepos) > 0:
        msg = "[COLOR {0}]Below is a list of Repositories that did not resolve.  This does not mean that they are Depreciated, sometimes hosts go down for a short period of time.  Please do serveral scans of your repository list before removing a repository just to make sure it is broken.[/COLOR][CR][CR][COLOR {1}]".format(
            CONFIG.COLOR2, CONFIG.COLOR1)
        msg += '[CR]'.join(badrepos)
        msg += '[/COLOR]'
        window.show_text_box("Viewing Broken Repositories", msg)
    else:
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]All Repositories Working![/COLOR]".format(
                CONFIG.COLOR2))
    def build_info(self, name):
        from resources.libs import check
        from resources.libs.common import logging
        from resources.libs.common import tools
        from resources.libs.gui import window
        
        response = tools.open_url(CONFIG.BUILDFILE, check=True)
        
        if response:
            if check.check_build(name, 'url'):
                name, version, url, minor, gui_ignore, kodi, theme, icon, fanart, preview, adult, info, description = check.check_build(name, 'all')
                adult = 'Yes' if adult.lower() == 'yes' else 'No'

                info_response = tools.open_url(info)

                if info_response:
                    try:
                        tname, extracted, zipsize, skin, created, programs, video, music, picture, repos, scripts, binaries = check.check_info(info_response.text)
                        extend = True
                    except:
                        extend = False
                else:
                    extend = False

                themes = self.theme_count(name, count=False)

                msg = "[COLOR {0}]Build Name:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, name)
                msg += "[COLOR {0}]Build Version:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, version)
                if themes:
                    msg += "[COLOR {0}]Build Theme(s):[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, ', '.join(themes))
                msg += "[COLOR {0}]Kodi Version:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, kodi)
                msg += "[COLOR {0}]Adult Content:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, adult)
                msg += "[COLOR {0}]Description:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, description)

                if extend:
                    msg += "[COLOR {0}]Latest Update:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, created)
                    msg += "[COLOR {0}]Extracted Size:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, tools.convert_size(int(float(extracted))))
                    msg += "[COLOR {0}]Zip Size:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, tools.convert_size(int(float(zipsize))))
                    msg += "[COLOR {0}]Skin Name:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, skin)
                    msg += "[COLOR {0}]Programs:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, programs)
                    msg += "[COLOR {0}]Video:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, video)
                    msg += "[COLOR {0}]Music:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, music)
                    msg += "[COLOR {0}]Pictures:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, picture)
                    msg += "[COLOR {0}]Repositories:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, repos)
                    msg += "[COLOR {0}]Scripts:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(CONFIG.COLOR2, CONFIG.COLOR1, scripts)
                    msg += "[COLOR {0}]Binaries:[/COLOR] [COLOR {1}]{2}[/COLOR]".format(CONFIG.COLOR2, CONFIG.COLOR1, binaries)

                window.show_text_box("Viewing Build Info: {0}".format(name), msg)
            else:
                logging.log("Invalid Build Name!")
        else:
            logging.log("Build text file not working: {0}".format(CONFIG.BUILDFILE))
Пример #6
0
    def _view_errors(self, percent, errors, error, file):
        if int(errors) >= 1:
            if self.dialog.yesno(
                    CONFIG.ADDONTITLE,
                    '[COLOR {0}][COLOR {1}]{2}[/COLOR]'.format(
                        CONFIG.COLOR2, CONFIG.COLOR1, file) + '\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 cyan]Ver Errores[/COLOR][/B]'):

                from resources.libs.gui import window
                window.show_text_box("Ver Errores", error.replace('\t', ''))
Пример #7
0
    def _view_errors(self, percent, errors, error, file):
        if int(errors) >= 1:
            if self.dialog.yesno(CONFIG.ADDONTITLE,
                                 '[COLOR {0}][COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, file),
                                 'Completed: [COLOR {0}]{1}{2}[/COLOR] [Errors: [COLOR {3}]{4}[/COLOR]]'.format(
                                     CONFIG.COLOR1,
                                     percent, '%',
                                     CONFIG.COLOR1,
                                     errors),
                                 'Would you like to view the errors?[/COLOR]',
                                 nolabel='[B][COLOR red]No Thanks[/COLOR][/B]',
                                 yeslabel='[B][COLOR deepskyblue]View Errors[/COLOR][/B]'):

                from resources.libs.gui import window
                window.show_text_box("Viewing Errors", error.replace('\t', ''))
Пример #8
0
    def _finish(self, file, loc, zname):
        from resources.libs import extract
        from resources.libs import db
        from resources.libs.common import tools

        dialog = xbmcgui.Dialog()
        progress_dialog = xbmcgui.DialogProgress()

        self._prompt_for_wipe()

        percent, errors, error = extract.all(file, loc)

        if int(errors) >= 1:
            if dialog.yesno(
                    CONFIG.ADDONTITLE,
                    '[COLOR {0}][COLOR {1}]{2}[/COLOR]'.format(
                        CONFIG.COLOR2, CONFIG.COLOR1, zname),
                    'Completed: [COLOR {0}]{1}{2}[/COLOR] [Errors: [COLOR {3}]{4}[/COLOR]]'
                    .format(CONFIG.COLOR1, percent, '%', CONFIG.COLOR1,
                            errors),
                    'Would you like to view the errors?[/COLOR]',
                    nolabel='[B][COLOR red]No Thanks[/COLOR][/B]',
                    yeslabel='[B][COLOR springgreen]View Errors[/COLOR][/B]'):

                from resources.libs.gui import window
                window.show_text_box("Viewing Errors", error.replace('\t', ''))
        CONFIG.set_setting('installed', 'true')
        CONFIG.set_setting('extract', str(percent))
        CONFIG.set_setting('errors', str(errors))

        if self.external:
            try:
                os.remove(file)
            except:
                pass

        # binaries_done = self._binaries()
        db.force_check_updates(over=True)

        # if not binaries_done:
        # dialog.ok(CONFIG.ADDONTITLE, '[COLOR {0}]There was an error while restoring. The build may not function correctly.[/COLOR]'.format(CONFIG.COLOR2))

        tools.kill_kodi(
            msg=
            '[COLOR {0}]To save changes, Kodi needs to be force closed. Would you like to continue?[/COLOR]'
            .format(CONFIG.COLOR2))
Пример #9
0
def whitelist(do):
    addonnames = []
    addonids = []
    addonfolds = []

    dialog = xbmcgui.Dialog()

    if do == 'edit':
        fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/'))
        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):
                a = tools.read_from_file(xml)
                temp, addid = parse(a, foldername)
                addonnames.append(temp)
                addonids.append(addid)
                addonfolds.append(foldername)
        fold2 = glob.glob(os.path.join(CONFIG.ADDON_DATA, '*/'))
        for folder in sorted(fold2, key=lambda x: x):
            foldername = os.path.split(folder[:-1])[1]
            if foldername in addonfolds:
                continue
            if foldername in CONFIG.EXCLUDES:
                continue
            xml = os.path.join(CONFIG.ADDONS, foldername, 'addon.xml')
            xml2 = os.path.join(CONFIG.XBMC, 'addons', foldername, 'addon.xml')
            if os.path.exists(xml):
                a = tools.read_from_file(xml)
            elif os.path.exists(xml2):
                a = tools.read_from_file(xml2)
            else:
                continue
            temp, addid = parse(a, foldername)
            addonnames.append(temp)
            addonids.append(addid)
            addonfolds.append(foldername)
        selected = []
        tempaddonnames = ["-- Clique aqui para continuar --"] + addonnames
        currentWhite = whitelist(do='read')
        for item in currentWhite:
            logging.log(str(item))
            try:
                name, id, fold = item
            except Exception as e:
                logging.log(str(e))
            if id in addonids:
                pos = addonids.index(id) + 1
                selected.append(pos - 1)
                tempaddonnames[pos] = "[B][COLOR {0}]{1}[/COLOR][/B]".format(
                    CONFIG.COLOR1, name)
            else:
                addonids.append(id)
                addonnames.append(name)
                tempaddonnames.append("[B][COLOR {0}]{1}[/COLOR][/B]".format(
                    CONFIG.COLOR1, name))
        choice = 1
        while choice not in [-1, 0]:
            choice = dialog.select(
                "{0}: Selecione os complementos que deseja para a lista de permissões."
                .format(CONFIG.ADDONTITLE), tempaddonnames)
            if choice == -1:
                break
            elif choice == 0:
                break
            else:
                choice2 = (choice - 1)
                if choice2 in selected:
                    selected.remove(choice2)
                    tempaddonnames[choice] = addonnames[choice2]
                else:
                    selected.append(choice2)
                    tempaddonnames[
                        choice] = "[B][COLOR {0}]{1}[/COLOR][/B]".format(
                            CONFIG.COLOR1, addonnames[choice2])
        white_list = []
        if len(selected) > 0:
            for addon in selected:
                white_list.append(
                    "['%s', '%s', '%s']" %
                    (addonnames[addon], addonids[addon], addonfolds[addon]))
            writing = '\n'.join(white_list)
            tools.write_to_file(CONFIG.WHITELIST, writing)
        else:
            try:
                os.remove(CONFIG.WHITELIST)
            except:
                pass
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]{1} Complementos na lista de permissões[/COLOR]".
            format(CONFIG.COLOR2, len(selected)))
    elif do == 'read':
        white_list = []
        if os.path.exists(CONFIG.WHITELIST):
            lines = tools.read_from_file(CONFIG.WHITELIST).split('\n')
            for item in lines:
                try:
                    name, id, fold = eval(item)
                    white_list.append(eval(item))
                except:
                    pass
        return white_list
    elif do == 'view':
        list = whitelist(do='read')
        if len(list) > 0:
            msg = "Aqui está uma lista de seus itens de whitelist, esses itens (junto com as dependências) não serão removidos ao realizar um novo início ou os dados do usuário sobrescritos em uma instalação de compilação.[CR][CR]"
            for item in list:
                try:
                    name, id, fold = item
                except Exception as e:
                    logging.log(str(e))
                msg += "[COLOR {0}]{1}[/COLOR] [COLOR {2}]\"{3}\"[/COLOR][CR]".format(
                    CONFIG.COLOR1, name, CONFIG.COLOR2, id)
            window.show_text_box("Exibindo itens da lista de permissões", msg)
        else:
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Nenhum item na lista de permissões[/COLOR]".format(
                    CONFIG.COLOR2))
    elif do == 'import':
        source = dialog.browse(
            1,
            '[COLOR {0}]Selecione o arquivo da lista de permissões para importar[/COLOR]'
            .format(CONFIG.COLOR2), 'files', '.txt', False, False, CONFIG.HOME)
        logging.log(str(source))
        if not source.endswith('.txt'):
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Importação cancelada![/COLOR]".format(
                    CONFIG.COLOR2))
            return
        current = whitelist(do='read')
        idList = []
        count = 0
        for item in current:
            name, id, fold = item
            idList.append(id)
        lines = tools.read_from_file(xbmcvfs.File(source)).split('\n')
        with open(CONFIG.WHITELIST, 'a') as f:
            for item in lines:
                try:
                    name, id, folder = eval(item)
                except Exception as e:
                    logging.log("Erro ao adicionar: '{0}' / {1}".format(
                        item, str(e)),
                                level=xbmc.LOGERROR)
                    continue
                logging.log("{0} / {1} / {2}".format(name, id, folder))
                if id not in idList:
                    count += 1
                    writing = "['{0}', '{1}', '{2}']".format(name, id, folder)
                    if len(idList) + count > 1:
                        writing = "\n%s" % writing
                    f.write(writing)
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]{1} Item(s) Adicionado[/COLOR]".format(
                    CONFIG.COLOR2, count))
    elif do == 'export':
        source = dialog.browse(
            3,
            '[COLOR {0}]AdicionadoSelecione para onde deseja exportar o arquivo da lista de permissões[/COLOR]'
            .format(CONFIG.COLOR2), 'files', '.txt', False, False, CONFIG.HOME)
        logging.log(str(source))
        try:
            xbmcvfs.copy(CONFIG.WHITELIST,
                         os.path.join(source, 'whitelist.txt'))
            dialog.ok(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]A lista de permissões foi exportada para:[/COLOR]".
                format(CONFIG.COLOR2) + '\n' + "[COLOR {0}]{1}[/COLOR]".format(
                    CONFIG.COLOR1, os.path.join(source, 'whitelist.txt')))
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Whitelist Exported[/COLOR]".format(CONFIG.COLOR2))
        except Exception as e:
            logging.log("Export Error: {0}".format(str(e)),
                        level=xbmc.LOGERROR)
            if not dialog.yesno(
                    CONFIG.ADDONTITLE,
                    "[COLOR {0}]O local selecionado não é gravável. Gostaria de selecionar outro?[/COLOR]"
                    .format(CONFIG.COLOR2),
                    yeslabel=
                    "[B][COLOR springgreen]Mudar localização[/COLOR][/B]",
                    nolabel="[B][COLOR red]Não Cancelar[/COLOR][/B]"):
                logging.log_notify(
                    CONFIG.ADDONTITLE,
                    "[COLOR {0}]Exportação da lista branca cancelada[/COLOR]".
                    format(CONFIG.COLOR2, e))
            else:
                whitelist(do='export')
    elif do == 'clear':
        if not dialog.yesno(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Tem certeza de que deseja limpar sua lista de permissões?"
                .format(CONFIG.COLOR2) + '\n' +
                "Este processo não pode ser desfeito.[/COLOR]",
                yeslabel="[B][COLOR springgreen]Sim remover[/COLOR][/B]",
                nolabel="[B][COLOR red]No Cancel[/COLOR][/B]"):
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Clear Whitelist Cancelado[/COLOR]".format(
                    CONFIG.COLOR2))
            return
        try:
            os.remove(CONFIG.WHITELIST)
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Permissões Liberado[/COLOR]".format(CONFIG.COLOR2))
        except:
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Erro ao limpar a lista de permissões![/COLOR]".
                format(CONFIG.COLOR2))
Пример #10
0
def view_current():
    window.show_text_box(
        CONFIG.ADDONTITLE,
        tools.read_from_file(CONFIG.ADVANCED).replace('\t', '    '))
Пример #11
0
def whitelist(do):
    addonnames = []
    addonids = []
    addonfolds = []

    dialog = xbmcgui.Dialog()
    
    if do == 'edit':
        fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/'))
        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):
                a = tools.read_from_file(xml)
                temp, addid = parse(a, foldername)
                addonnames.append(temp)
                addonids.append(addid)
                addonfolds.append(foldername)
        fold2 = glob.glob(os.path.join(CONFIG.ADDON_DATA, '*/'))
        for folder in sorted(fold2, key=lambda x: x):
            foldername = os.path.split(folder[:-1])[1]
            if foldername in addonfolds:
                continue
            if foldername in CONFIG.EXCLUDES:
                continue
            xml = os.path.join(CONFIG.ADDONS, foldername, 'addon.xml')
            xml2 = os.path.join(CONFIG.XBMC, 'addons', foldername, 'addon.xml')
            if os.path.exists(xml):
                a = tools.read_from_file(xml)
            elif os.path.exists(xml2):
                a = tools.read_from_file(xml2)
            else:
                continue
            temp, addid = parse(a, foldername)
            addonnames.append(temp)
            addonids.append(addid)
            addonfolds.append(foldername)
        selected = []
        tempaddonnames = ["-- Click here to Continue --"] + addonnames
        currentWhite = whitelist(do='read')
        for item in currentWhite:
            logging.log(str(item))
            try:
                name, id, fold = item
            except Exception as e:
                logging.log(str(e))
            if id in addonids:
                pos = addonids.index(id)+1
                selected.append(pos-1)
                tempaddonnames[pos] = "[B][COLOR {0}]{1}[/COLOR][/B]".format(CONFIG.COLOR1, name)
            else:
                addonids.append(id)
                addonnames.append(name)
                tempaddonnames.append("[B][COLOR {0}]{1}[/COLOR][/B]".format(CONFIG.COLOR1, name))
        choice = 1
        while choice not in [-1, 0]:
            choice = dialog.select("{0}: Select the add-ons you wish to the whitelist.".format(CONFIG.ADDONTITLE), tempaddonnames)
            if choice == -1:
                break
            elif choice == 0:
                break
            else:
                choice2 = (choice-1)
                if choice2 in selected:
                    selected.remove(choice2)
                    tempaddonnames[choice] = addonnames[choice2]
                else:
                    selected.append(choice2)
                    tempaddonnames[choice] = "[B][COLOR {0}]{1}[/COLOR][/B]".format(CONFIG.COLOR1, addonnames[choice2])
        white_list = []
        if len(selected) > 0:
            for addon in selected:
                white_list.append("['%s', '%s', '%s']" % (addonnames[addon], addonids[addon], addonfolds[addon]))
            writing = '\n'.join(white_list)
            tools.write_to_file(CONFIG.WHITELIST, writing)
        else:
            try:
                os.remove(CONFIG.WHITELIST)
            except:
                pass
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]{1} Add-ons in whitelist[/COLOR]".format(CONFIG.COLOR2, len(selected)))
    elif do == 'read':
        white_list = []
        if os.path.exists(CONFIG.WHITELIST):
            lines = tools.read_from_file(CONFIG.WHITELIST).split('\n')
            for item in lines:
                try:
                    name, id, fold = eval(item)
                    white_list.append(eval(item))
                except:
                    pass
        return white_list
    elif do == 'view':
        list = whitelist(do='read')
        if len(list) > 0:
            msg = "Here is a list of your whitelist items, these items(along with dependencies) will not be removed when preforming a fresh start or the userdata overwritten in a build install.[CR][CR]"
            for item in list:
                try:
                    name, id, fold = item
                except Exception as e:
                    logging.log(str(e))
                msg += "[COLOR {0}]{1}[/COLOR] [COLOR {2}]\"{3}\"[/COLOR][CR]".format(CONFIG.COLOR1, name, CONFIG.COLOR2, id)
            window.show_text_box("Viewing Whitelisted Items", msg)
        else:
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]No items in whitelist[/COLOR]".format(CONFIG.COLOR2))
    elif do == 'import':
        source = dialog.browse(1, '[COLOR {0}]Select the whitelist file to import[/COLOR]'.format(CONFIG.COLOR2),
                                   'files', '.txt', False, False, CONFIG.HOME)
        logging.log(str(source))
        if not source.endswith('.txt'):
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]Import Cancelled![/COLOR]".format(CONFIG.COLOR2))
            return
        current = whitelist(do='read')
        idList = []
        count = 0
        for item in current:
            name, id, fold = item
            idList.append(id)
        lines = tools.read_from_file(xbmcvfs.File(source)).split('\n')
        with open(CONFIG.WHITELIST, 'a') as f:
            for item in lines:
                try:
                    name, id, folder = eval(item)
                except Exception as e:
                    logging.log("Error Adding: '{0}' / {1}".format(item, str(e)), level=xbmc.LOGERROR)
                    continue
                logging.log("{0} / {1} / {2}".format(name, id, folder))
                if id not in idList:
                    count += 1
                    writing = "['{0}', '{1}', '{2}']".format(name, id, folder)
                    if len(idList) + count > 1:
                        writing = "\n%s" % writing
                    f.write(writing)
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]{1} Item(s) Added[/COLOR]".format(CONFIG.COLOR2, count))
    elif do == 'export':
        source = dialog.browse(3,
                                   '[COLOR {0}]Select where you wish to export the whitelist file[/COLOR]'.format(CONFIG.COLOR2),
                                   'files', '.txt', False, False, CONFIG.HOME)
        logging.log(str(source))
        try:
            xbmcvfs.copy(CONFIG.WHITELIST, os.path.join(source, 'whitelist.txt'))
            dialog.ok(CONFIG.ADDONTITLE,
                          "[COLOR {0}]Whitelist has been exported to:[/COLOR]".format(CONFIG.COLOR2)
                          +'\n'+"[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, os.path.join(source, 'whitelist.txt')))
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]Whitelist Exported[/COLOR]".format(CONFIG.COLOR2))
        except Exception as e:
            logging.log("Export Error: {0}".format(str(e)), level=xbmc.LOGERROR)
            if not dialog.yesno(CONFIG.ADDONTITLE,
                                    "[COLOR {0}]The location you selected isn\'t writable would you like to select another one?[/COLOR]".format(CONFIG.COLOR2),
                                    yeslabel="[B][COLOR springgreen]Change Location[/COLOR][/B]",
                                    nolabel="[B][COLOR red]No Cancel[/COLOR][/B]"):
                logging.log_notify(CONFIG.ADDONTITLE,
                                   "[COLOR {0}]Whitelist Export Cancelled[/COLOR]".format(CONFIG.COLOR2, e))
            else:
                whitelist(do='export')
    elif do == 'clear':
        if not dialog.yesno(CONFIG.ADDONTITLE,
                                "[COLOR {0}]Are you sure you want to clear your whitelist?".format(CONFIG.COLOR2)
                                +'\n'+"This process can't be undone.[/COLOR]",
                                yeslabel="[B][COLOR springgreen]Yes Remove[/COLOR][/B]",
                                nolabel="[B][COLOR red]No Cancel[/COLOR][/B]"):
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]Clear Whitelist Cancelled[/COLOR]".format(CONFIG.COLOR2))
            return
        try:
            os.remove(CONFIG.WHITELIST)
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]Whitelist Cleared[/COLOR]".format(CONFIG.COLOR2))
        except:
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]Error Clearing Whitelist![/COLOR]".format(CONFIG.COLOR2))
Пример #12
0
def whitelist(do):
    addonnames = []
    addonids = []
    addonfolds = []

    dialog = xbmcgui.Dialog()

    if do == 'edit':
        fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/'))
        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):
                a = tools.read_from_file(xml)
                temp, addid = parse(a, foldername)
                addonnames.append(temp)
                addonids.append(addid)
                addonfolds.append(foldername)
        fold2 = glob.glob(os.path.join(CONFIG.ADDON_DATA, '*/'))
        for folder in sorted(fold2, key=lambda x: x):
            foldername = os.path.split(folder[:-1])[1]
            if foldername in addonfolds:
                continue
            if foldername in CONFIG.EXCLUDES:
                continue
            xml = os.path.join(CONFIG.ADDONS, foldername, 'addon.xml')
            xml2 = os.path.join(CONFIG.XBMC, 'addons', foldername, 'addon.xml')
            if os.path.exists(xml):
                a = tools.read_from_file(xml)
            elif os.path.exists(xml2):
                a = tools.read_from_file(xml2)
            else:
                continue
            temp, addid = parse(a, foldername)
            addonnames.append(temp)
            addonids.append(addid)
            addonfolds.append(foldername)
        selected = []
        tempaddonnames = ["-- Clic aquí para Continuar --"] + addonnames
        currentWhite = whitelist(do='read')
        for item in currentWhite:
            logging.log(str(item))
            try:
                name, id, fold = item
            except Exception as e:
                logging.log(str(e))
            if id in addonids:
                pos = addonids.index(id) + 1
                selected.append(pos - 1)
                tempaddonnames[pos] = "[B][COLOR {0}]{1}[/COLOR][/B]".format(
                    CONFIG.COLOR1, name)
            else:
                addonids.append(id)
                addonnames.append(name)
                tempaddonnames.append("[B][COLOR {0}]{1}[/COLOR][/B]".format(
                    CONFIG.COLOR1, name))
        choice = 1
        while choice not in [-1, 0]:
            choice = dialog.select(
                "{0}: Seleccione los add-ons que desea incluir en la Lista Blanca."
                .format(CONFIG.ADDONTITLE), tempaddonnames)
            if choice == -1:
                break
            elif choice == 0:
                break
            else:
                choice2 = (choice - 1)
                if choice2 in selected:
                    selected.remove(choice2)
                    tempaddonnames[choice] = addonnames[choice2]
                else:
                    selected.append(choice2)
                    tempaddonnames[
                        choice] = "[B][COLOR {0}]{1}[/COLOR][/B]".format(
                            CONFIG.COLOR1, addonnames[choice2])
        white_list = []
        if len(selected) > 0:
            for addon in selected:
                white_list.append(
                    "['%s', '%s', '%s']" %
                    (addonnames[addon], addonids[addon], addonfolds[addon]))
            writing = '\n'.join(white_list)
            tools.write_to_file(CONFIG.WHITELIST, writing)
        else:
            try:
                os.remove(CONFIG.WHITELIST)
            except:
                pass
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]{1} Add-ons en la Lista Blanca[/COLOR]".format(
                CONFIG.COLOR2, len(selected)))
    elif do == 'read':
        white_list = []
        if os.path.exists(CONFIG.WHITELIST):
            lines = tools.read_from_file(CONFIG.WHITELIST).split('\n')
            for item in lines:
                try:
                    name, id, fold = eval(item)
                    white_list.append(eval(item))
                except:
                    pass
        return white_list
    elif do == 'view':
        list = whitelist(do='read')
        if len(list) > 0:
            msg = "Aquí hay una lista de los add-ons de su Lista Blanca, estos add-ons (junto con las dependencias) no se eliminarán cuando se realice un nuevo comienzo o los datos de usuario se sobrescriban en la instalación de una nueva Build.[CR][CR]"
            for item in list:
                try:
                    name, id, fold = item
                except Exception as e:
                    logging.log(str(e))
                msg += "[COLOR {0}]{1}[/COLOR] [COLOR {2}]\"{3}\"[/COLOR][CR]".format(
                    CONFIG.COLOR1, name, CONFIG.COLOR2, id)
            window.show_text_box("Visualización de add-ons de la Lista Blanca",
                                 msg)
        else:
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]No hay add-ons en la Lista Blanca[/COLOR]".format(
                    CONFIG.COLOR2))
    elif do == 'import':
        source = dialog.browse(
            1,
            '[COLOR {0}]Seleccione el archivo de la Lista Blanca para importar[/COLOR]'
            .format(CONFIG.COLOR2), 'files', '.txt', False, False, CONFIG.HOME)
        logging.log(str(source))
        if not source.endswith('.txt'):
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Importación Cancelada![/COLOR]".format(
                    CONFIG.COLOR2))
            return
        current = whitelist(do='read')
        idList = []
        count = 0
        for item in current:
            name, id, fold = item
            idList.append(id)
        lines = tools.read_from_file(xbmcvfs.File(source)).split('\n')
        with open(CONFIG.WHITELIST, 'a') as f:
            for item in lines:
                try:
                    name, id, folder = eval(item)
                except Exception as e:
                    logging.log("Error al Agregar: '{0}' / {1}".format(
                        item, str(e)),
                                level=xbmc.LOGERROR)
                    continue
                logging.log("{0} / {1} / {2}".format(name, id, folder))
                if id not in idList:
                    count += 1
                    writing = "['{0}', '{1}', '{2}']".format(name, id, folder)
                    if len(idList) + count > 1:
                        writing = "\n%s" % writing
                    f.write(writing)
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]{1} Elemento(s) Agregado[/COLOR]".format(
                    CONFIG.COLOR2, count))
    elif do == 'export':
        source = dialog.browse(
            3,
            '[COLOR {0}]Seleccione donde desea exportar el archivo de la Lista Blanca[/COLOR]'
            .format(CONFIG.COLOR2), 'files', '.txt', False, False, CONFIG.HOME)
        logging.log(str(source))
        try:
            xbmcvfs.copy(CONFIG.WHITELIST,
                         os.path.join(source, 'whitelist.txt'))
            dialog.ok(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]La Lista Blanca ha sido exportada a:[/COLOR]".
                format(CONFIG.COLOR2) + '\n' + "[COLOR {0}]{1}[/COLOR]".format(
                    CONFIG.COLOR1, os.path.join(source, 'whitelist.txt')))
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Lista Blanca Exportada[/COLOR]".format(
                    CONFIG.COLOR2))
        except Exception as e:
            logging.log("Error de Exportación: {0}".format(str(e)),
                        level=xbmc.LOGERROR)
            if not dialog.yesno(
                    CONFIG.ADDONTITLE,
                    "[COLOR {0}]La ubicación que seleccionó no se puede escribir. Le gustaría seleccionar otra?[/COLOR]"
                    .format(CONFIG.COLOR2),
                    yeslabel="[B][COLOR cyan]Cambiar Ubicación[/COLOR][/B]",
                    nolabel="[B][COLOR red]No, Cancelar[/COLOR][/B]"):
                logging.log_notify(
                    CONFIG.ADDONTITLE,
                    "[COLOR {0}]Cancelada la Exportación de la Lista Blanca  [/COLOR]"
                    .format(CONFIG.COLOR2, e))
            else:
                whitelist(do='export')
    elif do == 'clear':
        if not dialog.yesno(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Estás seguro de que quieres vaciar tu whitelist?".
                format(CONFIG.COLOR2) + '\n' +
                "Este proceso no se puede deshacer.[/COLOR]",
                yeslabel="[B][COLOR springgreen]Si, Eliminar[/COLOR][/B]",
                nolabel="[B][COLOR red]No, Cancelar[/COLOR][/B]"):
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Cancelado el borrado de la Lista Blanca[/COLOR]".
                format(CONFIG.COLOR2))
            return
        try:
            os.remove(CONFIG.WHITELIST)
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Lista Blanca Vaciada[/COLOR]".format(
                    CONFIG.COLOR2))
        except:
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Error Vaciando Lista Blanca![/COLOR]".format(
                    CONFIG.COLOR2))
Пример #13
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]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))
Пример #14
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))
Пример #15
0
def ascii_check(use=None, over=False):
    from resources.libs.common import logging
    from resources.libs.gui import window

    dialog = xbmcgui.Dialog()
    progress_dialog = xbmcgui.DialogProgress()

    if use is None:
        source = dialog.browse(
            3, '[COLOR {0}]Seleccione la carpeta que desea escanear[/COLOR]'.
            format(CONFIG.COLOR2), 'files', '', False, False, CONFIG.HOME)
        if over:
            yes = 1
        else:
            yes = dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Desea [COLOR {1}]eliminar[/COLOR] todos los nombres de archivo con caracteres especiales o prefiere simplemente [COLOR {2}]escanear y ver[/COLOR] los resultados en el Registro (log)?[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.COLOR1),
                yeslabel='[B][COLOR cyan]Eliminar[/COLOR][/B]',
                nolabel='[B][COLOR red]Escanear[/COLOR][/B]')
    else:
        source = use
        yes = 1

    if source == "":
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]ASCII Check:[/COLOR] [COLOR gold]Cancelado[/COLOR]".
            format(CONFIG.COLOR2))
        return

    files_found = os.path.join(CONFIG.PLUGIN_DATA, 'asciifiles.txt')
    files_fails = os.path.join(CONFIG.PLUGIN_DATA, 'asciifails.txt')
    afiles = open(files_found, mode='w+')
    afails = open(files_fails, mode='w+')
    f1 = 0
    f2 = 0
    items = file_count(source)
    msg = ''
    prog = []
    logging.log("Archivo fuente: ({0})".format(str(source)))

    progress_dialog.create(CONFIG.ADDONTITLE, 'Espere por Favor...')
    for base, dirs, files in os.walk(source):
        dirs[:] = [d for d in dirs]
        files[:] = [f for f in files]
        for file in files:
            prog.append(file)
            prog2 = int(len(prog) / float(items) * 100)
            progress_dialog.update(
                prog2, "[COLOR {0}]Comprobación de archivos no ASCII".format(
                    CONFIG.COLOR2) + '\n' +
                '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, file) + '\n' +
                'Espere por Favor[/COLOR]')
            try:
                file.encode('ascii')
            except UnicodeEncodeError:
                logging.log(
                    "[ASCII Check] Carácter ilegal encontrado en archivo: {0}".
                    format(file))
            except UnicodeDecodeError:
                logging.log(
                    "[ASCII Check] Carácter ilegal encontrado en archivo: {0}".
                    format(file))
                badfile = os.path.join(base, file)
                if yes:
                    try:
                        os.remove(badfile)
                        for chunk in chunks(badfile, 75):
                            afiles.write(chunk + '\n')
                        afiles.write('\n')
                        f1 += 1
                        logging.log(
                            "[ASCII Check] Archivo Eliminado: {0} ".format(
                                badfile),
                            level=xbmc.LOGERROR)
                    except:
                        for chunk in chunks(badfile, 75):
                            afails.write(chunk + '\n')
                        afails.write('\n')
                        f2 += 1
                        logging.log(
                            "[ASCII Check] Archivo Fallido: {0} ".format(
                                badfile),
                            level=xbmc.LOGERROR)
                else:
                    for chunk in chunks(badfile, 75):
                        afiles.write(chunk + '\n')
                    afiles.write('\n')
                    f1 += 1
                    logging.log(
                        "[ASCII Check] Archivo Encontrado: {0} ".format(
                            badfile),
                        level=xbmc.LOGERROR)
                pass
        if progress_dialog.iscanceled():
            progress_dialog.close()
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Comprobación ASCII Cancelada[/COLOR]".format(
                    CONFIG.COLOR2))
            sys.exit()
    progress_dialog.close()
    afiles.close()
    afails.close()
    total = int(f1) + int(f2)
    if total > 0:
        if os.path.exists(files_found):
            msg = read_from_file(files_found)
        if os.path.exists(files_fails):
            msg2 = read_from_file(files_fails)
        if yes:
            if use:
                logging.log_notify(
                    CONFIG.ADDONTITLE,
                    "[COLOR {0}]ASCII Check: {1} Eliminado / {2} Fallido.[/COLOR]"
                    .format(CONFIG.COLOR2, f1, f2))
            else:
                window.show_text_box(
                    "Viewing Removed ASCII Files",
                    "[COLOR yellow][B]{0} Archivos Eliminados:[/B][/COLOR]\n {1}\n\n[COLOR yellow][B]{2} Archivos Fallidos:[B][/COLOR]\n {3}"
                    .format(f1, msg, f2, msg2))
        else:
            window.show_text_box(
                "Viewing Found ASCII Files",
                "[COLOR yellow][B]{0} Archivos Encontrados:[/B][/COLOR]\n {1}".
                format(f1, msg))
    else:
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]ASCII Check:[/COLOR] [COLOR gold]Nada Encontrado.[/COLOR]"
            .format(CONFIG.COLOR2))
Пример #16
0
def ascii_check(use=None, over=False):
    from resources.libs.common import logging
    from resources.libs.gui import window

    dialog = xbmcgui.Dialog()
    progress_dialog = xbmcgui.DialogProgress()

    if use is None:
        source = dialog.browse(
            3,
            '[COLOR {0}]Selecione a pasta que deseja verificar[/COLOR]'.format(
                CONFIG.COLOR2), 'files', '', False, False, CONFIG.HOME)
        if over:
            yes = 1
        else:
            yes = dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Você quer [COLOR {1}]excluir[/COLOR] todos os nomes de arquivos com caracteres especiais ou você prefere apenas [COLOR {2}]escanear e ver[/COLOR] os resultados no log?[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.COLOR1),
                yeslabel='[B][COLOR springgreen]Excluir[/COLOR][/B]',
                nolabel='[B][COLOR red]Varredura[/COLOR][/B]')
    else:
        source = use
        yes = 1

    if source == "":
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Verificação ASCII: Cancelado[/COLOR]".format(
                CONFIG.COLOR2))
        return

    files_found = os.path.join(CONFIG.PLUGIN_DATA, 'asciifiles.txt')
    files_fails = os.path.join(CONFIG.PLUGIN_DATA, 'asciifails.txt')
    afiles = open(files_found, mode='w+')
    afails = open(files_fails, mode='w+')
    f1 = 0
    f2 = 0
    items = file_count(source)
    msg = ''
    prog = []
    logging.log("Arquivo fonte: ({0})".format(str(source)))

    progress_dialog.create(CONFIG.ADDONTITLE, 'Por favor, espere...')
    for base, dirs, files in os.walk(source):
        dirs[:] = [d for d in dirs]
        files[:] = [f for f in files]
        for file in files:
            prog.append(file)
            prog2 = int(len(prog) / float(items) * 100)
            progress_dialog.update(
                prog2, "[COLOR {0}]Verificando arquivos não ASCII".format(
                    CONFIG.COLOR2) + '\n' +
                '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, file) + '\n' +
                'Por favor, aguarde[/COLOR]')
            try:
                file.encode('ascii')
            except UnicodeEncodeError:
                logging.log(
                    "[ASCII Check] Caráter ilegal encontrado no arquivo: {0}".
                    format(file))
            except UnicodeDecodeError:
                logging.log(
                    "[ASCII Check] Caráter ilegal encontrado no arquivo: {0}".
                    format(file))
                badfile = os.path.join(base, file)
                if yes:
                    try:
                        os.remove(badfile)
                        for chunk in chunks(badfile, 75):
                            afiles.write(chunk + '\n')
                        afiles.write('\n')
                        f1 += 1
                        logging.log(
                            "[ASCII Check] Arquivo Removido: {0} ".format(
                                badfile),
                            level=xbmc.LOGERROR)
                    except:
                        for chunk in chunks(badfile, 75):
                            afails.write(chunk + '\n')
                        afails.write('\n')
                        f2 += 1
                        logging.log(
                            "[ASCII Check] Arquivo falhou: {0} ".format(
                                badfile),
                            level=xbmc.LOGERROR)
                else:
                    for chunk in chunks(badfile, 75):
                        afiles.write(chunk + '\n')
                    afiles.write('\n')
                    f1 += 1
                    logging.log(
                        "[ASCII Check] Arquivo encontrado: {0} ".format(
                            badfile),
                        level=xbmc.LOGERROR)
                pass
        if progress_dialog.iscanceled():
            progress_dialog.close()
            logging.log_notify(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Verificação ASCII cancelada[/COLOR]".format(
                    CONFIG.COLOR2))
            sys.exit()
    progress_dialog.close()
    afiles.close()
    afails.close()
    total = int(f1) + int(f2)
    if total > 0:
        if os.path.exists(files_found):
            msg = read_from_file(files_found)
        if os.path.exists(files_fails):
            msg2 = read_from_file(files_fails)
        if yes:
            if use:
                logging.log_notify(
                    CONFIG.ADDONTITLE,
                    "[COLOR {0}]Verificar ASCII: {1} Removido / {2} Fracassado.[/COLOR]"
                    .format(CONFIG.COLOR2, f1, f2))
            else:
                window.show_text_box(
                    "Visualizando arquivos ASCII removidos",
                    "[COLOR yellow][B]{0} Arquivos Removidos:[/B][/COLOR]\n {1}\n\n[COLOR yellow][B]{2} Arquivos com falha:[B][/COLOR]\n {3}"
                    .format(f1, msg, f2, msg2))
        else:
            window.show_text_box(
                "Visualizando arquivos ASCII encontrados",
                "[COLOR yellow][B]{0} Arquivos encontrados:[/B][/COLOR]\n {1}".
                format(f1, msg))
    else:
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Verificação ASCII: Nenhum encontrado.[/COLOR]".format(
                CONFIG.COLOR2))
Пример #17
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}]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 build_info(self, name):
     from resources.libs import check
     from resources.libs.common import logging
     from resources.libs.common import tools
     from resources.libs.gui import window
     if 75 - 75: o0oOOo0O0Ooo.Oo0ooO0oo0oO
     iiiI11 = tools.open_url(CONFIG.BUILDFILE, check=True)
     if 54 - 54:
         II111iiii % OoOoOO00 % I11i % iIii1I11I1II1 + iIii1I11I1II1 * Oo0ooO0oo0oO
     if iiiI11:
         if check.check_build(name, 'url'):
             name, o00, Oo0oO0ooo, O00O0oOO00O00, i1Oo00, i1, oOOoo00O0O, i1111, i11, I1i1I, I11, oOO00oOO, Oo0o0000o0o0 = check.check_build(
                 name, 'all')
             I11 = 'Yes' if I11.lower() == 'yes' else 'No'
             if 31 - 31: O0oo0OO0.OoOoOO00 / O0
             o000O0o = tools.open_url(oOO00oOO)
             if 42 - 42: OoOoOO00
             if o000O0o:
                 try:
                     II, Ii1I1IIii1II, O0ii1ii1ii, oooooOoo0ooo, I1I1IiI1, III1iII1I1ii, oOOo0, oo00O00oO, iIiIIIi, ooo00OOOooO, O00OOOoOoo0O, O000OOo00oo = check.check_info(
                         o000O0o.text)
                     oo0OOo = True
                 except:
                     oo0OOo = False
             else:
                 oo0OOo = False
                 if 64 - 64: I11i
             i1IIiiiii = self.theme_count(name, count=False)
             if 22 - 22: Oo0Ooo + Ii1I % I1ii11iIi11i
             iI1 = "[COLOR {0}]Nome da construção:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                 CONFIG.COLOR2, CONFIG.COLOR1, name)
             iI1 += "[COLOR {0}]Build Version:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                 CONFIG.COLOR2, CONFIG.COLOR1, o00)
             if i1IIiiiii:
                 iI1 += "[COLOR {0}]Build Tema(s):[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, ', '.join(i1IIiiiii))
             iI1 += "[COLOR {0}]Versão Kodi:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                 CONFIG.COLOR2, CONFIG.COLOR1, i1)
             iI1 += "[COLOR {0}]Conteúdo adulto:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                 CONFIG.COLOR2, CONFIG.COLOR1, I11)
             iI1 += "[COLOR {0}]Descrição:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                 CONFIG.COLOR2, CONFIG.COLOR1, Oo0o0000o0o0)
             if 28 - 28: OoO0O00 + Ii1I / OoO0O00.II111iiii
             if oo0OOo:
                 iI1 += "[COLOR {0}]Última atualização:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, I1I1IiI1)
                 iI1 += "[COLOR {0}]Tamanho Extraído:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1,
                     tools.convert_size(int(float(Ii1I1IIii1II))))
                 iI1 += "[COLOR {0}]Tamanho Zip:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1,
                     tools.convert_size(int(float(O0ii1ii1ii))))
                 iI1 += "[COLOR {0}]Nome da Skin:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, oooooOoo0ooo)
                 iI1 += "[COLOR {0}]Programa:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, III1iII1I1ii)
                 iI1 += "[COLOR {0}]Video:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, oOOo0)
                 iI1 += "[COLOR {0}]Música:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, oo00O00oO)
                 iI1 += "[COLOR {0}]Fotos:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, iIiIIIi)
                 iI1 += "[COLOR {0}]Repositórios:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, ooo00OOOooO)
                 iI1 += "[COLOR {0}]Scripts:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, O00OOOoOoo0O)
                 iI1 += "[COLOR {0}]Binários:[/COLOR] [COLOR {1}]{2}[/COLOR]".format(
                     CONFIG.COLOR2, CONFIG.COLOR1, O000OOo00oo)
                 if 68 - 68: i11iIiiIii % I1ii11iIi11i + i11iIiiIii
             window.show_text_box(
                 "Visualizando informações de compilação: {0}".format(name),
                 iI1)
         else:
             logging.log("Nome de compilação inválido!")
     else:
         logging.log(
             "O arquivo de texto de compilação não está funcionando: {0}".
             format(CONFIG.BUILDFILE))
         if 31 - 31: II111iiii.I1IiiI
Пример #19
0
    def build_info(self, name):
        from resources.libs import check
        from resources.libs.common import logging
        from resources.libs.common import tools
        from resources.libs.gui import window

        response = tools.open_url(CONFIG.BUILDFILE, check=True)

        if response:
            if check.check_build(name, 'url'):
                name, version, url, minor, gui_ignore, kodi, theme, icon, fanart, preview, adult, info, description = check.check_build(
                    name, 'all')
                adult = 'Yes' if adult.lower() == 'yes' else 'No'

                info_response = tools.open_url(info)

                if info_response:
                    try:
                        tname, extracted, zipsize, skin, created, programs, video, music, picture, repos, scripts, binaries = check.check_info(
                            info_response.text)
                        extend = True
                    except:
                        extend = False
                else:
                    extend = False

                themes = self.theme_count(name, count=False)

                msg = "[COLOR {0}]Nombre Build:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                    CONFIG.COLOR2, CONFIG.COLOR1, name)
                msg += "[COLOR {0}]Version Build:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                    CONFIG.COLOR2, CONFIG.COLOR1, version)
                if themes:
                    msg += "[COLOR {0}]Build Parche(s):[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, ', '.join(themes))
                msg += "[COLOR {0}]Version Kodi:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                    CONFIG.COLOR2, CONFIG.COLOR1, kodi)
                msg += "[COLOR {0}]Contenido Adulto:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                    CONFIG.COLOR2, CONFIG.COLOR1, adult)
                msg += "[COLOR {0}]Descripción:[/COLOR] [COLOR {1}]{2}[/COLOR][CR]".format(
                    CONFIG.COLOR2, CONFIG.COLOR1, description)

                if extend:
                    msg += "[COLOR {0}]Ultima Actualización:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, created)
                    msg += "[COLOR {0}]Tamaño Extraido:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1,
                        tools.convert_size(int(float(extracted))))
                    msg += "[COLOR {0}]Tamaño Zip:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1,
                        tools.convert_size(int(float(zipsize))))
                    msg += "[COLOR {0}]Nombre Skin:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, skin)
                    msg += "[COLOR {0}]Programas:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, programs)
                    msg += "[COLOR {0}]Video:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, video)
                    msg += "[COLOR {0}]Música:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, music)
                    msg += "[COLOR {0}]Imágenes:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, picture)
                    msg += "[COLOR {0}]Repositorios:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, repos)
                    msg += "[COLOR {0}]Scripts:[/COLOR] [COLOR {1}]{2}[/COLOR][CR][CR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, scripts)
                    msg += "[COLOR {0}]Binarios:[/COLOR] [COLOR {1}]{2}[/COLOR]".format(
                        CONFIG.COLOR2, CONFIG.COLOR1, binaries)

                window.show_text_box(
                    "[B][COLOR azure]Visualización de Información de la Build:[/COLOR][/B] [COLOR blue]{0}[/COLOR]"
                    .format(name), msg)
            else:
                logging.log("Nombre Inválido de la Build!")
        else:
            logging.log(
                "[B][COLOR azure]La Build del archivo de texto no funciona:[/COLOR][/B] [COLOR blue]{0}[/COLOR]"
                .format(CONFIG.BUILDFILE))
Пример #20
0
def ascii_check(use=None, over=False):
    from resources.libs.common import logging
    from resources.libs.gui import window
    
    dialog = xbmcgui.Dialog()
    progress_dialog = xbmcgui.DialogProgress()

    if use is None:
        source = dialog.browse(3,
                                   '[COLOR {0}]Select the folder you want to scan[/COLOR]'.format(CONFIG.COLOR2),
                                   'files', '', False, False, CONFIG.HOME)
        if over:
            yes = 1
        else:
            yes = dialog.yesno(CONFIG.ADDONTITLE,
                                   '[COLOR {0}]Do you want to [COLOR {1}]delete[/COLOR] all filenames with special characters or would you rather just [COLOR {2}]scan and view[/COLOR] the results in the log?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, CONFIG.COLOR1),
                                   yeslabel='[B][COLOR deepskyblue]Delete[/COLOR][/B]',
                                   nolabel='[B][COLOR red]Scan[/COLOR][/B]')
    else:
        source = use
        yes = 1

    if source == "":
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]ASCII Check: Cancelled[/COLOR]".format(CONFIG.COLOR2))
        return

    files_found = os.path.join(CONFIG.PLUGIN_DATA, 'asciifiles.txt')
    files_fails = os.path.join(CONFIG.PLUGIN_DATA, 'asciifails.txt')
    afiles = open(files_found, mode='w+')
    afails = open(files_fails, mode='w+')
    f1 = 0
    f2 = 0
    items = file_count(source)
    msg = ''
    prog = []
    logging.log("Source file: ({0})".format(str(source)))

    progress_dialog.create(CONFIG.ADDONTITLE, 'Please wait...')
    for base, dirs, files in os.walk(source):
        dirs[:] = [d for d in dirs]
        files[:] = [f for f in files]
        for file in files:
            prog.append(file)
            prog2 = int(len(prog) / float(items) * 100)
            progress_dialog.update(prog2, "[COLOR {0}]Checking for non ASCII files".format(CONFIG.COLOR2),
                          '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, file), 'Please Wait[/COLOR]')
            try:
                file.encode('ascii')
            except UnicodeEncodeError:
                logging.log("[ASCII Check] Illegal character found in file: {0}".format(file))
            except UnicodeDecodeError:
                logging.log("[ASCII Check] Illegal character found in file: {0}".format(file))
                badfile = os.path.join(base, file)
                if yes:
                    try:
                        os.remove(badfile)
                        for chunk in chunks(badfile, 75):
                            afiles.write(chunk+'\n')
                        afiles.write('\n')
                        f1 += 1
                        logging.log("[ASCII Check] File Removed: {0} ".format(badfile), level=xbmc.LOGERROR)
                    except:
                        for chunk in chunks(badfile, 75):
                            afails.write(chunk+'\n')
                        afails.write('\n')
                        f2 += 1
                        logging.log("[ASCII Check] File Failed: {0} ".format(badfile), level=xbmc.LOGERROR)
                else:
                    for chunk in chunks(badfile, 75):
                        afiles.write(chunk+'\n')
                    afiles.write('\n')
                    f1 += 1
                    logging.log("[ASCII Check] File Found: {0} ".format(badfile), level=xbmc.LOGERROR)
                pass
        if progress_dialog.iscanceled():
            progress_dialog.close()
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]ASCII Check Cancelled[/COLOR]".format(CONFIG.COLOR2))
            sys.exit()
    progress_dialog.close()
    afiles.close()
    afails.close()
    total = int(f1) + int(f2)
    if total > 0:
        if os.path.exists(files_found):
            msg = read_from_file(files_found)
        if os.path.exists(files_fails):
            msg2 = read_from_file(files_fails)
        if yes:
            if use:
                logging.log_notify(CONFIG.ADDONTITLE,
                                 "[COLOR {0}]ASCII Check: {1} Removed / {2} Failed.[/COLOR]".format(CONFIG.COLOR2, f1, f2))
            else:
                window.show_text_box("Viewing Removed ASCII Files",
                                  "[COLOR yellow][B]{0} Files Removed:[/B][/COLOR]\n {1}\n\n[COLOR yellow][B]{2} Files Failed:[B][/COLOR]\n {3}".format(f1, msg, f2, msg2))
        else:
            window.show_text_box("Viewing Found ASCII Files", "[COLOR yellow][B]{0} Files Found:[/B][/COLOR]\n {1}".format(f1, msg))
    else:
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]ASCII Check: None Found.[/COLOR]".format(CONFIG.COLOR2))
Пример #21
0
    def install(self, name):
                CONFIG.clear_setting('build')

                if CONFIG.get_setting('choicelink') == 'true':
                    buildzip = check.check_data(name,'url')
                elif CONFIG.get_setting('choicelink') == 'false':
                    buildzip = check.check_data(name,'url')
                zipname = name.replace('\\', '').replace('/', '').replace(':', '').replace('*', '').replace('?', '').replace('"', '').replace('<', '').replace('>', '').replace('|', '')

                self.dialogProgress.create(CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name) + '\n' + 'Please Wait')

                lib = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(zipname))
                
                try:
                    os.remove(lib)
                except:
                    pass

                Downloader().download(buildzip, lib)
                xbmc.sleep(500)
                
                if os.path.getsize(lib) == 0:
                    try:
                        os.remove(lib)
                    except:
                        pass
                        
                    return
                
                    
                # install.wipe()
                    
                # skin.look_and_feel_data('save')
                
                title = '[COLOR {0}][B]Installing:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version'))
                self.dialogProgress.update(0, title + '\n' + 'Please Wait')
                percent, errors, error = extract.all(lib, CONFIG.HOME, title=title)
                
                # skin.skin_to_default('Build Install')

                if int(float(percent)) > 0:
                    # db.fix_metas()
                    # CONFIG.set_setting('buildname', name)
                    # CONFIG.set_setting('buildversion', check.check_build(name, 'version'))
                    # CONFIG.set_setting('buildtheme', '')
                    # CONFIG.set_setting('latestversion', check.check_build(name, 'version'))
                    # CONFIG.set_setting('nextbuildcheck', tools.get_date(days=CONFIG.UPDATECHECK, formatted=True))
                    # CONFIG.set_setting('installed', 'true')
                    # CONFIG.set_setting('extract', percent)
                    # CONFIG.set_setting('errors', errors)
                    logging.log('INSTALLED {0}: [ERRORS:{1}]'.format(percent, errors))

                    try:
                        os.remove(lib)
                    except:
                        pass

                    if int(float(errors)) > 0:
                        yes_pressed = self.dialog.yesno(CONFIG.ADDONTITLE,
                                           '[COLOR {0}][COLOR {1}]{2} v{3}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1,
                                                                                           name, check.check_build(name, 'version')),
                                           'Completed: [COLOR {0}]{1}{2}[/COLOR] [Errors:[COLOR {3}]{4}[/COLOR]]'.format(
                                               CONFIG.COLOR1, percent, '%', CONFIG.COLOR1, errors),
                                           'Would you like to view the errors?[/COLOR]',
                                           nolabel='[B][COLOR red]No Thanks[/COLOR][/B]',
                                           yeslabel='[B][COLOR springgreen]View Errors[/COLOR][/B]')
                        if yes_pressed:
                            from resources.libs.gui import window
                            window.show_text_box("Viewing Build Install Errors", error)
                    self.dialogProgress.close()

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

                    # if themecount > 0:
                        # self.theme(name, 'theme')

                    # db.addon_database(CONFIG.ADDON_ID, 1)
                    # #db.force_check_updates(over=True)

                    self.dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]Khôi phục xong, nhấn OK và thưởng thức ^^[/COLOR]".format(CONFIG.COLOR2))
                    # tools.kill_kodi(over=True)
                else:
                    from resources.libs.gui import window
                    window.show_text_box("Viewing Build Install Errors", error)