Пример #1
0
def clear_archive():
    dialog = xbmcgui.Dialog()

    if dialog.yesno(CONFIG.ADDONTITLE,
                        '[COLOR {0}]Le gustaria borrar la carpeta \'Archive_Cache \'?[/COLOR]'.format(CONFIG.COLOR2),
                        nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]',
                        yeslabel='[B][COLOR dodgerblue]Si Borrar[/COLOR][/B]'):
        if os.path.exists(CONFIG.ARCHIVE_CACHE):
            from resources.libs.common import tools
            tools.clean_house(CONFIG.ARCHIVE_CACHE)
Пример #2
0
def clear_archive():
    dialog = xbmcgui.Dialog()

    if dialog.yesno(CONFIG.ADDONTITLE,
                        '[COLOR {0}]Would you like to clear the \'Archive_Cache\' folder?[/COLOR]'.format(CONFIG.COLOR2),
                        nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]',
                        yeslabel='[B][COLOR springgreen]Yes Clear[/COLOR][/B]'):
        if os.path.exists(CONFIG.ARCHIVE_CACHE):
            from resources.libs.common import tools
            tools.clean_house(CONFIG.ARCHIVE_CACHE)
def clear_archive():
    dialog = xbmcgui.Dialog()

    if dialog.yesno(CONFIG.ADDONTITLE,
                        '[COLOR {0}]Deseja limpar a pasta  \'Archive_Cache\' ?[/COLOR]'.format(CONFIG.COLOR2),
                        nolabel='[B][COLOR red]Não, Cancelar[/COLOR][/B]',
                        yeslabel='[B][COLOR springgreen]Sim limpar[/COLOR][/B]'):
        if os.path.exists(CONFIG.ARCHIVE_CACHE):
            from resources.libs.common import tools
            tools.clean_house(CONFIG.ARCHIVE_CACHE)
Пример #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)
Пример #5
0
def remove_addon(addon, name, over=False, data=True):
    import sqlite3
    from resources.libs import db

    if over:
        yes = 1
    else:
        dialog = xbmcgui.Dialog()

        yes = dialog.yesno(
            CONFIG.ADDONTITLE,
            '[COLOR {0}]Are you sure you want to delete the add-on:'.format(
                CONFIG.COLOR2),
            'Name: [COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, name),
            'ID: [COLOR {0}]{1}[/COLOR][/COLOR]'.format(CONFIG.COLOR1, addon),
            yeslabel='[B][COLOR springgreen]Remove Add-on[/COLOR][/B]',
            nolabel='[B][COLOR red]Don\'t Remove[/COLOR][/B]')
    if yes == 1:
        folder = os.path.join(CONFIG.ADDONS, addon)
        logging.log("Removing Add-on: {0}".format(addon))

        from resources.libs.common import tools
        tools.clean_house(folder)
        xbmc.sleep(200)

        xbmc.executebuiltin('StopScript({0})'.format(addon))

        sqldb = sqlite3.connect(
            os.path.join(CONFIG.DATABASE, db.latest_db('Addons')))
        sqlexe = sqldb.cursor()
        query = "DELETE FROM {0} WHERE addonID = '{1}'"

        for table in ['addons', 'installed', 'package']:
            sqlexe.execute(query.format(table, addon))

        try:
            shutil.rmtree(folder)
        except Exception as e:
            logging.log("Error removing {0}: {1}".format(addon, str(e)),
                        level=xbmc.LOGNOTICE)

        if data:
            remove_addon_data(addon)

        return True

    if not over:
        logging.log_notify(
            "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
            "[COLOR {0}]{1} Removed[/COLOR]".format(CONFIG.COLOR2, name))
Пример #6
0
def remove_addon(addon, name, over=False, data=True):
    import sqlite3
    from resources.libs import db
    
    if over:
        yes = 1
    else:
        dialog = xbmcgui.Dialog()
        
        yes = dialog.yesno(CONFIG.ADDONTITLE,
                               '[COLOR {0}]Estas seguro de que quieres eliminar el add-on:'.format(CONFIG.COLOR2)
                               +'\n'+'Name: [COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, name)
                               +'\n'+'ID: [COLOR {0}]{1}[/COLOR][/COLOR]'.format(CONFIG.COLOR1, addon),
                               yeslabel='[B][COLOR dodgerblue]Eliminar Add-on[/COLOR][/B]',
                               nolabel='[B][COLOR red]No Eliminar[/COLOR][/B]')
    if yes == 1:
        folder = os.path.join(CONFIG.ADDONS, addon)
        logging.log("Eliminadno Add-on: {0}".format(addon))

        from resources.libs.common import tools
        tools.clean_house(folder)
        xbmc.sleep(200)
        
        xbmc.executebuiltin('StopScript({0})'.format(addon))
        
        sqldb = sqlite3.connect(os.path.join(CONFIG.DATABASE, db.latest_db('Addons')))
        sqlexe = sqldb.cursor()
        query = "BORRAR DE {0} DONDE addonID = '{1}'"
        
        for table in ['addons', 'installed', 'package']:
            sqlexe.execute(query.format(table, addon))
        
        try:
            shutil.rmtree(folder)
        except Exception as e:
            logging.log("Error al eliminar {0}: {1}".format(addon, str(e)))
        
        if data:
            remove_addon_data(addon)
            
        return True
            
    if not over:
        logging.log_notify(CONFIG.ADDONTITLE,
                           "[COLOR {0}]{1} Eliminado[/COLOR]".format(CONFIG.COLOR2, name))
