示例#1
0
def installAPK(url):
    path = xbmc.translatePath(
        os.path.join('special://home', 'addons', 'packages', ''))
    filename = url.split('/')[-1]
    destination_file = os.path.join(path, filename)

    # Download File
    dp.create('KBuilds Installer', 'Downloading: ' + filename, '',
              'Please wait...')
    kodi.log('Downloading ' + url + ' to ' + destination_file)

    while 1:
        if download_with_resume(url, destination_file, _download_progress):

            # Give instructions for installing APK

            # Install APK
            kodi.log('Installing APK:' + destination_file)
            kodi.get_setting('runonstart', 'true')
            kodi.set_setting('cleanup', destination_file)
            kodi.execute(
                'StartAndroidActivity("","android.intent.action.VIEW","application/vnd.android.package-archive","file:'
                + destination_file + '")')
            return True
            break
        else:
            choice = xbmcgui.Dialog().yesno('KBuilds Installer',
                                            'Transfer incomplete!', '',
                                            'Would you like to retry?')
            if choice == 0:
                return False
                break
示例#2
0
    conn.close()
    #xbmc.executebuiltin('ReloadSkin()')


if __name__ == '__main__':
    monitor = xbmc.Monitor()
    wait = 10  #900 # Set wait to 15mins
    kodi.set_setting('isrunning', 'false')
    update_lastused()

    while not monitor.abortRequested():

        # Start idolpx Installer if runonstart is set
        if kodi.get_setting('runonstart') == 'true':
            kodi.get_setting('runonstart', 'false')
            kodi.execute('XBMC.RunScript(' + addon_id + ')', True)

        # Clean up Kodi apk after install
        cleanup = kodi.get_setting('cleanup')
        if len(cleanup):
            try:
                os.remove(cleanup)
                kodi.set_setting('cleanup', '')
            except:
                pass

        # Sleep/wait for abort for 10 seconds 12 hours is 43200   1 hours is 3600
        # 24hrs = 86400, 5min = 300
        if monitor.waitForAbort(wait):
            # Abort was requested while waiting. We should exit
            kodi.log('CLOSING ' + addon_name.upper() + ' SERVICES')
示例#3
0
def showAdult(status, pin='0'):
    global window

    if status == None:
        status = window.getProperty('idolpx.installer.adultstatus')

    if status == 'true':
        # Enable Adult Addons
        if pin == '0':
            pin = xbmcgui.Dialog().numeric(0,'Enter PIN')

        if pin == kodi.get_setting('adultpin'):
            status = 'true'
        else:
            status = 'abort'
    else:
        # Disable Adult Addons
        status = 'false'

    kodi.debug('Adult Addons Enabled: ' + status)
    if status != 'abort':
        window.setProperty('idolpx.installer.adultstatus', status)
        
        addonPath = xbmc.translatePath(os.path.join('special://home', 'addons'))
        resourcePath = os.path.join(addonPath, kodi.addon_id(), 'resources')
        nsfw_addons = os.path.join(resourcePath, 'nsfw_addons.dat')
        with open(nsfw_addons, 'r') as myfile:
            addons = myfile.read().split('\n')

        for addon in addons:
            try:
                # Move Addon
                if status == 'true':
                    shutil.move(os.path.join(resourcePath, addon), os.path.join(addonPath, addon))
                    #kodi.update_enabled(addon, 1)
                else:
                    shutil.move(os.path.join(addonPath, addon), os.path.join(resourcePath, addon))
                    #kodi.update_enabled(addon, 0)

                # Enable/Disable Addon
                query = '{"jsonrpc":"2.0", "id":1, "method":"Addons.SetAddonEnabled","params":{"addonid":"%s", "enabled":%s}}' % (addon, status)
                kodi.execute_jsonrpc(query)
                kodi.debug(query)
                xbmc.sleep(200)

            except:
                pass

        kodi.execute('UpdateLocalAddons()')
        kodi.execute('UpdateAddonRepos()')
        #xbmc.sleep(1000)
        #kodi.execute('ReloadSkin()')
        
        kodi.set_setting('adultstatus', status)         
        
        if status == 'true': 
            kodi.notify('Adult Addons','Enabled!')
        else: 
            kodi.notify('Adult Addons', 'Disabled!')
       
    else:
        kodi.notify('Adult Addons', 'Invalid PIN!')
示例#4
0
    monitor = xbmc.Monitor()
    wait = 10  #900 # Set wait to 15mins
    kodi.update_lastused('script.idolpx.installer')
    kodi.update_lastused('plugin.video.mediasnatcher')
    window = xbmcgui.Window(10000)
    window.clearProperty('idolpx.installer.running')
    window.setProperty('idolpx.installer.adultstatus',
                       kodi.get_setting('adultstatus'))
    installer.do_maintenance()

    while not monitor.abortRequested():

        # Start idolpx Installer if runonstart is set
        if kodi.get_setting('runonstart') == 'true':
            kodi.get_setting('runonstart', 'false')
            kodi.execute('XBMC.RunScript(%s)' % addon_id, True)

        # Clean up Kodi apk after install
        cleanup = kodi.get_setting('cleanup')
        if len(cleanup):
            try:
                os.remove(cleanup)
                kodi.set_setting('cleanup', '')
            except:
                pass

        # Sleep/wait for abort for 10 seconds 12 hours is 43200   1 hours is 3600
        # 24hrs = 86400, 5min = 300
        if monitor.waitForAbort(wait):
            # Abort was requested while waiting. We should exit
            kodi.debug('CLOSING ' + addon_name.upper() + ' SERVICES')
