def get_files(): logfiles = [] log = grab_log(file=True) old = grab_log(file=True, old=True) wizard = False if not os.path.exists(CONFIG.WIZLOG) else CONFIG.WIZLOG if log: if os.path.exists(log): logfiles.append(['log', log]) else: show_result("No log file found") else: show_result("No log file found") if CONFIG.KEEPOLDLOG: if old: if os.path.exists(old): logfiles.append(['oldlog', old]) else: show_result("No old log file found") else: show_result("No old log file found") if CONFIG.KEEPWIZLOG: if wizard: logfiles.append(['wizlog', wizard]) else: show_result("No wizard log file found") if CONFIG.KEEPCRASHLOG: from resources.libs.common import tools crashlog_path = '' items = [] if xbmc.getCondVisibility('system.platform.osx'): crashlog_path = os.path.join(os.path.expanduser('~'), 'Library/Logs/DiagnosticReports/') filematch = 'Kodi' elif xbmc.getCondVisibility('system.platform.ios'): crashlog_path = '/var/mobile/Library/Logs/CrashReporter/' filematch = 'Kodi' elif tools.platform() == 'linux': # not 100% accurate (crashlogs can be created in the dir kodi was started from as well) crashlog_path = os.path.expanduser('~') filematch = 'kodi_crashlog' elif tools.platform() == 'windows': log("Windows crashlogs are not supported, please disable this option in the addon settings" ) elif tools.platform() == 'android': log("Android crashlogs are not supported, please disable this option in the addon settings" ) if crashlog_path and os.path.isdir(crashlog_path): dirs, files = xbmcvfs.listdir(crashlog_path) for item in files: if filematch in item and os.path.isfile( os.path.join(crashlog_path, item)): items.append(os.path.join(crashlog_path, item)) items.sort(key=lambda f: os.path.getmtime(f)) lastcrash = items[-1] logfiles.append(['crashlog', lastcrash]) if len(items) == 0: log("No crashlog file found") return logfiles
def get_files(): logfiles = [] kodilog = grab_log(file=True) old = grab_log(file=True, old=True) wizard = False if not os.path.exists(CONFIG.WIZLOG) else CONFIG.WIZLOG if kodilog: if os.path.exists(kodilog): logfiles.append(['log', kodilog]) else: show_result("Nenhum arquivo de log encontrado") else: show_result("Nenhum arquivo de log encontrado") if CONFIG.KEEPOLDLOG: if old: if os.path.exists(old): logfiles.append(['oldlog', old]) else: show_result("Nenhum arquivo de log antigo encontrado") else: show_result("Nenhum arquivo de log antigo encontrado") if CONFIG.KEEPWIZLOG: if wizard: logfiles.append(['wizlog', wizard]) else: show_result("Nenhum arquivo de log do assistente encontrado") if CONFIG.KEEPCRASHLOG: crashlog_path = '' items = [] if xbmc.getCondVisibility('system.platform.osx'): crashlog_path = os.path.join(os.path.expanduser('~'), 'Library/Logs/DiagnosticReports/') filematch = 'Kodi' elif xbmc.getCondVisibility('system.platform.ios'): crashlog_path = '/var/mobile/Library/Logs/CrashReporter/' filematch = 'Kodi' elif tools.platform() == 'linux': # not 100% accurate (crashlogs can be created in the dir kodi was started from as well) crashlog_path = os.path.expanduser('~') filematch = 'kodi_crashlog' elif tools.platform() == 'windows': log("Não há suporte para logs de travamento do Windows, desative esta opção nas configurações do complemento" ) elif tools.platform() == 'android': log("Não há suporte para crashlogs do Android, desative esta opção nas configurações do complemento" ) if crashlog_path and os.path.isdir(crashlog_path): dirs, files = xbmcvfs.listdir(crashlog_path) for item in files: if filematch in item and os.path.isfile( os.path.join(crashlog_path, item)): items.append(os.path.join(crashlog_path, item)) items.sort(key=lambda f: os.path.getmtime(f)) lastcrash = items[-1] logfiles.append(['crashlog', lastcrash]) if len(items) == 0: log("Nenhum arquivo de crashlog encontrado") return logfiles
def get_files(): logfiles = [] kodilog = grab_log(file=True) old = grab_log(file=True, old=True) wizard = False if not os.path.exists(CONFIG.WIZLOG) else CONFIG.WIZLOG if kodilog: if os.path.exists(kodilog): logfiles.append(['log', kodilog]) else: show_result("No se encontró ningún archivo de registro") else: show_result("No se encontró ningún archivo de registro") if CONFIG.KEEPOLDLOG: if old: if os.path.exists(old): logfiles.append(['oldlog', old]) else: show_result("No se encontró ningún archivo de registro antiguo") else: show_result("No se encontró ningún archivo de registro antiguo") if CONFIG.KEEPWIZLOG: if wizard: logfiles.append(['wizlog', wizard]) else: show_result("No se encontró ningún archivo de registro del wizard") if CONFIG.KEEPCRASHLOG: crashlog_path = '' items = [] if xbmc.getCondVisibility('system.platform.osx'): crashlog_path = os.path.join(os.path.expanduser('~'), 'Library/Logs/DiagnosticReports/') filematch = 'Kodi' elif xbmc.getCondVisibility('system.platform.ios'): crashlog_path = '/var/mobile/Library/Logs/CrashReporter/' filematch = 'Kodi' elif tools.platform() == 'linux': # not 100% accurate (crashlogs can be created in the dir kodi was started from as well) crashlog_path = os.path.expanduser('~') filematch = 'kodi_crashlog' elif tools.platform() == 'windows': log("Los registros de fallos de Windows no son compatibles, desactive esta opción en la configuración del add-on") elif tools.platform() == 'android': log("Los registros de fallos de Android no son compatibles, desactive esta opción en la configuración del add-on") if crashlog_path and os.path.isdir(crashlog_path): dirs, files = xbmcvfs.listdir(crashlog_path) for item in files: if filematch in item and os.path.isfile(os.path.join(crashlog_path, item)): items.append(os.path.join(crashlog_path, item)) items.sort(key=lambda f: os.path.getmtime(f)) lastcrash = items[-1] logfiles.append(['crashlog', lastcrash]) if len(items) == 0: log("No se encontró ningún archivo de registro de fallos") return logfiles
def install_apk(apk, 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() logging.log(apk) logging.log(url) if tools.platform() == 'android': yes = dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]Would you like to download and install: ".format(CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, apk), 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 display = apk if not os.path.exists(CONFIG.PACKAGES): os.makedirs(CONFIG.PACKAGES) 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, display), '', 'Please Wait') lib = os.path.join(CONFIG.PACKAGES, "{0}.apk".format(apk.replace('\\', '').replace('/', '').replace(':', '').replace('*', '').replace('?', '').replace('"', '').replace('<', '').replace('>', '').replace('|', ''))) try: os.remove(lib) except: pass Downloader().download(url, lib) xbmc.sleep(100) progress_dialog.close() window.show_apk_warning(apk) xbmc.executebuiltin('StartAndroidActivity("","android.intent.action.VIEW","application/vnd.android.package-archive","file:{0}")'.format(lib)) else: logging.log_notify(CONFIG.ADDONTITLE, '[COLOR {0}]ERROR: None Android Device[/COLOR]'.format(CONFIG.COLOR2))
def copy_to_clipboard(txt): import subprocess platform = tools.platform() if platform == 'windows': try: cmd = 'echo ' + txt.strip() + '|clip' return subprocess.check_call(cmd, shell=True) pass except: pass elif platform == 'linux': try: from subprocess import Popen, PIPE p = Popen(['xsel', '-pi'], stdin=PIPE) p.communicate(input=txt) except: pass else: pass
def get_listing(self): from resources.libs import check from resources.libs.common import logging from resources.libs.common import tools errors = int(logging.error_checking(count=True)) errorsfound = str(errors) + ' Error(es) Encontrado' if errors > 0 else 'Nada Encontrado' if CONFIG.AUTOUPDATE == 'Yes': response = tools.open_url(CONFIG.BUILDFILE, check=True) if response: ver = check.check_wizard('version') if ver: if ver > CONFIG.ADDON_VERSION: directory.add_file( '{0} [v{1}] [COLOR red][B][ACTUALIZACIÓN v{2}][/B][/COLOR]'.format(CONFIG.ADDONTITLE, CONFIG.ADDON_VERSION, ver), {'mode': 'wizardupdate'}, themeit=CONFIG.THEME2) else: directory.add_file('{0} [v{1}]'.format(CONFIG.ADDONTITLE, CONFIG.ADDON_VERSION), themeit=CONFIG.THEME2) else: directory.add_file('{0} [v{1}]'.format(CONFIG.ADDONTITLE, CONFIG.ADDON_VERSION), themeit=CONFIG.THEME2) else: directory.add_file('{0} [v{1}]'.format(CONFIG.ADDONTITLE, CONFIG.ADDON_VERSION), themeit=CONFIG.THEME2) if len(CONFIG.BUILDNAME) > 0: version = check.check_build(CONFIG.BUILDNAME, 'version') build = '[B]{0} - v{1}[/B]'.format(CONFIG.BUILDNAME, CONFIG.BUILDVERSION) if version > CONFIG.BUILDVERSION: build = '{0} [COLOR red][B][ACTUALIZACIÓN v{1}][/B][/COLOR]'.format(build, version) directory.add_dir(build, {'mode': 'viewbuild', 'name': CONFIG.BUILDNAME}, themeit=CONFIG.THEME4) from resources.libs.gui.build_menu import BuildMenu themefile = BuildMenu().theme_count(CONFIG.BUILDNAME) if themefile: directory.add_file('Nada' if CONFIG.BUILDTHEME == "" else CONFIG.BUILDTHEME, {'mode': 'theme', 'name': CONFIG.BUILDNAME}, themeit=CONFIG.THEME5) else: directory.add_dir('Nada', {'mode': 'builds'}, themeit=CONFIG.THEME4) directory.add_separator() directory.add_dir('[B][COLOR dodgerblue]BUILDS[/COLOR] - [COLOR dodgerblue]PARCHES[/COLOR][/B]', {'mode': 'builds'}, icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME1) directory.add_dir('[B]Mantenimiento[/B]', {'mode': 'maint'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME1) if (tools.platform() == 'android' or CONFIG.DEVELOPER == 'true'): directory.add_dir('Instalador de APK', {'mode': 'apk'}, icon=CONFIG.ICONAPK, themeit=CONFIG.THEME1) if tools.open_url(CONFIG.ADDONFILE, check=True) or os.path.exists(os.path.join(CONFIG.ADDON_PATH, 'resources', 'text', 'addons.json')): directory.add_dir('Instalador de Addon', {'mode': 'addons'}, icon=CONFIG.ICONADDONS, themeit=CONFIG.THEME1) if tools.open_url(CONFIG.YOUTUBEFILE, check=True) and not CONFIG.YOUTUBETITLE == '': directory.add_dir(CONFIG.YOUTUBETITLE, {'mode': 'youtube'}, icon=CONFIG.ICONYOUTUBE, themeit=CONFIG.THEME1) directory.add_dir('[B]Guardar Datos[/B]', {'mode': 'savedata'}, icon=CONFIG.ICONSAVE, themeit=CONFIG.THEME1) if CONFIG.HIDECONTACT == 'No': directory.add_file('Contacto', {'mode': 'contact'}, icon=CONFIG.ICONCONTACT, themeit=CONFIG.THEME1) directory.add_separator() directory.add_file('Cargar Archivo de Registro', {'mode': 'uploadlog'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME1) directory.add_file('[B]Ver Errores en el Registro:[/B] [COLOR teal]{0}[/COLOR]'.format(errorsfound), {'mode': 'viewerrorlog'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME1) if errors > 0: directory.add_file('Ver el Ultimo Error en el Registro', {'mode': 'viewerrorlast'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME1) directory.add_separator() directory.add_file('[B]Ajustes[/B]', {'mode': 'settings', 'name': CONFIG.ADDON_ID}, icon=CONFIG.ICONSETTINGS, themeit=CONFIG.THEME1) if CONFIG.DEVELOPER == 'true': directory.add_dir('Menú de Desarrollador', {'mode': 'developer'}, icon=CONFIG.ADDON_ICON, themeit=CONFIG.THEME1)
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))
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))
def system_info(): from resources.libs.common import logging from resources.libs.common import tools from resources.libs import speedtest infoLabel = ['System.FriendlyName', 'System.BuildVersion', 'System.CpuUsage', 'System.ScreenMode', 'Network.IPAddress', 'Network.MacAddress', 'System.Uptime', 'System.TotalUptime', 'System.FreeSpace', 'System.UsedSpace', 'System.TotalSpace', 'System.Memory(free)', 'System.Memory(used)', 'System.Memory(total)'] data = [] x = 0 for info in infoLabel: temp = tools.get_info_label(info) y = 0 while temp == "Busy" and y < 10: temp = tools.get_info_label(info) y += 1 logging.log("{0} sleep {1}".format(info, str(y))) xbmc.sleep(200) data.append(temp) x += 1 storage_free = data[8] if 'Una' in data[8] else tools.convert_size(int(float(data[8][:-8])) * 1024 * 1024) storage_used = data[9] if 'Una' in data[9] else tools.convert_size(int(float(data[9][:-8])) * 1024 * 1024) storage_total = data[10] if 'Una' in data[10] else tools.convert_size(int(float(data[10][:-8])) * 1024 * 1024) ram_free = tools.convert_size(int(float(data[11][:-2])) * 1024 * 1024) ram_used = tools.convert_size(int(float(data[12][:-2])) * 1024 * 1024) ram_total = tools.convert_size(int(float(data[13][:-2])) * 1024 * 1024) picture = [] music = [] video = [] programs = [] repos = [] scripts = [] skins = [] fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/')) for folder in sorted(fold, key = lambda x: x): foldername = os.path.split(folder[:-1])[1] if foldername == 'packages': continue xml = os.path.join(folder, 'addon.xml') if os.path.exists(xml): prov = re.compile("<provides>(.+?)</provides>").findall(tools.read_from_file(xml)) if len(prov) == 0: if foldername.startswith('skin'): skins.append(foldername) elif foldername.startswith('repo'): repos.append(foldername) else: scripts.append(foldername) elif not (prov[0]).find('executable') == -1: programs.append(foldername) elif not (prov[0]).find('video') == -1: video.append(foldername) elif not (prov[0]).find('audio') == -1: music.append(foldername) elif not (prov[0]).find('image') == -1: picture.append(foldername) directory.add_file('[B]Media Center Info:[/B]', icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Name:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, data[0]), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME3) directory.add_file('[COLOR {0}]Version:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, data[1]), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME3) directory.add_file('[COLOR {0}]Platform:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, tools.platform().title()), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME3) directory.add_file('[COLOR {0}]CPU Usage:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, data[2]), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME3) directory.add_file('[COLOR {0}]Screen Mode:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, data[3]), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME3) directory.add_file('[B]Uptime:[/B]', icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Current Uptime:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, data[6]), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Total Uptime:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, data[7]), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[B]Local Storage:[/B]', icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Used Storage:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, storage_used), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Free Storage:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, storage_free), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Total Storage:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, storage_total), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[B]Ram Usage:[/B]', icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Used Memory:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, ram_free), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Free Memory:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, ram_used), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Total Memory:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, ram_total), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) mac, inter_ip, ip, city, state, country, isp = speedtest.net_info() directory.add_file('[B]Network:[/B]', icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Mac:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, mac), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Internal IP: [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, inter_ip), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]External IP:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, ip), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]City:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, city), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]State:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, state), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Country:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, country), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]ISP:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, isp), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) totalcount = len(picture) + len(music) + len(video) + len(programs) + len(scripts) + len(skins) + len(repos) directory.add_file('[B]Addons([COLOR {0}]{1}[/COLOR]):[/B]'.format(CONFIG.COLOR1, totalcount), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Video Addons:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, str(len(video))), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Program Addons:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, str(len(programs))), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Music Addons:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, str(len(music))), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Picture Addons:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, str(len(picture))), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Repositories:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, str(len(repos))), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Skins:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, str(len(skins))), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2) directory.add_file('[COLOR {0}]Scripts/Modules:[/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR1, CONFIG.COLOR2, str(len(scripts))), icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME2)
def get_listing(self): from resources.libs import check from resources.libs.common import logging from resources.libs.common import tools errors = int(logging.error_checking(count=True)) errorsfound = str(errors) + ' Error(s) Found' if errors > 0 else 'None Found' if CONFIG.AUTOUPDATE == 'Yes': response = tools.open_url(CONFIG.BUILDFILE, check=True) if response: ver = check.check_wizard('version') if ver: if ver > CONFIG.ADDON_VERSION: directory.add_file( '{0} [v{1}] [COLOR red][B][UPDATE v{2}][/B][/COLOR]'.format(CONFIG.ADDONTITLE, CONFIG.ADDON_VERSION, ver), {'mode': 'wizardupdate'}, themeit=CONFIG.THEME2) else: directory.add_file('{0} [v{1}]'.format(CONFIG.ADDONTITLE, CONFIG.ADDON_VERSION), themeit=CONFIG.THEME2) else: directory.add_file('{0} [v{1}]'.format(CONFIG.ADDONTITLE, CONFIG.ADDON_VERSION), themeit=CONFIG.THEME2) else: directory.add_file('{0} [v{1}]'.format(CONFIG.ADDONTITLE, CONFIG.ADDON_VERSION), themeit=CONFIG.THEME2) if len(CONFIG.BUILDNAME) > 0: version = check.check_build(CONFIG.BUILDNAME, 'version') build = '{0} (v{1})'.format(CONFIG.BUILDNAME, CONFIG.BUILDVERSION) if version > CONFIG.BUILDVERSION: build = '{0} [COLOR red][B][UPDATE v{1}][/B][/COLOR]'.format(build, version) directory.add_dir(build, {'mode': 'viewbuild', 'name': CONFIG.BUILDNAME}, themeit=CONFIG.THEME4) from resources.libs.gui.build_menu import BuildMenu themefile = BuildMenu().theme_count(CONFIG.BUILDNAME) if themefile: directory.add_file('None' if CONFIG.BUILDTHEME == "" else CONFIG.BUILDTHEME, {'mode': 'theme', 'name': CONFIG.BUILDNAME}, themeit=CONFIG.THEME5) else: directory.add_dir('None', {'mode': 'builds'}, themeit=CONFIG.THEME4) directory.add_separator() directory.add_dir('Builds', {'mode': 'builds'}, icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME1) directory.add_dir('Maintenance', {'mode': 'maint'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME1) if (tools.platform() == 'android' or CONFIG.DEVELOPER == 'true') and CONFIG.KODIV < 18: directory.add_dir('APK Installer', {'mode': 'apk'}, icon=CONFIG.ICONAPK, themeit=CONFIG.THEME1) if tools.open_url(CONFIG.ADDONFILE, check=True) or os.path.exists(os.path.join(CONFIG.ADDON_PATH, 'resources', 'text', 'addons.json')): directory.add_dir('Addon Installer', {'mode': 'addons'}, icon=CONFIG.ICONADDONS, themeit=CONFIG.THEME1) if tools.open_url(CONFIG.YOUTUBEFILE, check=True) and not CONFIG.YOUTUBETITLE == '': directory.add_dir(CONFIG.YOUTUBETITLE, {'mode': 'youtube'}, icon=CONFIG.ICONYOUTUBE, themeit=CONFIG.THEME1) directory.add_dir('Save Data', {'mode': 'savedata'}, icon=CONFIG.ICONSAVE, themeit=CONFIG.THEME1) if CONFIG.HIDECONTACT == 'No': directory.add_file('Contact', {'mode': 'contact'}, icon=CONFIG.ICONCONTACT, themeit=CONFIG.THEME1) directory.add_separator() directory.add_file('Upload Log File', {'mode': 'uploadlog'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME1) directory.add_file('View Errors in Log: {0}'.format(errorsfound), {'mode': 'viewerrorlog'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME1) if errors > 0: directory.add_file('View Last Error In Log', {'mode': 'viewerrorlast'}, icon=CONFIG.ICONMAINT, themeit=CONFIG.THEME1) directory.add_separator() directory.add_file('Settings', {'mode': 'settings', 'name': CONFIG.ADDON_ID}, icon=CONFIG.ICONSETTINGS, themeit=CONFIG.THEME1) if CONFIG.DEVELOPER == 'true': directory.add_dir('Developer Menu', {'mode': 'developer'}, icon=CONFIG.ADDON_ICON, themeit=CONFIG.THEME1)
def get_listing(self): from resources.libs import test response = tools.open_url(CONFIG.BUILDFILE) if response: link = tools.clean_text(response.text) else: directory.add_file('Bạn đang dùng Kodi: {0} {1}'.format( CONFIG.KODIV, tools.platform().title()), icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) directory.add_separator() directory.add_file('Hiện tại không có bản Build nào để sử dụng', icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) return # total, count17, count18, count19, adultcount, hidden = check.build_count() # match = re.compile('name="(.+?)".+?ersion="(.+?)".+?rl="(.+?)".+?ui="(.+?)".+?odi="(.+?)".+?heme="(.+?)".+?con="(.+?)".+?anart="(.+?)".+?dult="(.+?)".+?escription="(.+?)"').findall(link) match = re.compile( 'name="(.+?)".+?rl="(.+?)".+?con="(.+?)".+?anart="(.+?)".+?escription="(.+?)"' ).findall(link) # if total == 1: # for name, version, url, gui, kodi, theme, icon, fanart, adult, description in match: # if not CONFIG.SHOWADULT == 'true' and adult.lower() == 'yes': # continue # if not CONFIG.DEVELOPER == 'true' and test.str_test(name): # continue # self.view_build(match[0][0]) # return if not CONFIG.get_setting('buildlink') == '': directory.add_file('Custom Build URL: [COLOR yellow]%s[/COLOR]' % (CONFIG.BUILDFILE), {'mode': ''}, icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) directory.add_file( '[COLOR yellow][B]Reset:[/B][/COLOR] Xóa link trả về mặc định', {'mode': 'clearurl'}, icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) directory.add_file('Bạn đang dùng Kodi: {0} {1}'.format( CONFIG.KODIV, tools.platform().title()), icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) directory.add_file( '===== [COLOR red][B]CHỌN BẢN CUSTOM BUILD MUỐN SỬ DỤNG[/B][/COLOR] =====', icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) self._list_build(match) else: directory.add_dir( '[COLOR yellow][B]Custom Build URL:[/B][/COLOR] Nhập list của bạn', { 'mode': 'inputurl', 'name': 'buildlink' }, icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) directory.add_file('Bạn đang dùng Kodi: {0} {1}'.format( CONFIG.KODIV, tools.platform().title()), icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) # directory.add_dir('Save Data Menu', {'mode': 'savedata'}, icon=CONFIG.ICONSAVE, themeit=CONFIG.THEME3) directory.add_file( '===== [COLOR red][B]CHỌN BẢN BUILD MUỐN SỬ DỤNG[/B][/COLOR] =====', icon=CONFIG.ICONBUILDS, themeit=CONFIG.THEME3) # directory.add_separator() self._list_build(match)