コード例 #1
0
def reload_fix(default=None):
    from resources.libs import db
    from resources.libs.common import logging
    from resources.libs import skin
    from resources.libs import update

    dialog = xbmcgui.Dialog()

    dialog.ok(
        CONFIG.ADDONTITLE,
        "[COLOR red]ADVERTENCIA:[/COLOR] [COLOR {0}] A veces, Recargando el Perfil hace que Kodi se bloquee. Mientras Kodi está Recargando el Perfil, Por Favor No Presione Ningún Botón![/COLOR]"
        .format(CONFIG.COLOR2))

    if not os.path.exists(CONFIG.PACKAGES):
        os.makedirs(CONFIG.PACKAGES)
    if default is None:
        skin.look_and_feel_data('save')
    redo_thumbs()
    xbmc.executebuiltin('ActivateWindow(Home)')
    reload_profile()
    xbmc.sleep(10000)
    if CONFIG.KODIV >= 17:
        db.kodi_17_fix()
    if default is None:
        logging.log("Switching to: {0}".format(
            CONFIG.get_setting('defaultskin')))
        gotoskin = CONFIG.get_setting('defaultskin')
        skin.switch_to_skin(gotoskin)
        skin.look_and_feel_data('restore')
    update.addon_updates('reset')
    update.force_update()
    xbmc.executebuiltin("ReloadSkin()")
コード例 #2
0
def reload_fix(default=None):
    from resources.libs import db
    from resources.libs.common import logging
    from resources.libs import skin
    from resources.libs import update

    dialog = xbmcgui.Dialog()
    
    dialog.ok(CONFIG.ADDONTITLE,
                  "[COLOR {0}]WARNING: Sometimes Reloading the Profile causes Kodi to crash. While Kodi is Reloading the Profile Please Do Not Press Any Buttons![/COLOR]".format(CONFIG.COLOR2))
                  
    if not os.path.exists(CONFIG.PACKAGES):
        os.makedirs(CONFIG.PACKAGES)
    if default is None:
        skin.look_and_feel_data('save')
    redo_thumbs()
    xbmc.executebuiltin('ActivateWindow(Home)')
    reload_profile()
    xbmc.sleep(10000)
    if CONFIG.KODIV >= 17:
        db.kodi_17_fix()
    if default is None:
        logging.log("Switching to: {0}".format(CONFIG.get_setting('defaultskin')))
        gotoskin = CONFIG.get_setting('defaultskin')
        skin.switch_to_skin(gotoskin)
        skin.look_and_feel_data('restore')
    update.addon_updates('reset')
    update.force_update()
    xbmc.executebuiltin("ReloadSkin()")
コード例 #3
0
def reload_fix(default=None):
    from resources.libs import db
    from resources.libs.common import logging
    from resources.libs import skin
    from resources.libs import update

    dialog = xbmcgui.Dialog()

    dialog.ok(
        CONFIG.ADDONTITLE,
        "[COLOR {0}]AVISO: Às vezes, recarregar o perfil causa o travamento do Kodi. Enquanto Kodi estiver recarregando o perfil, não pressione nenhum botão![/COLOR]"
        .format(CONFIG.COLOR2))

    if not os.path.exists(CONFIG.PACKAGES):
        os.makedirs(CONFIG.PACKAGES)
    if default is None:
        skin.look_and_feel_data('save')
    redo_thumbs()
    xbmc.executebuiltin('ActivateWindow(Home)')
    reload_profile()
    xbmc.sleep(10000)
    if CONFIG.KODIV >= 17:
        db.kodi_17_fix()
    if default is None:
        logging.log("Switching to: {0}".format(
            CONFIG.get_setting('defaultskin')))
        gotoskin = CONFIG.get_setting('defaultskin')
        skin.switch_to_skin(gotoskin)
        skin.look_and_feel_data('restore')
    update.addon_updates('reset')
    update.force_update()
    xbmc.executebuiltin("ReloadSkin()")