示例#5
0
def installConfig(url, hash=None):
    path = xbmc.translatePath('special://home')
    filename = url.split('/')[-1]
    destination_file = os.path.join(path, filename)

    # Download File
    dp.create('idolpx Installer', 'Downloading: ' + filename, '',
              'Please wait...')

    while 1:
        kodi.debug('Downloading ' + url + ' to ' + destination_file)
        if download_with_resume(url, destination_file, _download_progress):

            # Check to make sure file validates before install
            if validate_file(destination_file, hash) or hash == '':

                #                # Delete 'addons' folder
                #                dp.update(100, "Removing 'addons' folder",
                #                        '',
                #                        'Please wait...')
                #                try:
                #                    addons = xbmc.translatePath('special://home/addons')
                #                    os.rename(addons, addons+'.old')
                #                except:
                #                    xbmcgui.Dialog().ok(
                #                        'idolpx Installer',
                #                        '[COLOR red]Error renaming addons![/COLOR]',
                #                        '',
                #                        '[B]'+addons[-40:]+'[/B]'
                #                    )
                #                    return False
                #                    break

                # Rename addons folder
                try:
                    addons = xbmc.translatePath('special://home/addons')
                    os.rename(addons, addons + '.old')
                except:
                    xbmcgui.Dialog().ok(
                        'idolpx Installer',
                        '[COLOR red]Error renaming addons![/COLOR]', '',
                        '[B]' + addons[-40:] + '[/B]')
                    return False
                    break

                # Rename userdata folder
                try:
                    userdata = xbmc.translatePath('special://home/userdata')
                    os.rename(userdata, userdata + '.old')
                except:
                    xbmcgui.Dialog().ok(
                        'idolpx Installer',
                        '[COLOR red]Error renaming userdata![/COLOR]', '',
                        '[B]' + userdata[-40:] + '[/B]')
                    return False
                    break

                # Extract File
                try:
                    extract_path = xbmc.translatePath('special://home')
                    unzip(destination_file, extract_path)
                except Exception, e:
                    xbmcgui.Dialog().ok(
                        'idolpx Installer',
                        '[COLOR red]Error Extracting![/COLOR]', str(e),
                        '[B][' + destination_file[-40:] + '][/B]')

                    # Restore old addons and data
                    #shutil.rmtree(addons)
                    #shutil.rmtree(userdata)
                    #os.rename(addons+'.old', addons)
                    #os.rename(userdata+'.old', userdata)
                    return False
                    break

                # Copy settings files back into place
                dp.update(100, 'Restoring Settings', '', 'Please wait...')

                # Copy addon settings back into place
                try:
                    shutil.copyfile(
                        os.path.join(userdata + '.old', 'addon_data',
                                     kodi.addon_id(), 'settings.xml'),
                        os.path.join(userdata, 'addon_data', kodi.addon_id(),
                                     'settings.xml'))
                except:
                    pass

                if kodi.get_setting('keepadv') == 'true':
                    try:
                        shutil.copyfile(
                            os.path.join(userdata + '.old',
                                         'advancedsettings.xml'),
                            os.path.join(userdata, 'advancedsettings.xml'))
                    except:
                        pass
                if kodi.get_setting('keepfavourites') == 'true':
                    try:
                        shutil.copyfile(
                            os.path.join(userdata + '.old', 'favourites.xml'),
                            os.path.join(userdata, 'favourites.xml'))
                    except:
                        pass
                if kodi.get_setting('keepgui') == 'true':
                    try:
                        shutil.copyfile(
                            os.path.join(userdata + '.old', 'guisettings.xml'),
                            os.path.join(userdata, 'guisettings.xml'))
                    except:
                        pass
                if kodi.get_setting('keepsources') == 'true':
                    try:
                        shutil.copyfile(
                            os.path.join(userdata + '.old', 'sources.xml'),
                            os.path.join(userdata, 'sources.xml'))
                    except:
                        pass
                    try:
                        if kodi.get_setting('keepmuisc') == 'true':
                            for file in glob.glob(
                                    os.path.join(userdata + '.old', 'Database',
                                                 'MyMusic*.db')):
                                shutil.copyfile(
                                    file, os.path.join(userdata, 'Database'))

                        if kodi.get_setting('keepvideos') == 'true':
                            for file in glob.glob(
                                    os.path.join(userdata + '.old', 'Database',
                                                 'MyVideos*.db')):
                                shutil.copyfile(
                                    file, os.path.join(userdata, 'Database'))
                    except:
                        pass

                # Enable Adult Addons
                if kodi.get_setting('adultstatus') == 'true':
                    kodi.debug('Adult Addons Enabled')
                    kodi.execute('XBMC.RunScript(%s,%s,%s,%s)' %
                                 (kodi.addon_id(), 'showadult', 'true',
                                  kodi.get_setting('adultpin')))
                else:
                    kodi.debug('Adult Addons Disabled')

                # Delete old 'userdata' folder
                dp.update(100, "Cleaning up", '', 'Please wait...')
                try:
                    shutil.rmtree(addons + '.old')
                    shutil.rmtree(userdata + '.old')
                except:
                    pass

                # Delete archives and partial downloads
                try:
                    for file in glob.glob(extract_path + "kodi.*.zip"):
                        os.remove(file)
                    for file in glob.glob(extract_path + "kodi.*.part"):
                        os.remove(file)
                    for file in glob.glob(extract_path + "kodi.*.md5"):
                        os.remove(file)
                    for file in glob.glob(extract_path + "update.*"):
                        os.remove(file)
                except:
                    pass

                return True
                break

            else:
                choice = xbmcgui.Dialog().yesno('idolpx Installer',
                                                'File Validation Failed!', '',
                                                'Would you like to retry?')
                if choice == 0:
                    return False
                    break

        else:
            choice = xbmcgui.Dialog().yesno('idolpx Installer',
                                            'Transfer incomplete!', '',
                                            'Would you like to retry?')
            if choice == 0:
                return False
                break