Ejemplo n.º 1
0
def choose_file_manager():
    if not xbmc.getCondVisibility('System.HasAddon(script.kodi.android.update)'):
        from resources.libs.gui import addon_menu
        addon_menu.install_from_kodi('script.kodi.android.update')
    
    try:
        updater = xbmcaddon.Addon('script.kodi.android.update')
    except RuntimeError as e:
        return False
        
    updater.setSetting('File_Manager', '1')
    
    CONFIG.open_settings('script.kodi.android.update', 0, 4, True)
Ejemplo n.º 2
0
def binaries():
    dialog = xbmcgui.Dialog()

    binarytxt = os.path.join(CONFIG.USERDATA, 'build_binaries.txt')

    if os.path.exists(binarytxt):
        binaryids = tools.read_from_file(binarytxt).split(',')

        logging.log(
            "[Binario Detección] Reinstalación de Add-ons Binarios Elegibles")
        dialog.ok(
            CONFIG.ADDONTITLE,
            '[COLOR {0}]La compilación restaurada contiene add-ons específicos de la plataforma, que ahora serán '
            'instalados automáticamente. Es posible que aparezcan varios cuadros de diálogo durante este proceso. Cancelarlos '
            'puede hacer que la compilación restaurada funcione incorrectamente.[/COLOR]'
            .format(CONFIG.COLOR2))
    else:
        logging.log(
            "[Detección de Binario] No hay Addons Binarios Elegibles para Reinstalar"
        )
        return True

    success = []
    fail = []

    if len(binaryids) == 0:
        logging.log('No se seleccionaron add-ons para la instalación.')
        return

    from resources.libs.gui import addon_menu

    # finally, reinstall addons
    for addonid in binaryids:
        if addon_menu.install_from_kodi(addonid):
            logging.log('{0} instalación correcta.'.format(addonid))
            success.append(addonid)
        else:
            logging.log('{0} instalación fallida.'.format(addonid))
            fail.append(addonid)

    if not fail:
        dialog.ok(
            CONFIG.ADDONTITLE,
            'Todos los  addons seleccionados se instalaron correctamente.')
        os.remove(binarytxt)
        return True
    else:
        dialog.ok(
            CONFIG.ADDONTITLE,
            'Los siguientes addons no se pudieron instalar:\n{0}'.format(
                ', '.join(fail)))
        return False
Ejemplo n.º 3
0
def check_for_fm():
    if not xbmc.getCondVisibility('System.HasAddon(script.kodi.android.update)'):
        from resources.libs.gui import addon_menu
        addon_menu.install_from_kodi('script.kodi.android.update')
    
    try:
        updater = xbmcaddon.Addon('script.kodi.android.update')
    except RuntimeError as e:
        return False
        
    fm = int(updater.getSetting('File_Manager'))
    apps = xbmcvfs.listdir('androidapp://sources/apps/')[1]
    
    if fm == 0 and 'com.android.documentsui' not in apps:
        dialog = xbmcgui.Dialog()
        choose = dialog.yesno(CONFIG.ADDONTITLE, 'It appears your device has no default file manager. Would you like to set one now?')
        if not choose:
            dialog.ok(CONFIG.ADDONTITLE, 'If an APK downloads, but doesn\'t open for installation, try changing your file manager in {}\'s "Install Settings".'.format(CONFIG.ADDONTITLE))
        else:
            from resources.libs import install
            install.choose_file_manager()
            
    return True
Ejemplo n.º 4
0
def binaries():
    dialog = xbmcgui.Dialog()

    binarytxt = os.path.join(CONFIG.USERDATA, 'build_binaries.txt')

    if os.path.exists(binarytxt):
        binaryids = tools.read_from_file(binarytxt).split(',')

        logging.log("[Binary Detection] Reinstalling Eligible Binary Addons")
        dialog.ok(
            CONFIG.ADDONTITLE,
            '[COLOR {0}]The restored build contains platform-specific addons, which will now be '
            'automatically installed. A number of dialogs may pop up during this process. Cancelling them '
            'may cause the restored build to function incorrectly.[/COLOR]'.
            format(CONFIG.COLOR2))
    else:
        logging.log(
            "[Binary Detection] No Eligible Binary Addons to Reinstall")
        return True

    success = []
    fail = []

    if len(binaryids) == 0:
        logging.log('No addons selected for installation.')
        return

    from resources.libs.gui import addon_menu

    # finally, reinstall addons
    for addonid in binaryids:
        if addon_menu.install_from_kodi(addonid):
            logging.log('{0} install succeeded.'.format(addonid))
            success.append(addonid)
        else:
            logging.log('{0} install failed.'.format(addonid))
            fail.append(addonid)

    if not fail:
        dialog.ok(CONFIG.ADDONTITLE,
                  'The selected addons were all installed successfully.')
        os.remove(binarytxt)
        return True
    else:
        dialog.ok(
            CONFIG.ADDONTITLE,
            'The following addons failed to install:\n{0}'.format(
                ', '.join(fail)))
        return False
