def clear_thumbs(type=None):
    from resources.libs import db

    dialog = xbmcgui.Dialog()

    thumb_locations = {
        CONFIG.THUMBNAILS,
        os.path.join(CONFIG.ADDON_DATA, 'script.module.metadatautils',
                     'animatedgifs'),
        os.path.join(CONFIG.ADDON_DATA, 'script.extendedinfo', 'images')
    }

    latest = db.latest_db('Textures')
    if type is not None:
        choice = 1
    else:
        choice = dialog.yesno(
            CONFIG.ADDONTITLE,
            '[COLOR {0}]Would you like to delete the {1} and related thumbnail folders?'
            .format(CONFIG.COLOR2, latest) + '\n' +
            "They will repopulate on the next startup[/COLOR]",
            nolabel='[B][COLOR red]Don\'t Delete[/COLOR][/B]',
            yeslabel='[B][COLOR springgreen]Delete Thumbs[/COLOR][/B]')
    if choice == 1:
        try:
            tools.remove_file(os.path.join(CONFIG.DATABASE, latest))
        except:
            logging.log('Failed to delete, Purging DB.')
            db.purge_db_file(latest)
        for i in thumb_locations:
            tools.remove_folder(i)
    else:
        logging.log('Clear thumbnames cancelled')

    tools.redo_thumbs()
Esempio n. 2
0
def clear_thumbs(type=None):
    from resources.libs import db
    
    dialog = xbmcgui.Dialog()

    thumb_locations = {CONFIG.THUMBNAILS,
                       os.path.join(CONFIG.ADDON_DATA, 'script.module.metadatautils', 'animatedgifs'),
                       os.path.join(CONFIG.ADDON_DATA, 'script.extendedinfo', 'images')}

    latest = db.latest_db('Textures')
    if type is not None:
        choice = 1
    else:
        choice = dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]Le gustaria eliminar {1} y las carpetas de miniaturas relacionadas?'.format(CONFIG.COLOR2, latest) + '\n' + "Ellas se repoblarán en la próxima puesta en marcha.[/COLOR]", nolabel='[B][COLOR red]No Eliminar[/COLOR][/B]', yeslabel='[B][COLOR dodgerblue]Eliminar Pulgares[/COLOR][/B]')
    if choice == 1:
        try:
            tools.remove_file(os.path.join(CONFIG.DATABASE, latest))
        except:
            logging.log('Error al eliminar, Purgando DB.')
            db.purge_db_file(latest)
        for i in thumb_locations:
            tools.remove_folder(i)
    else:
        logging.log('Borrar nombres en miniatura cancelados')

    tools.redo_thumbs()