Пример #7
0
def clear_packages_startup():
    from resources.libs.common import tools

    start = datetime.utcnow() - timedelta(minutes=3)
    file_count = 0
    cleanupsize = 0
    if os.path.exists(CONFIG.PACKAGES):
        pack = os.listdir(CONFIG.PACKAGES)
        pack.sort(
            key=lambda f: os.path.getmtime(os.path.join(CONFIG.PACKAGES, f)))
        try:
            for item in pack:
                file = os.path.join(CONFIG.PACKAGES, item)
                lastedit = datetime.utcfromtimestamp(os.path.getmtime(file))
                if lastedit <= start:
                    if os.path.isfile(file):
                        file_count += 1
                        cleanupsize += os.path.getsize(file)
                        os.unlink(file)
                    elif os.path.isdir(file):
                        cleanupsize += tools.get_size(file)
                        cleanfiles, cleanfold = tools.clean_house(file)
                        file_count += cleanfiles + cleanfold
                        try:
                            shutil.rmtree(file)
                        except Exception as e:
                            logging.log("Failed to remove {0}: {1}".format(
                                file, str(e), xbmc.LOGERROR))
            if file_count > 0:
                logging.log_notify(
                    "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1,
                                                    CONFIG.ADDONTITLE),
                    '[COLOR {0}]Clear Packages: Success: {1}[/COLOR]'.format(
                        CONFIG.COLOR2, tools.convert_size(cleanupsize)))
            else:
                logging.log_notify(
                    "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1,
                                                    CONFIG.ADDONTITLE),
                    '[COLOR {0}]Clear Packages: None Found![/COLOR]'.format(
                        CONFIG.COLOR2))
        except Exception as e:
            logging.log_notify(
                "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1,
                                                CONFIG.ADDONTITLE),
                '[COLOR {0}]Clear Packages: Error![/COLOR]'.format(
                    CONFIG.COLOR2))
            logging.log("Clear Packages Error: {0}".format(str(e)),
                        level=xbmc.LOGERROR)
    else:
        logging.log_notify(
            "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
            '[COLOR {0}]Clear Packages: None Found![/COLOR]'.format(
                CONFIG.COLOR2))
Пример #8
0
def force_text():
    tools.clean_house(CONFIG.TEXTCACHE)
    logging.log_notify(CONFIG.ADDONTITLE,
                       '[COLOR {0}]Archivos de Texto Descargados![/COLOR]'.format(CONFIG.COLOR2))