コード例 #4
0
def fresh_start(install=None, over=False):
    from resources.libs.common import logging
    from resources.libs.common import tools

    dialog = xbmcgui.Dialog()
    
    # if CONFIG.KEEPTRAKT == 'true':
        # from resources.libs import traktit

        # traktit.auto_update('all')
        # CONFIG.set_setting('traktnextsave', str(tools.get_date(days=3, formatted=True)))
    # if CONFIG.KEEPDEBRID == 'true':
        # from resources.libs import debridit

        # debridit.auto_update('all')
        # CONFIG.set_setting('debridnextsave', str(tools.get_date(days=3, formatted=True)))
    # if CONFIG.KEEPLOGIN == 'true':
        # from resources.libs import loginit

        # loginit.auto_update('all')
        # CONFIG.set_setting('loginnextsave', str(tools.get_date(days=3, formatted=True)))

    if over:
        yes_pressed = 1

    elif install == 'restore':
        yes_pressed = dialog.yesno(CONFIG.ADDONTITLE,
                                       "Bạn có muốn khôi phục Kodi về mặc định.",
                                       "Trước khi cài đặt bản Build cá nhân?[/COLOR]",
                                       nolabel='[B][COLOR red]Không![/COLOR][/B]',
                                       yeslabel='[B][COLOR springgreen]Tiếp Tục![/COLOR][/B]')
    elif install:
        yes_pressed = dialog.yesno(CONFIG.ADDONTITLE, "Bạn có muốn khôi phục Kodi về mặc định.",
                                       "Trước khi cài đặt [COLOR {0}]{1}[/COLOR]?".format(CONFIG.COLOR1, install),
                                       nolabel='[B][COLOR red]Không![/COLOR][/B]',
                                       yeslabel='[B][COLOR springgreen]Tiếp Tục[/COLOR][/B]')
    else:
        yes_pressed = dialog.yesno(CONFIG.ADDONTITLE, "Bạn có muốn khôi phục Kodi về mặc định.", nolabel='[B][COLOR red]Không![/COLOR][/B]', yeslabel='[B][COLOR springgreen]Tiếp Tục![/COLOR][/B]')
    if yes_pressed:
        wipe()
        
        if over:
            return True
        elif install == 'restore':
            return True
        elif install:
            from resources.libs.wizard import Wizard

            Wizard().build('normal', install, over=True)
        else:
            dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]Để thay đổi có hiệu lực cần thoát hẳn KODI.\nNhấn OK để thoát Kodi[/COLOR]".format(CONFIG.COLOR2))
            from resources.libs import update
            update.addon_updates('reset')
            tools.kill_kodi(over=True)
    else:
        if not install == 'restore':
            logging.log_notify(CONFIG.ADDONTITLE,
                               '[COLOR {0}]Fresh Install: Cancelled![/COLOR]'.format(CONFIG.COLOR2))
            xbmc.executebuiltin('Container.Refresh()')
コード例 #5
0
ファイル: clear.py プロジェクト: m0rpheas/m0rpheas.github.io
def remove_addon_menu():
    from resources.libs.common import logging
    from resources.libs.common import tools
    from resources.libs import update
    
    from xml.etree import ElementTree
    
    dialog = xbmcgui.Dialog()

    addonfolders = glob.iglob(os.path.join(CONFIG.ADDONS, '*/'))
    addonnames = []
    addonids = []
    
    for folder in addonfolders:
        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):
            root = ElementTree.parse(xml).getroot()
            addonid = root.get('id')
            addonname = root.get('name')
            
            try:
                addonnames.append(addonname)
                addonids.append(addonid)
            except:
                pass
                
    if len(addonnames) == 0:
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]No Addons To Remove[/COLOR]".format(CONFIG.COLOR2))
        return
    selected = dialog.multiselect("{0}: Select the addons you wish to remove.".format(CONFIG.ADDONTITLE), addonnames)
    if not selected:
        return
    if len(selected) > 0:
        update.addon_updates('set')
        for addon in selected:
            remove_addon(addon=addonids[addon], name=addonnames[addon], over=True)

        xbmc.sleep(500)

        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))
        
        update.addon_updates('reset')
        tools.kill_kodi(over=True)