def clear_thumbs(type=None):
    from resources.libs import db
    
    dialog = xbmcgui.Dialog()

    thumb_locations = {CONFIG.THUMBNAILS,
                       os.path.join(CONFIG.ADDON_DATA, 'script.module.metadatautils', 'animatedgifs'),
                       os.path.join(CONFIG.ADDON_DATA, 'script.extendedinfo', 'images')}

    latest = db.latest_db('Textures')
    if type is not None:
        choice = 1
    else:
        choice = dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]Você gostaria de excluir o {1} e as pastas de miniaturas relacionadas?'.format(CONFIG.COLOR2, latest) + '\n' + "Eles irão repovoar na próxima inicialização[/COLOR]", nolabel='[B][COLOR red]Não apagar[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Apagar Thumbs[/COLOR][/B]')
    if choice == 1:
        try:
            tools.remove_file(os.path.join(CONFIG.DATABASE, latest))
        except:
            logging.log('Failed to delete, Purging DB.')
            db.purge_db_file(latest)
        for i in thumb_locations:
            tools.remove_folder(i)
    else:
        logging.log('Clear thumbnames cancelled')

    tools.redo_thumbs()
Esempio n. 4
0
def fix_metas():
    from resources.libs.common import tools

    idlist = []
    for item in idlist:
        fold = os.path.join(CONFIG.ADDOND, item)
        if os.path.exists(fold):
            storage = os.path.join(fold, '.storage')
            if os.path.exists(storage):
                tools.clean_house(storage)
                tools.remove_folder(storage)
Esempio n. 5
0
def import_save_data():
    dialog = xbmcgui.Dialog()

    TEMP = os.path.join(CONFIG.PLUGIN_DATA, 'temp')
    if not os.path.exists(TEMP):
        os.makedirs(TEMP)
    source = dialog.browse(
        1, '[COLOR {0}]Selecione a localização do SaveData.zip[/COLOR]'.format(
            CONFIG.COLOR2), 'files', '.zip', False, False, CONFIG.HOME)
    if not source.endswith('.zip'):
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Erro de importação de dados![/COLOR]".format(
                CONFIG.COLOR2))
        return
    source = xbmcvfs.translatePath(source)
    tempfile = xbmcvfs.translatePath(
        os.path.join(CONFIG.MYBUILDS, 'SaveData.zip'))
    if not tempfile == source:
        goto = xbmcvfs.copy(source, tempfile)

    from resources.libs import extract
    if not extract.all(xbmcvfs.translatePath(tempfile), TEMP):
        logging.log("Erro ao tentar extrair o arquivo zip!")
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Erro de importação de dados![/COLOR]".format(
                CONFIG.COLOR2))
        return

    trakt = os.path.join(TEMP, 'trakt')
    login = os.path.join(TEMP, 'login')
    debrid = os.path.join(TEMP, 'debrid')
    super = os.path.join(TEMP, 'plugin.program.super.favourites')
    xmls = os.path.join(TEMP, 'xmls')

    x = 0
    overwrite = dialog.yesno(
        CONFIG.ADDONTITLE,
        "[COLOR {0}]Você prefere que substituamos todos os arquivos de dados salvos ou solicitemos cada arquivo que está sendo importado?[/COLOR]"
        .format(CONFIG.COLOR2),
        yeslabel="[B][COLOR springgreen]Sobrescreva tudo[/COLOR][/B]",
        nolabel="[B][COLOR red]Não pergunte[/COLOR][/B]")

    if os.path.exists(trakt):
        from resources.libs import traktit

        x += 1
        files = os.listdir(trakt)
        if not os.path.exists(CONFIG.TRAKTFOLD):
            os.makedirs(CONFIG.TRAKTFOLD)
        for item in files:
            old = os.path.join(CONFIG.TRAKTFOLD, item)
            temp = os.path.join(trakt, item)
            if os.path.exists(old):
                if overwrite == 1:
                    os.remove(old)
                else:
                    if not dialog.yesno(
                            CONFIG.ADDONTITLE,
                            "[COLOR {0}]Você gostaria de substituir o atual [COLOR {1}]{2}[/COLOR] file?"
                            .format(CONFIG.COLOR2, CONFIG.COLOR1, item),
                            yeslabel=
                            "[B][COLOR springgreen]Sim Substituir[/COLOR][/B]",
                            nolabel="[B][COLOR red]Não, pular[/COLOR][/B]"):
                        continue
                    else:
                        os.remove(old)
            shutil.copy(temp, old)
        traktit.import_list('all')
        traktit.trakt_it('restore', 'all')
    if os.path.exists(login):
        from resources.libs import loginit

        x += 1
        files = os.listdir(login)
        if not os.path.exists(CONFIG.LOGINFOLD):
            os.makedirs(CONFIG.LOGINFOLD)
        for item in files:
            old = os.path.join(CONFIG.LOGINFOLD, item)
            temp = os.path.join(login, item)
            if os.path.exists(old):
                if overwrite == 1:
                    os.remove(old)
                else:
                    if not dialog.yesno(
                            CONFIG.ADDONTITLE,
                            "[COLOR {0}]Você gostaria de substituir o atual [COLOR {1}]{2}[/COLOR] arquivo?"
                            .format(CONFIG.COLOR2, CONFIG.COLOR1, item),
                            yeslabel=
                            "[B][COLOR springgreen]Sim Substituir[/COLOR][/B]",
                            nolabel="[B][COLOR red]Não, pular[/COLOR][/B]"):
                        continue
                    else:
                        os.remove(old)
            shutil.copy(temp, old)
        loginit.import_list('all')
        loginit.login_it('restore', 'all')

    if os.path.exists(debrid):
        from resources.libs import debridit

        x += 1
        files = os.listdir(debrid)
        if not os.path.exists(CONFIG.DEBRIDFOLD):
            os.makedirs(CONFIG.DEBRIDFOLD)
        for item in files:
            old = os.path.join(CONFIG.DEBRIDFOLD, item)
            temp = os.path.join(debrid, item)
            if os.path.exists(old):
                if overwrite == 1:
                    os.remove(old)
                else:
                    if not dialog.yesno(
                            CONFIG.ADDONTITLE,
                            "[COLOR {0}]Você gostaria de substituir o atual [COLOR {1}]{2}[/COLOR] arquivo?"
                            .format(CONFIG.COLOR2, CONFIG.COLOR1, item),
                            yeslabel=
                            "[B][COLOR springgreen]Sim Trocar[/COLOR][/B]",
                            nolabel="[B][COLOR red]Não, pular[/COLOR][/B]"):
                        continue
                    else:
                        os.remove(old)
            shutil.copy(temp, old)
        debridit.import_list('all')
        debridit.debrid_it('restore', 'all')
    if os.path.exists(xmls):
        x += 1
        for item in CONFIG.XMLS:
            old = os.path.join(CONFIG.USERDATA, item)
            new = os.path.join(xmls, item)
            if not os.path.exists(new): continue
            if os.path.exists(old):
                if not overwrite == 1:
                    if not dialog.yesno(
                            CONFIG.ADDONTITLE,
                            "[COLOR {0}]Você gostaria de substituir o atual [COLOR {1}]{2}[/COLOR] arquivo?"
                            .format(CONFIG.COLOR2, CONFIG.COLOR1, item),
                            yeslabel=
                            "[B][COLOR springgreen]Sim Trocar[/COLOR][/B]",
                            nolabel="[B][COLOR red]Não, pular[/COLOR][/B]"):
                        continue
            os.remove(old)
            shutil.copy(new, old)
    if os.path.exists(super):
        x += 1
        old = os.path.join(CONFIG.ADDON_DATA,
                           'plugin.program.super.favourites')
        if os.path.exists(old):
            cont = dialog.yesno(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Você gostaria de substituir o atual [COLOR {1}]Super Favourites[/COLOR] addon_data pasta com a nova?"
                .format(CONFIG.COLOR2, CONFIG.COLOR1),
                yeslabel="[B][COLOR springgreen]Sim Trocar[/COLOR][/B]",
                nolabel="[B][COLOR red]Não, pular[/COLOR][/B]")
        else:
            cont = 1
        if cont == 1:
            tools.clean_house(old)
            tools.remove_folder(old)
            xbmcvfs.copy(super, old)
    tools.clean_house(TEMP)
    tools.remove_folder(TEMP)
    if not tempfile == source:
        xbmcvfs.delete(tempfile)
    if x == 0:
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Save Data Import Failed[/COLOR]".format(CONFIG.COLOR2))
    else:
        logging.log_notify(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Save Data Import Complete[/COLOR]".format(
                CONFIG.COLOR2))