Пример #9
0
    def dispatch(self, handle, paramstring):
        self._log_params(paramstring)

        mode = self.params['mode'] if 'mode' in self.params else None
        url = self.params['url'] if 'url' in self.params else None
        name = self.params['name'] if 'name' in self.params else None
        action = self.params['action'] if 'action' in self.params else None

        # MAIN MENU
        if mode is None:
            from resources.libs.gui.main_menu import MainMenu
            MainMenu().get_listing()
            self._finish(handle)

        # SETTINGS
        elif mode == 'settings':  # OpenWizard settings
            CONFIG.open_settings(name)
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'opensettings':  # Open other addons' settings
            settings_id = eval(url.upper() + 'ID')[name]['plugin']
            CONFIG.open_settings(settings_id)
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'togglesetting':  # Toggle a setting
            CONFIG.set_setting(name, 'false' if CONFIG.get_setting(name) == 'true' else 'true')
            xbmc.executebuiltin('Container.Refresh()')

        # MENU SECTIONS
        elif mode == 'builds':  # Builds
            from resources.libs.gui.build_menu import BuildMenu
            BuildMenu().get_listing()
            self._finish(handle)
        elif mode == 'viewbuild':  # Builds -> "Your Build"
            from resources.libs.gui.build_menu import BuildMenu
            BuildMenu().view_build(name)
            self._finish(handle)
        elif mode == 'buildinfo':  # Builds -> Build Info
            from resources.libs.gui.build_menu import BuildMenu
            BuildMenu().build_info(name)
        elif mode == 'buildpreview':  # Builds -> Build Preview
            from resources.libs.gui.build_menu import BuildMenu
            BuildMenu().build_video(name)
        elif mode == 'install':  # Builds -> Fresh Install/Standard Install/Apply guifix
            from resources.libs.wizard import Wizard

            if action == 'build':
                Wizard().build(name)
            elif action == 'gui':
                Wizard().gui(name)
            elif action == 'theme':  # Builds -> "Your Build" -> "Your Theme"
                Wizard().theme(name, url)

        elif mode == 'maint':  # Maintenance + Maintenance -> any "Tools" section
            from resources.libs.gui.maintenance_menu import MaintenanceMenu

            if name == 'clean':
                MaintenanceMenu().clean_menu()
            elif name == 'addon':
                MaintenanceMenu().addon_menu()
            elif name == 'misc':
                MaintenanceMenu().misc_menu()
            elif name == 'backup':
                MaintenanceMenu().backup_menu()
            elif name == 'tweaks':
                MaintenanceMenu().tweaks_menu()
            elif name == 'logging':
                MaintenanceMenu().logging_menu()
            elif name is None:
                MaintenanceMenu().get_listing()
                
            self._finish(handle)

        elif mode == 'enableaddons':  # Maintenance - > Addon Tools -> Enable/Disable Addons
            menu.enable_addons()
            self._finish(handle)
        elif mode == 'toggleaddon':
            from resources.libs import db
            db.toggle_addon(name, url)
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'forceupdate':
            from resources.libs import db
            db.force_check_updates(auto=action)
        elif mode == 'togglecache':
            from resources.libs import clear
            clear.toggle_cache(name)
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'changefreq':  # Maintenance - Auto Clean Frequency
            menu.change_freq()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'systeminfo':  # Maintenance -> System Tweaks/Fixes -> System Information
            menu.system_info()
            self._finish(handle)
        elif mode == 'nettools':  # Maintenance -> Misc Maintenance -> Network Tools
            menu.net_tools()
            self._finish(handle)
        elif mode == 'runspeedtest':  # Maintenance -> Misc Maintenance -> Network Tools -> Speed Test -> Run Speed Test
            menu.run_speed_test()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'clearspeedtest':  # Maintenance -> Misc Maintenance -> Network Tools -> Speed Test -> Clear Results
            menu.clear_speed_test()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'viewspeedtest':  # Maintenance -> Misc Maintenance -> Network Tools -> Speed Test -> any previous test
            menu.view_speed_test(name)
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'viewIP':  # Maintenance -> Misc Maintenance -> Network Tools -> View IP Address & MAC Address
            menu.view_ip()
            self._finish(handle)
        elif mode == 'speedtest':  # Maintenance -> Misc Maintenance -> Network Tools -> Speed Test
            menu.speed_test()
            self._finish(handle)
        elif mode == 'apk':  # APK Installer
            menu.apk_menu(url)
            self._finish(handle)
        elif mode == 'kodiapk':  # APK Installer -> Official Kodi APK's
            xbmc.executebuiltin('RunScript(script.kodi.android.update)')
        elif mode == 'fmchoose':
            from resources.libs import install
            install.choose_file_manager()
        elif mode == 'apkinstall':
            from resources.libs import install
            install.install_apk(name, url)
        elif mode == 'removeaddondata':  # Maintenance - > Addon Tools -> Remove Addon Data
            menu.remove_addon_data_menu()
            self._finish(handle)
        elif mode == 'savedata':  # Save Data + Builds -> Save Data Menu
            menu.save_menu()
            self._finish(handle)
        elif mode == 'youtube':  # "YouTube Section"
            menu.youtube_menu(url)
            self._finish(handle)
        elif mode == 'viewVideo':  # View  Video
            from resources.libs import yt
            yt.play_video(url)
        elif mode == 'trakt':  # Save Data -> Keep Trakt Data
            menu.trakt_menu()
            self._finish(handle)
        elif mode == 'realdebrid':  # Save Data -> Keep Debrid
            menu.debrid_menu()
            self._finish(handle)
        elif mode == 'login':  # Save Data -> Keep Login Info
            menu.login_menu()
            self._finish(handle)
        elif mode == 'developer':  # Developer  Menu
            menu.developer()
            self._finish(handle)

        # MAINTENANCE FUNCTIONS
        elif mode == 'kodi17fix':  # Misc Maintenance -> Kodi 17 Fix
            from resources.libs import db
            db.kodi_17_fix()
        elif mode == 'unknownsources':  # Misc Maintenance -> Enable Unknown Sources
            from resources.libs import skin
            skin.swap_us()
        elif mode == 'enabledebug':  # Misc Maintenance -> Enable Debug Logging
            logging.swap_debug()
        elif mode == 'toggleupdates':  # Misc Maintenance -> Toggle Addon Updates
            from resources.libs import update
            update.toggle_addon_updates()
        elif mode == 'asciicheck':  # System Tweaks -> Scan for Non-Ascii Files
            from resources.libs.common import tools
            tools.ascii_check()
        elif mode == 'convertpath':  # System Tweaks -> Convert Special Paths
            from resources.libs.common import tools
            tools.convert_special(CONFIG.HOME)
        elif mode == 'forceprofile':  # Misc Maintenance -> Reload Profile
            from resources.libs.common import tools
            tools.reload_profile(tools.get_info_label('System.ProfileName'))
        elif mode == 'forceclose':  # Misc Maintenance -> Force Close Kodi
            from resources.libs.common import tools
            tools.kill_kodi()
        elif mode == 'forceskin':  # Misc Maintenance -> Reload Skin
            xbmc.executebuiltin("ReloadSkin()")
            xbmc.executebuiltin('Container.Refresh()')
        # elif mode == 'hidepassword':  # Addon Tools -> Hide Passwords on Keyboard Entry
        #     from resources.libs import db
        #     db.hide_password()
        # elif mode == 'unhidepassword':  # Addon Tools -> Unhide Passwords on Keyboard Entry
        #     from resources.libs import db
        #     db.unhide_password()
        elif mode == 'checksources':  # System Tweaks -> Scan source for broken links
            from resources.libs import check
            check.check_sources()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'checkrepos':  # System Tweaks -> Scan for broken repositories
            from resources.libs import check
            check.check_repos()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'whitelist':  # Whitelist Functions
            from resources.libs import whitelist
            whitelist.whitelist(name)

        #  CLEANING
        elif mode == 'oldThumbs':  # Cleaning Tools -> Clear Old Thumbnails
            from resources.libs import clear
            clear.old_thumbs()
        elif mode == 'clearbackup':  # Backup/Restore -> Clean Up Back Up Folder
            from resources.libs import backup
            backup.cleanup_backup()
        elif mode == 'fullclean':  # Cleaning Tools -> Total Cleanup
            from resources.libs import clear
            clear.total_clean()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'clearcache':  # Cleaning Tools -> Clear Cache
            from resources.libs import clear
            clear.clear_cache()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'clearfunctioncache':  # Cleaning Tools -> Clear Function Caches
            from resources.libs import clear
            clear.clear_function_cache()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'clearpackages':  # Cleaning Tools -> Clear Packages
            from resources.libs import clear
            clear.clear_packages()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'clearcrash':  # Cleaning Tools -> Clear Crash Logs
            from resources.libs import clear
            clear.clear_crash()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'clearthumb':  # Cleaning Tools -> Clear Thumbnails
            from resources.libs import clear
            clear.clear_thumbs()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'cleararchive':  # Cleaning Tools -> Clear Archive Cache
            from resources.libs import clear
            clear.clear_archive()
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'freshstart':  # Cleaning Tools -> Fresh Start
            from resources.libs import install
            install.fresh_start()
        elif mode == 'purgedb':  # Cleaning Tools -> Purge Databases
            from resources.libs import db
            db.purge_db()
        elif mode == 'removeaddons':  # Addon Tools -> Remove Addons
            from resources.libs import clear
            clear.remove_addon_menu()
        elif mode == 'removedata':  # Addon Tools -> Remove Addon Data
            from resources.libs import clear
            clear.remove_addon_data(name)
        elif mode == 'resetaddon':  # Addon Tools -> Remove Addon Data -> Remove  Wizard Addon Data
            from resources.libs.common import tools

            tools.clean_house(CONFIG.ADDON_DATA, ignore=True)
            logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                               "[COLOR {0}]Addon_Data reset[/COLOR]".format(CONFIG.COLOR2))
        # BACKUP / RESTORE
        elif mode == 'backup' and action:
            from resources.libs import backup
            backup.backup(action)
        elif mode == 'restore' and action:
            from resources.libs import restore
            restore.restore(action, external=name == 'external')

        elif mode == 'wizardupdate':  # Wizard Update
            from resources.libs import update
            update.wizard_update()

        # LOGGING
        elif mode == 'uploadlog':  # Upload Log File
            logging.upload_log()
        elif mode == 'viewlog':  # View kodi.log
            logging.view_log_file()
        elif mode == 'viewwizlog':  # View wizard.log
            from resources.libs.gui import window
            window.show_log_viewer(log_file=CONFIG.WIZLOG)
        elif mode == 'viewerrorlog':  # View errors in log
            logging.error_checking()
        elif mode == 'viewerrorlast':  # View last error in log
            logging.error_checking(last=True)
        elif mode == 'clearwizlog':  # Clear wizard.log
            from resources.libs.common import tools
            tools.remove_file(CONFIG.WIZLOG)
            logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                               "[COLOR {0}]Wizard Log Cleared![/COLOR]".format(CONFIG.COLOR2))

        # ADVANCED SETTINGS
        elif mode == advanced_settings_mode:
            from resources.libs import advanced

            self.route = advanced.AdvancedMenu()
            advanced_settings_actions = ['quick_configure', 'view_current', 'remove_current', 'write_advanced', 'set_setting', 'show_section']

            category = self.params['category'] if 'category' in self.params else None
            tag = self.params['tag'] if 'tag' in self.params else None
            value = self.params['value'] if 'value' in self.params else None
            tags = self.params['tags'] if 'tags' in self.params else None

            if not action:
                self.route.show_menu(url=url)
                self._finish(handle)
            elif action == advanced_settings_actions[0]:  # Advanced Settings Quick Configure
                self.route.quick_configure()
                self._finish(handle)
            elif action == advanced_settings_actions[1]:  # View Current Advanced Settings
                advanced.view_current()
            elif action == advanced_settings_actions[2]:  # Remove Current Advanced Settings
                advanced.remove_current()
            elif action == advanced_settings_actions[3] and url:  # Write New Advanced Settings
                self.route.write_advanced(name, url)
            elif action == advanced_settings_actions[4]:  # Set a Setting
                self.route.set_setting(category, tag, value)
            elif action == advanced_settings_actions[5]:  # Open a Section
                self.route.show_section(tags)
                self._finish(handle)
                
        # ADDON INSTALLER
        elif mode == addon_installer_mode:
            from resources.libs.gui import addon_menu
            
            self.route = addon_menu.AddonMenu()
            addon_installer_actions = ['addon', 'skin', 'addonpack']

            addonurl = self.params['addonurl'] if 'addonurl' in self.params else None
            repository = self.params['repository'] if 'repository' in self.params else None
            repositoryurl = self.params['repositoryurl'] if 'repositoryurl' in self.params else None
            repositoryxml = self.params['repositoryxml'] if 'repositoryxml' in self.params else None
            urls = [addonurl, repository, repositoryurl, repositoryxml]
            
            if not action:
                self.route.show_menu(url=url)
                self._finish(handle)
            elif action == addon_installer_actions[0]:
                self.route.install_addon(name, urls)
            elif action == addon_installer_actions[1]:
                pass
                # self.route.install_skin(name, url)
            elif action == addon_installer_actions[2]:
                pass
                # self.route.install_addon_pack(name, url)
            
        # SAVE DATA
        elif mode == 'managedata':
            from resources.libs import save

            if name == 'import':
                save.import_save_data()
            elif name == 'export':
                save.export_save_data()

        # TRAKT
        elif mode == 'savetrakt':  # Save Trakt Data
            from resources.libs import traktit
            traktit.trakt_it('update', name)
        elif mode == 'restoretrakt':  # Recover All Saved Trakt Data
            from resources.libs import traktit
            traktit.trakt_it('restore', name)
        elif mode == 'addontrakt':  # Clear All Addon Trakt Data
            from resources.libs import traktit
            traktit.trakt_it('clearaddon', name)
        elif mode == 'cleartrakt':  # Clear All Saved Trakt Data
            from resources.libs import traktit
            traktit.clear_saved(name)
        elif mode == 'authtrakt':  # Authorize Trakt
            from resources.libs import traktit
            traktit.activate_trakt(name)
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'updatetrakt':  # Update Saved Trakt Data
            from resources.libs import traktit
            traktit.auto_update('all')
        elif mode == 'importtrakt':  # Import Saved Trakt Data
            from resources.libs import traktit
            traktit.import_list(name)
            xbmc.executebuiltin('Container.Refresh()')

        # DEBRID
        elif mode == 'savedebrid':  # Save Debrid Data
            from resources.libs import debridit
            debridit.debrid_it('update', name)
        elif mode == 'restoredebrid':  # Recover All Saved Debrid Data
            from resources.libs import debridit
            debridit.debrid_it('restore', name)
        elif mode == 'addondebrid':  # Clear All Addon Debrid Data
            from resources.libs import debridit
            debridit.debrid_it('clearaddon', name)
        elif mode == 'cleardebrid':  # Clear All Saved Debrid Data
            from resources.libs import debridit
            debridit.clear_saved(name)
        elif mode == 'authdebrid':  # Authorize Debrid
            from resources.libs import debridit
            debridit.activate_debrid(name)
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'updatedebrid':  # Update Saved Debrid Data
            from resources.libs import debridit
            debridit.auto_update('all')
        elif mode == 'importdebrid':  # Import Saved Debrid Data
            from resources.libs import debridit
            debridit.import_list(name)
            xbmc.executebuiltin('Container.Refresh()')

        # LOGIN
        elif mode == 'savelogin':  # Save Login Data
            from resources.libs import loginit
            loginit.login_it('update', name)
        elif mode == 'restorelogin':  # Recover All Saved Login Data
            from resources.libs import loginit
            loginit.login_it('restore', name)
        elif mode == 'addonlogin':  # Clear All Addon Login Data
            from resources.libs import loginit
            loginit.login_it('clearaddon', name)
        elif mode == 'clearlogin':  # Clear All Saved Login Data
            from resources.libs import loginit
            loginit.clear_saved(name)
        elif mode == 'authlogin':  # "Authorize" Login
            from resources.libs import loginit
            loginit.activate_login(name)
            xbmc.executebuiltin('Container.Refresh()')
        elif mode == 'updatelogin':  # Update Saved Login Data
            from resources.libs import loginit
            loginit.auto_update('all')
        elif mode == 'importlogin':  # Import Saved Login Data
            from resources.libs import loginit
            loginit.import_list(name)
            xbmc.executebuiltin('Container.Refresh()')

        # DEVELOPER MENU
        elif mode == 'createqr':  # Developer Menu -> Create QR Code
            from resources.libs import qr
            qr.create_code()
        elif mode == 'testnotify':  # Developer Menu -> Test Notify
            from resources.libs import test
            test.test_notify()
        elif mode == 'testupdate':  # Developer Menu -> Test Update
            from resources.libs import test
            test.test_update()
        elif mode == 'testsavedata':  # Developer Menu -> Test Save Data Settings
            from resources.libs import test
            test.test_save_data_settings()
        elif mode == 'testbuildprompt':  # Developer Menu -> Test Build Prompt
            from resources.libs import test
            test.test_first_run()
        elif mode == 'binarycheck':
            from resources.libs import db
            db.find_binary_addons()
        elif mode == 'contact':  # Contact
            from resources.libs.gui import window
            window.show_contact(CONFIG.CONTACT)