Ejemplo n.º 5
0
def binaries():
    dialog = xbmcgui.Dialog()

    binarytxt = os.path.join(CONFIG.USERDATA, 'build_binaries.txt')

    if os.path.exists(binarytxt):
        binaryids = tools.read_from_file(binarytxt).split(',')

        logging.log("[Detecção binária] Reinstalando complementos binários qualificados")
        dialog.ok(CONFIG.ADDONTITLE,
                  '[COLOR {0}]A compilação restaurada contém complementos específicos da plataforma, que agora serão '
                  'instalado automaticamente. Vários diálogos podem aparecer durante este processo. Cancelando-os '
                  'pode fazer com que a compilação restaurada funcione incorretamente.[/COLOR]'.format(
                      CONFIG.COLOR2))
    else:
        logging.log("[Detecção binária] Nenhum complemento binário elegível para reinstalar")
        return True

    success = []
    fail = []

    if len(binaryids) == 0:
        logging.log('Nenhum complemento selecionado para instalação.')
        return

    from resources.libs.gui import addon_menu

    # finally, reinstall addons
    for addonid in binaryids:
        if addon_menu.install_from_kodi(addonid):
            logging.log('{0} instalação bem-sucedida.'.format(addonid))
            success.append(addonid)
        else:
            logging.log('{0} a instalação falhou.'.format(addonid))
            fail.append(addonid)

    if not fail:
        dialog.ok(CONFIG.ADDONTITLE, 'Os addons selecionados foram todos instalados com sucesso.')
        os.remove(binarytxt)
        return True
    else:
        dialog.ok(CONFIG.ADDONTITLE, 'Os seguintes complementos não foram instalados:\n{0}'.format(', '.join(fail)))
        return False
Ejemplo n.º 6
0
def install_apk(name, url):
    from resources.libs.downloader import Downloader
    from resources.libs.common import logging
    from resources.libs.common import tools
    from resources.libs.gui import window

    dialog = xbmcgui.Dialog()
    progress_dialog = xbmcgui.DialogProgress()
    
    addon = xbmcaddon.Addon()
    path = addon.getSetting('apk_path')
    apk = os.path.basename(url).replace('\\', '').replace('/', '').replace(':', '').replace('*', '').replace('?', '').replace('"', '').replace('<', '').replace('>', '').replace('|', '')
    apk = apk if apk.endswith('.apk') else '{}.apk'.format(apk)
    lib = os.path.join(path, apk)
    
    if not xbmc.getCondVisibility('System.HasAddon(script.kodi.android.update)'):
        from resources.libs.gui import addon_menu
        addon_menu.install_from_kodi('script.kodi.android.update')
        
    try:
        updater = xbmcaddon.Addon('script.kodi.android.update')
    except RuntimeError as e:
        return False
        
    file_manager = int(updater.getSetting('File_Manager'))
    custom_manager = updater.getSetting('Custom_Manager')
    use_manager = {0: 'com.android.documentsui', 1: custom_manager}[file_manager]
    
    if tools.platform() == 'android':
        redownload = True
        yes = True
        if os.path.exists(lib):
            redownload = dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {}]{}[/COLOR] already exists. Would you like to redownload it?'.format(CONFIG.COLOR1, apk),
                               yeslabel="[B]Redownload[/B]",
                               nolabel="[B]Install[/B]")
            yes = False
        else:
            yes = dialog.yesno(CONFIG.ADDONTITLE,
                                   "[COLOR {0}]Would you like to download and install: ".format(CONFIG.COLOR2),
                                   "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, name),
                                   yeslabel="[B][COLOR springgreen]Download[/COLOR][/B]",
                                   nolabel="[B][COLOR red]Cancel[/COLOR][/B]")
                                   
            if not yes:
                logging.log_notify(CONFIG.ADDONTITLE,
                               '[COLOR {0}]ERROR: Install Cancelled[/COLOR]'.format(CONFIG.COLOR2))
                return
        
        if yes or redownload:
            response = tools.open_url(url, check=True)
            if not response:
                logging.log_notify(CONFIG.ADDONTITLE,
                                   '[COLOR {0}]APK Installer: Invalid Apk Url![/COLOR]'.format(CONFIG.COLOR2))
                return
                
            progress_dialog.create(CONFIG.ADDONTITLE,
                          '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, apk),
                          '', 'Please Wait')
            
            try:
                os.remove(lib)
            except:
                pass
            Downloader().download(url, lib)
            xbmc.sleep(100)
            progress_dialog.close()
                
        dialog.ok(CONFIG.ADDONTITLE, '[COLOR {}]{}[/COLOR] downloaded to [COLOR {}]{}[/COLOR]. If installation doesn\'t start by itself, navigate to that location to install the APK.'.format(CONFIG.COLOR1, apk, CONFIG.COLOR1, path))
        
        logging.log('Opening {} with {}'.format(lib, use_manager), level=xbmc.LOGNOTICE)
        xbmc.executebuiltin('StartAndroidActivity({},,,"content://{}")'.format(use_manager, lib))
    else:
        logging.log_notify(CONFIG.ADDONTITLE,
                           '[COLOR {0}]ERROR: None Android Device[/COLOR]'.format(CONFIG.COLOR2))