def import_save_data():
    dialog = xbmcgui.Dialog()

    TEMP = os.path.join(CONFIG.PLUGIN_DATA, 'temp')
    if not os.path.exists(TEMP):
        os.makedirs(TEMP)
    source = dialog.browse(1, '[COLOR {0}]Select the location of the SaveData.zip[/COLOR]'.format(CONFIG.COLOR2),
                               'files', '.zip', False, False, CONFIG.HOME)
    if not source.endswith('.zip'):
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]Import Data Error![/COLOR]".format(CONFIG.COLOR2))
        return
    source = xbmc.translatePath(source)
    tempfile = xbmc.translatePath(os.path.join(CONFIG.MYBUILDS, 'SaveData.zip'))
    if not tempfile == source:
        goto = xbmcvfs.copy(source, tempfile)

    from resources.libs import extract
    if not extract.all(xbmc.translatePath(tempfile), TEMP):
        logging.log("Error trying to extract the zip file!")
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]Import Data Error![/COLOR]".format(CONFIG.COLOR2))
        return

    trakt = os.path.join(TEMP, 'trakt')
    login = os.path.join(TEMP, 'login')
    debrid = os.path.join(TEMP, 'debrid')
    super = os.path.join(TEMP, 'plugin.program.super.favourites')
    xmls = os.path.join(TEMP, 'xmls')

    x = 0
    overwrite = dialog.yesno(CONFIG.ADDONTITLE,
                                 "[COLOR {0}]Would you rather we overwrite all Save Data files or ask you for each file being imported?[/COLOR]".format(CONFIG.COLOR2),
                                 yeslabel="[B][COLOR springgreen]Overwrite All[/COLOR][/B]",
                                 nolabel="[B][COLOR red]No Ask[/COLOR][/B]")
    
    if os.path.exists(trakt):
        from resources.libs import traktit

        x += 1
        files = os.listdir(trakt)
        if not os.path.exists(CONFIG.TRAKTFOLD):
            os.makedirs(CONFIG.TRAKTFOLD)
        for item in files:
            old = os.path.join(CONFIG.TRAKTFOLD, item)
            temp = os.path.join(trakt, item)
            if os.path.exists(old):
                if overwrite == 1:
                    os.remove(old)
                else:
                    if not dialog.yesno(CONFIG.ADDONTITLE,
                                            "[COLOR {0}]Would you like replace the current [COLOR {1}]{2}[/COLOR] file?".format(CONFIG.COLOR2, CONFIG.COLOR1, item),
                                            yeslabel="[B][COLOR springgreen]Yes Replace[/COLOR][/B]",
                                            nolabel="[B][COLOR red]No Skip[/COLOR][/B]"):
                        continue
                    else:
                        os.remove(old)
            shutil.copy(temp, old)
        traktit.import_list('all')
        traktit.trakt_it('restore', 'all')
    if os.path.exists(login):
        from resources.libs import loginit

        x += 1
        files = os.listdir(login)
        if not os.path.exists(CONFIG.LOGINFOLD):
            os.makedirs(CONFIG.LOGINFOLD)
        for item in files:
            old = os.path.join(CONFIG.LOGINFOLD, item)
            temp = os.path.join(login, item)
            if os.path.exists(old):
                if overwrite == 1:
                    os.remove(old)
                else:
                    if not dialog.yesno(CONFIG.ADDONTITLE,
                                            "[COLOR {0}]Would you like replace the current [COLOR {1}]{2}[/COLOR] file?".format(CONFIG.COLOR2, CONFIG.COLOR1, item),
                                            yeslabel="[B][COLOR springgreen]Yes Replace[/COLOR][/B]",
                                            nolabel="[B][COLOR red]No Skip[/COLOR][/B]"):
                        continue
                    else:
                        os.remove(old)
            shutil.copy(temp, old)
        loginit.import_list('all')
        loginit.login_it('restore', 'all')
    
    if os.path.exists(debrid):
        from resources.libs import debridit

        x += 1
        files = os.listdir(debrid)
        if not os.path.exists(CONFIG.DEBRIDFOLD):
            os.makedirs(CONFIG.DEBRIDFOLD)
        for item in files:
            old = os.path.join(CONFIG.DEBRIDFOLD, item)
            temp = os.path.join(debrid, item)
            if os.path.exists(old):
                if overwrite == 1:
                    os.remove(old)
                else:
                    if not dialog.yesno(CONFIG.ADDONTITLE,
                                            "[COLOR {0}]Would you like replace the current [COLOR {1}]{2}[/COLOR] file?".format(CONFIG.COLOR2, CONFIG.COLOR1, item),
                                            yeslabel="[B][COLOR springgreen]Yes Replace[/COLOR][/B]",
                                            nolabel="[B][COLOR red]No Skip[/COLOR][/B]"):
                        continue
                    else:
                        os.remove(old)
            shutil.copy(temp, old)
        debridit.import_list('all')
        debridit.debrid_it('restore', 'all')
    if os.path.exists(xmls):
        x += 1
        for item in CONFIG.XMLS:
            old = os.path.join(CONFIG.USERDATA, item)
            new = os.path.join(xmls, item)
            if not os.path.exists(new): continue
            if os.path.exists(old):
                if not overwrite == 1:
                    if not dialog.yesno(CONFIG.ADDONTITLE,
                                            "[COLOR {0}]Would you like replace the current [COLOR {1}]{2}[/COLOR] file?".format(CONFIG.COLOR2, CONFIG.COLOR1, item),
                                            yeslabel="[B][COLOR springgreen]Yes Replace[/COLOR][/B]",
                                            nolabel="[B][COLOR red]No Skip[/COLOR][/B]"):
                        continue
            os.remove(old)
            shutil.copy(new, old)
    if os.path.exists(super):
        x += 1
        old = os.path.join(CONFIG.ADDON_DATA, 'plugin.program.super.favourites')
        if os.path.exists(old):
            cont = dialog.yesno(CONFIG.ADDONTITLE,
                                    "[COLOR {0}]Would you like replace the current [COLOR {1}]Super Favourites[/COLOR] addon_data folder with the new one?".format(CONFIG.COLOR2, CONFIG.COLOR1),
                                    yeslabel="[B][COLOR springgreen]Yes Replace[/COLOR][/B]",
                                    nolabel="[B][COLOR red]No Skip[/COLOR][/B]")
        else:
            cont = 1
        if cont == 1:
            tools.clean_house(old)
            tools.remove_folder(old)
            xbmcvfs.copy(super, old)
    tools.clean_house(TEMP)
    tools.remove_folder(TEMP)
    if not tempfile == source:
        xbmcvfs.delete(tempfile)
    if x == 0:
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]Save Data Import Failed[/COLOR]".format(CONFIG.COLOR2))
    else:
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]Save Data Import Complete[/COLOR]".format(CONFIG.COLOR2))
Esempio n. 7
0
def install_addon(plugin, url):
    from resources.libs.common import logging
    from resources.libs.common import tools

    if tools.open_url(CONFIG.ADDONFILE, check=True):
        from resources.libs import clear
        from resources.libs import db
        from resources.libs import extract
        from resources.libs import skin

        dialog = xbmcgui.Dialog()

        if url is None:
            url = CONFIG.ADDONFILE

        response = tools.open_url(url)

        if response:
            link = response.text.replace('\n', '').replace('\r', '').replace(
                '\t',
                '').replace('repository=""', 'repository="none"').replace(
                    'repositoryurl=""', 'repositoryurl="http://"').replace(
                        'repositoryxml=""', 'repositoryxml="http://"')
            match = re.compile(
                'name="(.+?)".+?lugin="%s".+?rl="(.+?)".+?epository="(.+?)".+?epositoryxml="(.+?)".+?epositoryurl="(.+?)".+?con="(.+?)".+?anart="(.+?)".+?dult="(.+?)".+?escription="(.+?)"'
                % plugin).findall(link)
            if len(match) > 0:
                for name, url, repository, repositoryxml, repositoryurl, icon, fanart, adult, description in match:
                    if os.path.exists(os.path.join(CONFIG.ADDONS, plugin)):
                        do = ['Launch Addon', 'Remove Addon']
                        selected = dialog.select(
                            "[COLOR {0}]Addon already installed what would you like to do?[/COLOR]"
                            .format(CONFIG.COLOR2), do)
                        if selected == 0:
                            xbmc.executebuiltin(
                                'InstallAddon({0})'.format(plugin))
                            xbmc.sleep(500)
                            return True
                        elif selected == 1:
                            tools.clean_house(
                                os.path.join(CONFIG.ADDONS, plugin))
                            try:
                                tools.remove_folder(
                                    os.path.join(CONFIG.ADDONS, plugin))
                            except:
                                pass
                            if dialog.yesno(
                                    CONFIG.ADDONTITLE,
                                    "[COLOR {0}]Would you like to remove the addon_data for:"
                                    .format(CONFIG.COLOR2),
                                    "[COLOR {0}]{1}[/COLOR]?[/COLOR]".format(
                                        CONFIG.COLOR1, plugin),
                                    yeslabel=
                                    "[B][COLOR springgreen]Yes Remove[/COLOR][/B]",
                                    nolabel="[B][COLOR red]No Skip[/COLOR][/B]"
                            ):
                                clear.remove_addon_data(plugin)
                            xbmc.executebuiltin('Container.Refresh()')
                            return True
                        else:
                            return False
                    repo = os.path.join(CONFIG.ADDONS, repository)
                    if repository.lower() != 'none' and not os.path.exists(
                            repo):
                        logging.log("Repository not installed, installing it")
                        if dialog.yesno(
                                CONFIG.ADDONTITLE,
                                "[COLOR {0}]Would you like to install the repository for [COLOR {1}]{2}[/COLOR]: "
                                .format(CONFIG.COLOR2, CONFIG.COLOR1, plugin),
                                "[COLOR {0}]{1}[/COLOR]?[/COLOR]".format(
                                    CONFIG.COLOR1, repository),
                                yeslabel=
                                "[B][COLOR springgreen]Yes Install[/COLOR][/B]",
                                nolabel="[B][COLOR red]No Skip[/COLOR][/B]"):
                            ver = tools.parse_dom(
                                tools.open_url(repositoryxml).text,
                                'addon',
                                ret='version',
                                attrs={'id': repository})
                            if len(ver) > 0:
                                repozip = '{0}{1}-{2}.zip'.format(
                                    repositoryurl, repository, ver[0])
                                logging.log(repozip)
                                db.addon_database(repository, 1)
                                install_addon(repository, repozip)
                                xbmc.executebuiltin('UpdateAddonRepos()')
                                logging.log("Installing Addon from Kodi")
                                install = install_from_kodi(plugin)
                                logging.log(
                                    "Install from Kodi: {0}".format(install))
                                if install:
                                    xbmc.executebuiltin('Container.Refresh()')
                                    return True
                            else:
                                logging.log(
                                    "[Addon Installer] Repository not installed: Unable to grab url! ({0})"
                                    .format(repository))
                        else:
                            logging.log(
                                "[Addon Installer] Repository for {0} not installed: {1}"
                                .format(plugin, repository))
                    elif repository.lower() == 'none':
                        logging.log("No repository, installing addon")
                        pluginid = plugin
                        zipurl = url
                        install_addon_from_url(plugin, url)
                        xbmc.executebuiltin('Container.Refresh()')
                        return True
                    else:
                        logging.log("Repository installed, installing addon")
                        install = install_from_kodi(plugin)
                        if install:
                            xbmc.executebuiltin('Container.Refresh()')
                            return True
                    if os.path.exists(os.path.join(CONFIG.ADDONS, plugin)):
                        return True
                    ver2 = tools.parse_dom(tools.open_url(repositoryxml),
                                           'addon',
                                           ret='version',
                                           attrs={'id': plugin})
                    if len(ver2) > 0:
                        url = "{0}{1}-{2}.zip".format(url, plugin, ver2[0])
                        logging.log(str(url))
                        db.addon_database(plugin, 1)
                        install_addon_from_url(plugin, url)
                        xbmc.executebuiltin('Container.Refresh()')
                    else:
                        logging.log("no match")
                        return False
            else:
                logging.log("[Addon Installer] Invalid Format")
        else:
            logging.log("[Addon Installer] Text File: {0}".format(
                CONFIG.ADDONFILE))
    else:
        logging.log("[Addon Installer] Not Enabled.")