Пример #10
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}]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))
Пример #11
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))
Пример #12
0
def force_text():
    tools.clean_house(CONFIG.TEXTCACHE)
    logging.log_notify(
        CONFIG.ADDONTITLE,
        '[COLOR {0}]Text Files Flushed![/COLOR]'.format(CONFIG.COLOR2))
Пример #13
0
def remove_addon_data(addon):
    dialog = xbmcgui.Dialog()

    if addon == 'all':  # clear ALL addon data
        if dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Would you like to remove [COLOR {1}]ALL[/COLOR] addon data stored in your userdata folder?[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1),
                yeslabel='[B][COLOR springgreen]Remove Data[/COLOR][/B]',
                nolabel='[B][COLOR red]Don\'t Remove[/COLOR][/B]'):
            tools.clean_house(CONFIG.ADDON_DATA)
        else:
            logging.log_notify(
                '[COLOR {0}]Remove Addon Data[/COLOR]'.format(CONFIG.COLOR1),
                '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    elif addon == 'uninstalled':  # clear addon data for uninstalled addons
        if dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Would you like to remove [COLOR {1}]ALL[/COLOR] addon data stored in your userdata folder for uninstalled addons?[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1),
                yeslabel='[B][COLOR springgreen]Remove Data[/COLOR][/B]',
                nolabel='[B][COLOR red]Don\'t Remove[/COLOR][/B]'):

            total = 0

            for folder in glob.glob(os.path.join(CONFIG.ADDON_DATA, '*')):
                foldername = folder.replace(CONFIG.ADDON_DATA,
                                            '').replace('\\',
                                                        '').replace('/', '')
                if foldername in CONFIG.EXCLUDES:
                    pass
                elif os.path.exists(os.path.join(CONFIG.ADDONS, foldername)):
                    pass
                elif os.path.isdir(folder):
                    tools.clean_house(folder)
                    total += 1
                    logging.log(folder)
                    shutil.rmtree(folder)
            logging.log_notify(
                '[COLOR {0}]Clean up Uninstalled[/COLOR]'.format(
                    CONFIG.COLOR1),
                '[COLOR {0}]{1} Folders(s) Removed[/COLOR]'.format(
                    CONFIG.COLOR2, total))
        else:
            logging.log_notify(
                '[COLOR {0}]Remove Add-on Data[/COLOR]'.format(CONFIG.COLOR1),
                '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    elif addon == 'empty':  # clear empty folders from addon_data
        if dialog.yesno(
                CONFIG.ADDONTITLE,
                '[COLOR {0}]Would you like to remove [COLOR {1}]ALL[/COLOR] empty addon data folders in your userdata folder?[/COLOR]'
                .format(CONFIG.COLOR2, CONFIG.COLOR1),
                yeslabel='[B][COLOR springgreen]Remove Data[/COLOR][/B]',
                nolabel='[B][COLOR red]Don\'t Remove[/COLOR][/B]'):
            total = tools.empty_folder(CONFIG.ADDON_DATA)
            logging.log_notify(
                '[COLOR {0}]Remove Empty Folders[/COLOR]'.format(
                    CONFIG.COLOR1),
                '[COLOR {0}]{1} Folders(s) Removed[/COLOR]'.format(
                    CONFIG.COLOR2, total))
        else:
            logging.log_notify(
                '[COLOR {0}]Remove Empty Folders[/COLOR]'.format(
                    CONFIG.COLOR1),
                '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    else:  # clear addon data for a specific addon
        addon_data = os.path.join(CONFIG.ADDON_DATA, addon)
        if addon in CONFIG.EXCLUDES:
            logging.log_notify(
                "[COLOR {0}]Protected Plugin[/COLOR]".format(CONFIG.COLOR1),
                "[COLOR {0}]Not allowed to remove add-on data[/COLOR]".format(
                    CONFIG.COLOR2))
        elif os.path.exists(addon_data):
            if dialog.yesno(
                    CONFIG.ADDONTITLE,
                    '[COLOR {0}]Would you also like to remove the add-on data for:[/COLOR]'
                    .format(CONFIG.COLOR2) + '\n' +
                    '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, addon),
                    yeslabel='[B][COLOR springgreen]Remove Data[/COLOR][/B]',
                    nolabel='[B][COLOR red]Don\'t Remove[/COLOR][/B]'):
                tools.clean_house(addon_data)
                try:
                    shutil.rmtree(addon_data)
                except:
                    logging.log("Error deleting: {0}".format(addon_data))
            else:
                logging.log(
                    'Add-on data for {0} was not removed'.format(addon))
    xbmc.executebuiltin('Container.Refresh()')
Пример #14
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.")
Пример #15
0
def remove_addon_data(addon):
    dialog = xbmcgui.Dialog()

    if addon == 'all':  # clear ALL addon data
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Le gustaria eliminar [COLOR {1}]TODOS[/COLOR] los datos de los addons almacenados en su carpeta de datos de usuario para los addons desinstalados?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR dodgerblue]Eliminar Datos[/COLOR][/B]',
                            nolabel='[B][COLOR red]No Eliminar[/COLOR][/B]'):
            tools.clean_house(CONFIG.ADDON_DATA)
        else:
            logging.log_notify('[COLOR {0}]Eliminar Datos de Addons[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelado![/COLOR]'.format(CONFIG.COLOR2))
    elif addon == 'uninstalled':  # clear addon data for uninstalled addons
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Le gustaría eliminar [COLOR {1}]TODOS[/COLOR] los datos de los addons almacenados en su carpeta de datos de usuario para los addons desinstalados?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR dodgerblue]Eliminar Datos[/COLOR][/B]',
                            nolabel='[B][COLOR red]No Eliminar[/COLOR][/B]'):
                            
            total = 0
            
            for folder in glob.glob(os.path.join(CONFIG.ADDON_DATA, '*')):
                foldername = folder.replace(CONFIG.ADDON_DATA, '').replace('\\', '').replace('/', '')
                if foldername in CONFIG.EXCLUDES:
                    pass
                elif os.path.exists(os.path.join(CONFIG.ADDONS, foldername)):
                    pass
                elif os.path.isdir(folder):
                    tools.clean_house(folder)
                    total += 1
                    logging.log(folder)
                    shutil.rmtree(folder)
            logging.log_notify('[COLOR {0}]Limpiar Desinstalado[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]{1} Carpetas(s) Eliminada[/COLOR]'.format(CONFIG.COLOR2, total))
        else:
            logging.log_notify('[COLOR {0}]Eliminar Datos de Add-ons[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelado![/COLOR]'.format(CONFIG.COLOR2))
    elif addon == 'empty':  # clear empty folders from addon_data
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Le gustaria eliminar [COLOR {1}] TODAS [/ COLOR] las carpetas de datos de addons vacias en su carpeta de datos de usuario?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR dodgerblue]Eliminar Datos[/COLOR][/B]',
                            nolabel='[B][COLOR red]No Eliminar[/COLOR][/B]'):
            total = tools.empty_folder(CONFIG.ADDON_DATA)
            logging.log_notify('[COLOR {0}]Eliminar Carpetas Vacias[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]{1} Carpeta(s) Eliminada[/COLOR]'.format(CONFIG.COLOR2, total))
        else:
            logging.log_notify('[COLOR {0}]Eliminar Carpetas Vacias[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelado![/COLOR]'.format(CONFIG.COLOR2))
    else:  # clear addon data for a specific addon
        addon_data = os.path.join(CONFIG.ADDON_DATA, addon)
        if addon in CONFIG.EXCLUDES:
            logging.log_notify("[COLOR {0}]Plugin Protegido[/COLOR]".format(CONFIG.COLOR1),
                               "[COLOR {0}]No se permite eliminar datos de los add-ons[/COLOR]".format(CONFIG.COLOR2))
        elif os.path.exists(addon_data):
            if dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]Tambien le gustaria eliminar los datos de los add-ons para:[/COLOR]'.format(CONFIG.COLOR2) + '\n' + '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, addon), yeslabel='[B][COLOR dodgerblue]Quitar datos[/COLOR][/B]', nolabel='[B][COLOR red]No Quitar[/COLOR][/B]'):
                tools.clean_house(addon_data)
                try:
                    shutil.rmtree(addon_data)
                except:
                    logging.log("Error al eliminar: {0}".format(addon_data))
            else:
                logging.log('No se eliminaron los datos {0} Add-ons para'.format(addon))
    xbmc.executebuiltin('Container.Refresh()')