Ejemplo n.º 7
0
def install_apk(name, url):
    from resources.libs.downloader import Downloader
    from resources.libs.common import logging
    from resources.libs.common import tools
    from resources.libs.gui import window

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

    addon = xbmcaddon.Addon()
    path = addon.getSetting('apk_path')
    apk = os.path.basename(url).replace('\\', '').replace('/', '').replace(
        ':', '').replace('*', '').replace('?', '').replace('"', '').replace(
            '<', '').replace('>', '').replace('|', '')
    apk = apk if apk.endswith('.apk') else '{}.apk'.format(apk)
    lib = os.path.join(path, apk)

    if not xbmc.getCondVisibility(
            'System.HasAddon(script.kodi.android.update)'):
        from resources.libs.gui import addon_menu
        addon_menu.install_from_kodi('script.kodi.android.update')

    try:
        updater = xbmcaddon.Addon('script.kodi.android.update')
    except RuntimeError as e:
        return False

    file_manager = int(updater.getSetting('File_Manager'))
    custom_manager = updater.getSetting('Custom_Manager')
    use_manager = {
        0: 'com.android.documentsui',
        1: custom_manager
    }[file_manager]

    if tools.platform() == 'android':
        redownload = True
        yes = True
        if os.path.exists(lib):
            redownload = dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {}]{}[/COLOR] ya existe. Te gustaría volver a descargarlo?'
                .format(CONFIG.COLOR1, apk),
                yeslabel="[B]Volver a descargar[/B]",
                nolabel="[B]Instalar[/B]")
            yes = False
        else:
            yes = dialog.yesno(
                CONFIG.ADDONTITLE,
                "[COLOR {0}]Le gustaría descargar e instalar: ".format(
                    CONFIG.COLOR2) + '\n' +
                "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, name),
                yeslabel="[B][COLOR cyan]Descargar[/COLOR][/B]",
                nolabel="[B][COLOR red]Cancelar[/COLOR][/B]")

            if not yes:
                logging.log_notify(
                    CONFIG.ADDONTITLE,
                    '[COLOR {0}]ERROR: Instalación Cancelada[/COLOR]'.format(
                        CONFIG.COLOR2))
                return

        if yes or redownload:
            response = tools.open_url(url, check=True)
            if not response:
                logging.log_notify(
                    CONFIG.ADDONTITLE,
                    '[COLOR {0}]APK Instalador: Apk Url Invalida![/COLOR]'.
                    format(CONFIG.COLOR2))
                return

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

            try:
                os.remove(lib)
            except:
                pass
            Downloader().download(url, lib)
            xbmc.sleep(100)
            progress_dialog.close()

        dialog.ok(
            CONFIG.ADDONTITLE,
            '[COLOR {}]{}[/COLOR] descargado a [COLOR {}]{}[/COLOR]. Si la instalación no comienza por sí sola, navegue hasta esa ubicación para instalar el APK.'
            .format(CONFIG.COLOR1, apk, CONFIG.COLOR1, path))

        logging.log('Opening {} with {}'.format(lib, use_manager),
                    level=xbmc.LOGINFO)
        xbmc.executebuiltin('StartAndroidActivity({},,,"content://{}")'.format(
            use_manager, lib))
    else:
        logging.log_notify(
            CONFIG.ADDONTITLE,
            '[COLOR {0}]ERROR: Ningun Dispositivo Android[/COLOR]'.format(
                CONFIG.COLOR2))