コード例 #6
0
def remove_addon_menu():
    from resources.libs.common import logging
    from resources.libs.common import tools
    from resources.libs import update
    
    from xml.etree import ElementTree
    
    dialog = xbmcgui.Dialog()

    addonfolders = glob.iglob(os.path.join(CONFIG.ADDONS, '*/'))
    addonnames = []
    addonids = []
    
    for folder in addonfolders:
        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):
            root = ElementTree.parse(xml).getroot()
            addonid = root.get('id')
            addonname = root.get('name')
            
            try:
                addonnames.append(addonname)
                addonids.append(addonid)
            except:
                pass
                
    if len(addonnames) == 0:
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]No hay complementos para eliminar[/COLOR]".format(CONFIG.COLOR2))
        return
    selected = dialog.multiselect("{0}: Seleccione los complementos que desea eliminar.".format(CONFIG.ADDONTITLE), addonnames)
    if not selected:
        return
    if len(selected) > 0:
        update.addon_updates('set')
        for addon in selected:
            remove_addon(addon=addonids[addon], name=addonnames[addon], over=True)

        xbmc.sleep(500)

        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))
        
        update.addon_updates('reset')
        tools.kill_kodi(over=True)
コード例 #7
0
def wipe():
    from resources.libs import db
    from resources.libs.common import logging
    from resources.libs import skin
    from resources.libs.common import tools
    from resources.libs import update

    if CONFIG.KEEPTRAKT == 'true':
        from resources.libs import traktit

        traktit.auto_update('all')
        CONFIG.set_setting('traktnextsave', str(tools.get_date(days=3, formatted=True)))
    if CONFIG.KEEPDEBRID == 'true':
        from resources.libs import debridit

        debridit.auto_update('all')
        CONFIG.set_setting('debridnextsave', str(tools.get_date(days=3, formatted=True)))
    if CONFIG.KEEPLOGIN == 'true':
        from resources.libs import loginit

        loginit.auto_update('all')
        CONFIG.set_setting('loginnextsave', str(tools.get_date(days=3, formatted=True)))

    exclude_dirs = CONFIG.EXCLUDES
    exclude_dirs.append('My_Builds')
    
    progress_dialog = xbmcgui.DialogProgress()
    
    skin.skin_to_default('Fresh Install')
    
    update.addon_updates('set')
    xbmcPath = os.path.abspath(CONFIG.HOME)
    progress_dialog.create(CONFIG.ADDONTITLE, "[COLOR {0}]Calculating files and folders".format(CONFIG.COLOR2) + '\n' + '\n' + 'Please Wait![/COLOR]')
    total_files = sum([len(files) for r, d, files in os.walk(xbmcPath)])
    del_file = 0
    progress_dialog.update(0, "[COLOR {0}]Gathering Excludes list.[/COLOR]".format(CONFIG.COLOR2))
    if CONFIG.KEEPREPOS == 'true':
        repos = glob.glob(os.path.join(CONFIG.ADDONS, 'repo*/'))
        for item in repos:
            repofolder = os.path.split(item[:-1])[1]
            if not repofolder == exclude_dirs:
                exclude_dirs.append(repofolder)
    if CONFIG.KEEPSUPER == 'true':
        exclude_dirs.append('plugin.program.super.favourites')
    if CONFIG.KEEPWHITELIST == 'true':
        from resources.libs import whitelist
        
        whitelist = whitelist.whitelist('read')
        if len(whitelist) > 0:
            for item in whitelist:
                try:
                    name, id, fold = item
                except:
                    pass

                depends = db.depends_list(fold)
                for plug in depends:
                    if plug not in exclude_dirs:
                        exclude_dirs.append(plug)
                    depends2 = db.depends_list(plug)
                    for plug2 in depends2:
                        if plug2 not in exclude_dirs:
                            exclude_dirs.append(plug2)
                if fold not in exclude_dirs:
                    exclude_dirs.append(fold)

    for item in CONFIG.DEPENDENCIES:
        exclude_dirs.append(item)

    progress_dialog.update(0, "[COLOR {0}]Clearing out files and folders:".format(CONFIG.COLOR2))
    latestAddonDB = db.latest_db('Addons')
    for root, dirs, files in os.walk(xbmcPath, topdown=True):
        dirs[:] = [d for d in dirs if d not in exclude_dirs]
        for name in files:
            del_file += 1
            fold = root.replace('/', '\\').split('\\')
            x = len(fold)-1
            if name == 'sources.xml' and fold[-1] == 'userdata' and CONFIG.KEEPSOURCES == 'true':
                logging.log("Keep sources.xml: {0}".format(os.path.join(root, name)))
            elif name == 'favourites.xml' and fold[-1] == 'userdata' and CONFIG.KEEPFAVS == 'true':
                logging.log("Keep favourites.xml: {0}".format(os.path.join(root, name)))
            elif name == 'profiles.xml' and fold[-1] == 'userdata' and CONFIG.KEEPPROFILES == 'true':
                logging.log("Keep profiles.xml: {0}".format(os.path.join(root, name)))
            elif name == 'playercorefactory.xml' and fold[-1] == 'userdata' and CONFIG.KEEPPLAYERCORE == 'true':
                logging.log("Keep playercorefactory.xml: {0}".format(os.path.join(root, name)))
            elif name == 'guisettings.xml' and fold[-1] == 'userdata' and CONFIG.KEEPGUISETTINGS == 'true':
                logging.log("Keep guisettings.xml: {0}".format(os.path.join(root, name)))
            elif name == 'advancedsettings.xml' and fold[-1] == 'userdata' and CONFIG.KEEPADVANCED == 'true':
                logging.log("Keep advancedsettings.xml: {0}".format(os.path.join(root, name)))
            elif name in CONFIG.LOGFILES:
                logging.log("Keep Log File: {0}".format(name))
            elif name.endswith('.db'):
                try:
                    if name == latestAddonDB:
                        logging.log("Ignoring {0} on Kodi {1}".format(name, tools.kodi_version()))
                    else:
                        os.remove(os.path.join(root, name))
                except Exception as e:
                    if not name.startswith('Textures13'):
                        logging.log('Failed to delete, Purging DB')
                        logging.log("-> {0}".format(str(e)))
                        db.purge_db_file(os.path.join(root, name))
            else:
                progress_dialog.update(int(tools.percentage(del_file, total_files)), '\n' + '[COLOR {0}]File: [/COLOR][COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name))
                try:
                    os.remove(os.path.join(root, name))
                except Exception as e:
                    logging.log("Error removing {0}".format(os.path.join(root, name)))
                    logging.log("-> / {0}".format(str(e)))
        if progress_dialog.iscanceled():
            progress_dialog.close()
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]Fresh Start Cancelled[/COLOR]".format(CONFIG.COLOR2))
            return False
    for root, dirs, files in os.walk(xbmcPath, topdown=True):
        dirs[:] = [d for d in dirs if d not in exclude_dirs]
        for name in dirs:
            progress_dialog.update(100, '\n' + 'Cleaning Up Empty Folder: [COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, name))
            if name not in ["Database", "userdata", "temp", "addons", "addon_data"]:
                shutil.rmtree(os.path.join(root, name), ignore_errors=True, onerror=None)
        if progress_dialog.iscanceled():
            progress_dialog.close()
            logging.log_notify(CONFIG.ADDONTITLE,
                               "[COLOR {0}]Fresh Start Cancelled[/COLOR]".format(CONFIG.COLOR2))
            return False
            
    progress_dialog.close()
    CONFIG.clear_setting('build')
コード例 #8
0
def fresh_start(install=None, over=False):
    from resources.libs.common import logging
    from resources.libs.common import tools

    dialog = xbmcgui.Dialog()

    if CONFIG.KEEPTRAKT == 'true':
        from resources.libs import traktit

        traktit.auto_update('all')
        CONFIG.set_setting('traktnextsave',
                           str(tools.get_date(days=3, formatted=True)))
    if CONFIG.KEEPDEBRID == 'true':
        from resources.libs import debridit

        debridit.auto_update('all')
        CONFIG.set_setting('debridnextsave',
                           str(tools.get_date(days=3, formatted=True)))
    if CONFIG.KEEPLOGIN == 'true':
        from resources.libs import loginit

        loginit.auto_update('all')
        CONFIG.set_setting('loginnextsave',
                           str(tools.get_date(days=3, formatted=True)))

    if over:
        yes_pressed = 1

    elif install == 'restore':
        yes_pressed = dialog.yesno(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Do you wish to restore your".format(CONFIG.COLOR2),
            "Kodi configuration to default settings",
            "Before installing the local backup?[/COLOR]",
            nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]',
            yeslabel='[B][COLOR springgreen]Continue[/COLOR][/B]')
    elif install:
        yes_pressed = dialog.yesno(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Do you wish to restore your".format(CONFIG.COLOR2),
            "Kodi configuration to default settings",
            "Before installing [COLOR {0}]{1}[/COLOR]?".format(
                CONFIG.COLOR1, install),
            nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]',
            yeslabel='[B][COLOR springgreen]Continue[/COLOR][/B]')
    else:
        yes_pressed = dialog.yesno(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Do you wish to restore your".format(CONFIG.COLOR2),
            "Kodi configuration to default settings?[/COLOR]",
            nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]',
            yeslabel='[B][COLOR springgreen]Continue[/COLOR][/B]')
    if yes_pressed:
        wipe()

        if over:
            return True
        elif install == 'restore':
            return True
        elif install:
            from resources.libs.wizard import Wizard

            Wizard().build('normal', install, over=True)
        else:
            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))
            from resources.libs import update
            update.addon_updates('reset')
            tools.kill_kodi(over=True)
    else:
        if not install == 'restore':
            logging.log_notify(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Fresh Install: Cancelled![/COLOR]'.format(
                    CONFIG.COLOR2))
            xbmc.executebuiltin('Container.Refresh()')