def remove_addon_data(addon):
    dialog = xbmcgui.Dialog()

    if addon == 'all':  # clear ALL addon data
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Você gostaria de remover [COLOR {1}]Todos[/COLOR] dados adicionais armazenados em sua pasta de dados do usuário?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR springgreen]Remove Data[/COLOR][/B]',
                            nolabel='[B][COLOR red]Não Remove[/COLOR][/B]'):
            tools.clean_house(CONFIG.ADDON_DATA)
        else:
            logging.log_notify('[COLOR {0}]Remove Addon Data[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    elif addon == 'uninstalled':  # clear addon data for uninstalled addons
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Você gostaria de remover [COLOR {1}]Todos[/COLOR] dados adicionais armazenados em sua pasta de dados do usuário para complementos desinstalados?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR springgreen]Remove Data[/COLOR][/B]',
                            nolabel='[B][COLOR red]Não Remove[/COLOR][/B]'):
                            
            total = 0
            
            for folder in glob.glob(os.path.join(CONFIG.ADDON_DATA, '*')):
                foldername = folder.replace(CONFIG.ADDON_DATA, '').replace('\\', '').replace('/', '')
                if foldername in CONFIG.EXCLUDES:
                    pass
                elif os.path.exists(os.path.join(CONFIG.ADDONS, foldername)):
                    pass
                elif os.path.isdir(folder):
                    tools.clean_house(folder)
                    total += 1
                    logging.log(folder)
                    shutil.rmtree(folder)
            logging.log_notify('[COLOR {0}]Limpeza desinstalada[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]{1} Pasta(s) Removido[/COLOR]'.format(CONFIG.COLOR2, total))
        else:
            logging.log_notify('[COLOR {0}]Remove Add-on Data[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    elif addon == 'empty':  # clear empty folders from addon_data
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Você gostaria de remover [COLOR {1}]Todos[/COLOR] esvazie as pastas de dados adicionais em sua pasta de dados do usuário?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR springgreen]Remove Data[/COLOR][/B]',
                            nolabel='[B][COLOR red]Não Remove[/COLOR][/B]'):
            total = tools.empty_folder(CONFIG.ADDON_DATA)
            logging.log_notify('[COLOR {0}]Remover pastas vazias[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]{1} Pasta(s) Removidas[/COLOR]'.format(CONFIG.COLOR2, total))
        else:
            logging.log_notify('[COLOR {0}]Remover pastas vazias[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    else:  # clear addon data for a specific addon
        addon_data = os.path.join(CONFIG.ADDON_DATA, addon)
        if addon in CONFIG.EXCLUDES:
            logging.log_notify("[COLOR {0}]Plugin protegido[/COLOR]".format(CONFIG.COLOR1),
                               "[COLOR {0}]Não tem permissão para remover add-on data[/COLOR]".format(CONFIG.COLOR2))
        elif os.path.exists(addon_data):
            if dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]Você também gostaria de remover o add-on data para:[/COLOR]'.format(CONFIG.COLOR2) + '\n' + '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, addon), yeslabel='[B][COLOR springgreen]Remove Data[/COLOR][/B]', nolabel='[B][COLOR red]Não Remove[/COLOR][/B]'):
                tools.clean_house(addon_data)
                try:
                    shutil.rmtree(addon_data)
                except:
                    logging.log("Error deleting: {0}".format(addon_data))
            else:
                logging.log('Add-on data para {0} não foi removido'.format(addon))
    xbmc.executebuiltin('Container.Refresh()')
Пример #17
0
def remove_addon_data(addon):
    dialog = xbmcgui.Dialog()

    if addon == 'all':  # clear ALL addon data
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Le gustaria quitar [COLOR {1}]ALL[/COLOR] datos adicionales almacenados en su carpeta de datos de usuario?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR springgreen]eliminar Data[/COLOR][/B]',
                            nolabel='[B][COLOR red]no eliminar[/COLOR][/B]'):
            tools.clean_house(CONFIG.ADDON_DATA)
        else:
            logging.log_notify('[COLOR {0}]eliminar Addon Data[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    elif addon == 'uninstalled':  # clear addon data for uninstalled addons
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Le gustaria quitar [COLOR {1}]ALL[/COLOR] datos de complementos almacenados en su carpeta de datos de usuario para complementos desinstalados?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR springgreen]eliminar Data[/COLOR][/B]',
                            nolabel='[B][COLOR red]no eliminar[/COLOR][/B]'):
                            
            total = 0
            
            for folder in glob.glob(os.path.join(CONFIG.ADDON_DATA, '*')):
                foldername = folder.replace(CONFIG.ADDON_DATA, '').replace('\\', '').replace('/', '')
                if foldername in CONFIG.EXCLUDES:
                    pass
                elif os.path.exists(os.path.join(CONFIG.ADDONS, foldername)):
                    pass
                elif os.path.isdir(folder):
                    tools.clean_house(folder)
                    total += 1
                    logging.log(folder)
                    shutil.rmtree(folder)
            logging.log_notify('[COLOR {0}]Limpiar Desinstalado[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]{1} Folders(s) borradas[/COLOR]'.format(CONFIG.COLOR2, total))
        else:
            logging.log_notify('[COLOR {0}]eliminar  Add-on Data[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    elif addon == 'empty':  # clear empty folders from addon_data
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Le gustaria quitar [COLOR {1}]ALL[/COLOR] Carpetas de datos adicionales vacías en su carpeta de datos de usuario?[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1),
                            yeslabel='[B][COLOR springgreen]eliminar Data[/COLOR][/B]',
                            nolabel='[B][COLOR red]No quitar[/COLOR][/B]'):
            total = tools.empty_folder(CONFIG.ADDON_DATA)
            logging.log_notify('[COLOR {0}]Eliminar carpetas vacías[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]{1} Carpetas eliminadas[/COLOR]'.format(CONFIG.COLOR2, total))
        else:
            logging.log_notify('[COLOR {0}]Eliminar carpetas vacías[/COLOR]'.format(CONFIG.COLOR1),
                               '[COLOR {0}]Cancelled![/COLOR]'.format(CONFIG.COLOR2))
    else:  # clear addon data for a specific addon
        addon_data = os.path.join(CONFIG.ADDON_DATA, addon)
        if addon in CONFIG.EXCLUDES:
            logging.log_notify("[COLOR {0}]Protected Plugin[/COLOR]".format(CONFIG.COLOR1),
                               "[COLOR {0}]No se permite eliminar datos complementarios[/COLOR]".format(CONFIG.COLOR2))
        elif os.path.exists(addon_data):
            if dialog.yesno(CONFIG.ADDONTITLE, '[COLOR {0}]¿También le gustaría eliminar los datos complementarios para:[/COLOR]'.format(CONFIG.COLOR2) + '\n' + '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, addon), yeslabel='[B][COLOR springgreen]eliminar Data[/COLOR][/B]', nolabel='[B][COLOR red]No quitar[/COLOR][/B]'):
                tools.clean_house(addon_data)
                try:
                    shutil.rmtree(addon_data)
                except:
                    logging.log("Error deleting: {0}".format(addon_data))
            else:
                logging.log('Add-on data for {0} was not removed'.format(addon))
    xbmc.executebuiltin('Container.Refresh()')
Пример #18
0
def cleanup_backup():
    folder = glob.glob(os.path.join(CONFIG.MYBUILDS, "*"))
    logging.log(folder)
    list = []
    filelist = []

    dialog = xbmcgui.Dialog()

    if len(folder) == 0:
        logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                           "[COLOR {0}]Backup Location: Empty[/COLOR]".format(CONFIG.COLOR2))
        return
    for item in sorted(folder, key=os.path.getmtime):
        filelist.append(item)
        base = item.replace(CONFIG.MYBUILDS, '')
        if os.path.isdir(item):
            list.append('/{0}/'.format(base))
        elif os.path.isfile(item):
            list.append(base)
    list = ['--- Remove All Items ---'] + list
    selected = dialog.select("{0}: Select the items to remove from the 'My_Builds' folder.".format(CONFIG.ADDONTITLE), list)

    if selected == -1:
        logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                           "[COLOR {0}]Clean Up Cancelled![/COLOR]".format(CONFIG.COLOR2))
    elif selected == 0:
        if dialog.yesno(CONFIG.ADDONTITLE,
                            "[COLOR {0}]Would you like to clean up all items in your 'My_Builds' folder?[/COLOR]".format(CONFIG.COLOR2),
                            "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.MYBUILDS),
                            yeslabel="[B][COLOR springgreen]Clean Up[/COLOR][/B]",
                            nolabel="[B][COLOR red]No Cancel[/COLOR][/B]"):
            clearedfiles, clearedfolders = tools.clean_house(CONFIG.MYBUILDS)
            logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                               "[COLOR {0}]Removed Files: [COLOR {1}]{2}[/COLOR] / Folders:[/COLOR] [COLOR {3}]{4}[/COLOR]".format(CONFIG.COLOR2, CONFIG.COLOR1, clearedfiles, CONFIG.COLOR1, clearedfolders))
        else:
            logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                               "[COLOR {0}]Clean Up Cancelled![/COLOR]".format(CONFIG.COLOR2))
    else:
        path = filelist[selected-1]
        passed = False

        if dialog.yesno(CONFIG.ADDONTITLE,
                            "[COLOR {0}]Would you like to remove [COLOR {1}]{2}[/COLOR] from the 'My_Builds' folder?[/COLOR]".format(CONFIG.COLOR2, CONFIG.COLOR1, list[selected]),
                            "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, path),
                            yeslabel="[B][COLOR springgreen]Clean Up[/COLOR][/B]",
                            nolabel="[B][COLOR red]No Cancel[/COLOR][/B]"):
            if os.path.isfile(path):
                try:
                    os.remove(path)
                    passed = True
                except:
                    logging.log("Unable to remove: {0}".format(path))
            else:
                tools.clean_house(path)
                try:
                    shutil.rmtree(path)
                    passed = True
                except Exception as e:
                    logging.log("Error removing {0}: {1}".format(path, e))
            if passed:
                logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                                   "[COLOR {0}]{1} Removed![/COLOR]".format(CONFIG.COLOR2, list[selected]))
            else:
                logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                                   "[COLOR {0}]Error Removing {1}![/COLOR]".format(CONFIG.COLOR2, list[selected]))
        else:
            logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE),
                               "[COLOR {0}]Clean Up Cancelled![/COLOR]".format(CONFIG.COLOR2))