コード例 #9
0
def fresh_start(install=None, over=False):
    from resources.libs.common import logging
    from resources.libs.common import tools

    dialog = xbmcgui.Dialog()

    if CONFIG.KEEPTRAKT == 'true':
        from resources.libs import traktit

        traktit.auto_update('all')
        CONFIG.set_setting('traktnextsave',
                           str(tools.get_date(days=3, formatted=True)))
    if CONFIG.KEEPDEBRID == 'true':
        from resources.libs import debridit

        debridit.auto_update('all')
        CONFIG.set_setting('debridnextsave',
                           str(tools.get_date(days=3, formatted=True)))
    if CONFIG.KEEPLOGIN == 'true':
        from resources.libs import loginit

        loginit.auto_update('all')
        CONFIG.set_setting('loginnextsave',
                           str(tools.get_date(days=3, formatted=True)))

    if over:
        yes_pressed = 1

    elif install == 'restore':
        yes_pressed = dialog.yesno(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Desea restaurar su".format(CONFIG.COLOR2) + '\n' +
            "Configuración de Kodi a la configuración predeterminada" + '\n' +
            "¿Antes de instalar la copia de seguridad local?[/COLOR]",
            nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]',
            yeslabel='[B][COLOR cyan]Continuar[/COLOR][/B]')
    elif install:
        yes_pressed = dialog.yesno(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Desea restaurar su".format(CONFIG.COLOR2) + '\n' +
            "Configuración de Kodi a la configuración predeterminada" + '\n' +
            "Antes de instalar [COLOR {0}]{1}[/COLOR]?".format(
                CONFIG.COLOR1, install),
            nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]',
            yeslabel='[B][COLOR cyan]Continuar[/COLOR][/B]')
    else:
        yes_pressed = dialog.yesno(
            CONFIG.ADDONTITLE,
            "[COLOR {0}]Desea restaurar su".format(CONFIG.COLOR2) + ' \n' +
            "Configuración de Kodi a la configuración predeterminada[/COLOR]",
            nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]',
            yeslabel='[B][COLOR cyan]Continuar[/COLOR][/B]')
    if yes_pressed:
        wipe()

        if over:
            return True
        elif install == 'restore':
            return True
        elif install:
            from resources.libs.wizard import Wizard

            Wizard().build('normal', install, over=True)
        else:
            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))
            from resources.libs import update
            update.addon_updates('reset')
            tools.kill_kodi(over=True)
    else:
        if not install == 'restore':
            logging.log_notify(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Instalación Nueva: Cancelada![/COLOR]'.format(
                    CONFIG.COLOR2))
            xbmc.executebuiltin('Container.Refresh()')