def list_history(): if xbmcvfs.exists(history_file): lines = open(history_file).readlines() i=0 for line in lines: info = line.split('|') if i < int(settings.getSetting('items_per_page')): try: addDir(info[0],info[1],int(info[2]),info[3].replace('\n',''),1,False) except: pass i+=1 else: sys.exit(0)
def addon_favourites(): if os.path.exists(os.path.join(pastaperfil,"Favourites")): dirs, files = xbmcvfs.listdir(os.path.join(pastaperfil,"Favourites")) if files: for file in files: string = readfile(os.path.join(pastaperfil,"Favourites",file)) match = string.split("|") try: iconimage = match[3] except: if 'acestream' in file: iconimage = addonpath + art + 'acelogofull.png' elif 'sop' in file: iconimage = addonpath + art + 'sopcast_logo.jpg' else: iconimage = '' addDir("[B][COLOR orange]" + match[0] + "[/B][/COLOR]",match[2],int(match[1]),iconimage,1,False) addDir('[B]' + translate(70022) + '[/B]',MainURL,203,addonpath + art + 'plus-menu.png',2,False) xbmc.executebuiltin("Container.SetViewMode(51)")
def addon_favourites(): if os.path.exists(os.path.join(pastaperfil, "Favourites")): dirs, files = xbmcvfs.listdir(os.path.join(pastaperfil, "Favourites")) if files: for file in files: string = readfile(os.path.join(pastaperfil, "Favourites", file)) match = string.split("|") try: iconimage = match[3] except: if 'acestream' in file: iconimage = addonpath + art + 'acelogofull.png' elif 'sop' in file: iconimage = addonpath + art + 'sopcast_logo.jpg' else: iconimage = '' addDir("[B][COLOR orange]" + match[0] + "[/B][/COLOR]", match[2], int(match[1]), iconimage, 1, False) addDir('[B]' + translate(70022) + '[/B]', MainURL, 203, addonpath + art + 'plus-menu.png', 2, False) xbmc.executebuiltin("Container.SetViewMode(51)")
def advanced_menu(): addLink('[COLOR orange]XBMC Advancedsettings.xml:[/COLOR]', '', addonpath + art + 'settings_menu.png') lock_file = xbmc.translatePath('special://temp/' + 'ts.lock') if xbmcvfs.exists(lock_file): addDir(translate(40068), MainURL, 306, '', 2, False) userdatapath = xbmc.translatePath( os.path.join('special://home/userdata'.decode('utf-8'), ''.decode('utf-8'))) advancedsettings_var = os.path.join(userdatapath, 'advancedsettings.xml') advancedsettingsbackup_var = os.path.join(userdatapath, 'advancedsettingsbackup.xml') addDir(translate(40058), MainURL, 301, 'p2p', 2, False) if xbmcvfs.exists(advancedsettings_var): addDir(translate(40063), MainURL, 303, 'p2p', 2, False) addDir(translate(40065), MainURL, 304, 'p2p', 2, False) if xbmcvfs.exists(advancedsettingsbackup_var): addDir(translate(40061), MainURL, 302, 'p2p', 2, False) addLink('', '', 'p2p') if xbmcvfs.exists(advancedsettings_var): content = readfile(advancedsettings_var) match = re.compile( '<cachemembuffersize>(.+?)</cachemembuffersize>').findall(content) if match: if match[0] != '252420': valuebuff = '[COLOR red]' + match[0] + '[/COLOR]' else: valuebuff = '[COLOR green]' + match[0] + '[/COLOR]' addLink(translate(40067) + valuebuff + ']', '', 'p2p') addLink('', '', 'p2p') #Apply shutdown hooks addLink('[COLOR orange]' + translate(70025) + '[/COLOR]', '', addonpath + art + 'settings_menu.png') addDir(translate(70026), MainURL, 310, 'p2p', 2, False) #Change engine settings from xbmc menus eligible = False if xbmc.getCondVisibility('system.platform.linux') and settings.getSetting( 'force_android') != "true": if os.uname()[4] == "armv6l" or os.uname()[4] == "armv7l": eligible = True elif xbmc.getCondVisibility('system.platform.OSX'): eligible = False elif settings.getSetting('openeleci386') == "true": eligible = False elif settings.getSetting('force_android') == "true": eligible = False else: eligible = False if eligible and os.path.exists( os.path.join(pastaperfil, 'acestream', 'ace', 'ACEStream', 'values')): addLink('[COLOR orange]Acestream engine settings:[/COLOR]', '', addonpath + art + 'settings_menu.png') acestream_cachefolder = os.path.join(os.getenv("HOME"), '.ACEStream', 'cache') acestream_cache_size = str( int(getDirectorySize(acestream_cachefolder)) / (1024 * 1024)) addDir( translate(70003) + '[COLOR orange] [' + acestream_cache_size + ' MB][/COLOR]', acestream_cachefolder, 307, 'p2p', 1, False) try: porta = readfile( os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "port.txt")) except: porta = "N/A" try: acestream_settings_file = os.path.join(os.getenv("HOME"), '.ACEStream', 'sessconfig.pickle') sessconfig = readfile(acestream_settings_file) portvector = re.compile("S'minport'\np(\d+)\nI(\d+)\n").findall( sessconfig) maxport = re.compile("S'maxport'\np(\d+)\nI(\d+)\n").findall( sessconfig) except: portvector = [] maxport = [] addDir( translate(600015) + "[COLOR orange][ " + str(int(porta)) + " ][/COLOR]", os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "port.txt") + '|' + str(portvector) + '|' + str(maxport), 305, 'p2p', 2, False) try: vodbuffer = readfile( os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "vodbuffer.txt")) except: vodbuffer = "N/A" addDir( translate(600016) + "[COLOR orange][ " + str(int(vodbuffer)) + " ][/COLOR]", os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "vodbuffer.txt"), 305, 'p2p', 2, False) try: livebuffer = readfile( os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "livebuffer.txt")) except: livebuffer = "N/A" addDir( translate(600017) + "[COLOR orange][ " + str(int(livebuffer)) + " ][/COLOR]", os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "livebuffer.txt"), 305, 'p2p', 2, False) try: downloadlimit = readfile( os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "downloadlimit.txt")) except: downloadlimit = "N/A" addDir( translate(600018) + "[COLOR orange][ " + str(int(downloadlimit)) + " ][/COLOR]", os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "downloadlimit.txt"), 305, 'p2p', 2, False) try: uploadlimit = readfile( os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "uploadlimit.txt")) except: uploadlimit = "N/A" addDir( translate(600019) + "[COLOR orange][ " + str(int(uploadlimit)) + " ][/COLOR]", os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "uploadlimit.txt"), 305, 'p2p', 2, False) try: maxconnections = readfile( os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "maxconnections.txt")) except: maxconnections = "N/A" addDir( translate(600020) + "[COLOR orange][ " + str(int(maxconnections)) + " ][/COLOR]", os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "maxconnections.txt"), 305, 'p2p', 2, False) try: maxconnectionsstream = readfile( os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "maxconnectionsstream.txt")) except: maxconnectionsstream = "N/A" addDir( translate(600021) + "[COLOR orange][ " + str(int(maxconnectionsstream)) + " ][/COLOR]", os.path.join(pastaperfil, "acestream", "ace", "ACEStream", "values", "maxconnectionsstream.txt"), 305, '', 2, False) elif eligible and not os.path.exists( os.path.join(pastaperfil, 'acestream', 'ace', 'ACEStream', 'values')): addLink("[COLOR red][B]" + translate(600027) + "[/COLOR][/B]", "", addonpath + art + 'processwarning.png') else: pass if (not eligible and xbmc.getCondVisibility('system.platform.linux') and settings.getSetting('ace_cmd') == "0") or ( not eligible and xbmc.getCondVisibility('system.platform.windows')) or ( not eligible and xbmc.getCondVisibility('system.platform.Android') and settings.getSetting('engine_app') == "0") or (settings.getSetting('force_android') == "true" and settings.getSetting('engine_app') == "0"): if xbmc.getCondVisibility( 'system.platform.linux' ) and not xbmc.getCondVisibility('system.platform.Android'): default_acefolder = os.path.join(os.getenv("HOME"), '.ACEStream') default_cachefolder = os.path.join(os.getenv("HOME"), '.ACEStream', 'cache', '.acestream_cache') pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Linux/playerconf.pickle' if settings.getSetting('acestream_cachefolder') == '': acestream_cachefolder = os.path.join(os.getenv("HOME"), '.ACEStream', 'cache', '.acestream_cache') else: acestream_cachefolder = settings.getSetting( 'acestream_cachefolder') acestream_settings_file = os.path.join(os.getenv("HOME"), '.ACEStream', 'playerconf.pickle') elif xbmc.getCondVisibility('system.platform.Android'): default_acefolder = os.path.join('/sdcard', '.ACEStream') default_cachefolder = os.path.join('/sdcard', '.ACEStream', '.acestream_cache') pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Android/playerconf.pickle' if settings.getSetting('acestream_cachefolder') == '': acestream_cachefolder = os.path.join('/sdcard', '.ACEStream', '.acestream_cache') else: acestream_cachefolder = os.path.join( settings.getSetting('acestream_cachefolder'), '.acestream_cache') if not os.path.exists(acestream_cachefolder): xbmcvfs.mkdir(acestream_cachefolder) acestream_settings_file = os.path.join('/sdcard', '.ACEStream', 'playerconf.pickle') elif xbmc.getCondVisibility('system.platform.windows'): default_acefolder = os.path.join(os.getenv("APPDATA"), ".ACEStream") pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Windows/playerconf.pickle' default_cachefolder = os.path.join(os.getenv("SystemDrive"), '\_acestream_cache_') acestream_cachefolder = default_cachefolder acestream_settings_file = os.path.join(os.getenv("APPDATA"), ".ACEStream", "playerconf.pickle") #workaround to keep settings file in place if they get deleted if not os.path.exists(default_acefolder): xbmcvfs.mkdir(default_acefolder) if not os.path.exists(default_cachefolder): xbmcvfs.mkdir(default_cachefolder) if not os.path.exists(acestream_settings_file): local_file = os.path.join(default_acefolder, pickle_repo.split("/")[-1]) download_tools().Downloader(pickle_repo, local_file, '', translate(40000)) xbmc.sleep(200) if xbmcvfs.exists(acestream_settings_file): settings_text = readfile(acestream_settings_file) save( acestream_settings_file, settings_text.replace('my_cache_folder', default_cachefolder)) if xbmcvfs.exists(acestream_settings_file) and os.path.exists( acestream_cachefolder): addLink('[COLOR orange]Acestream engine settings:[/COLOR]', '', addonpath + art + 'settings_menu.png') xbmc.sleep(200) #Change default port for Android if xbmc.getCondVisibility('system.platform.Android'): android_port = settings.getSetting('android_port') addDir( translate(600015) + "[COLOR orange] [ " + android_port + " ][/COLOR]", 'p2p', 311, 'p2p', 2, False) # acestream_cache_size = str( int(getDirectorySize(acestream_cachefolder)) / (1024 * 1024)) addDir( translate(70003) + '[COLOR orange] [' + acestream_cache_size + ' MB][/COLOR]', acestream_cachefolder, 307, 'p2p', 1, False) settings_content = readfile(acestream_settings_file) number_of_settings = re.compile('p(\d+)\n').findall( settings_content) cachefoldersetting = re.compile( "'download_dir'\np\d+\n.+?/(.+?)\n").findall(settings_content) if not cachefoldersetting: if xbmc.getCondVisibility( 'system.platform.linux' ) and not xbmc.getCondVisibility('system.platform.Android'): if not 'arm' in os.uname()[4]: cachefoldersetting = os.path.join( os.getenv("HOME"), '.ACEStream', 'cache', '.acestream_cache') settings.setSetting('acestream_cachefolder', cachefoldersetting) else: cachefoldersetting = os.path.join( '/sdcard', '.ACEStream', 'cache') settings.setSetting('acestream_cachefolder', cachefoldersetting) elif xbmc.getCondVisibility('system.platform.windows'): cachefoldersetting = os.path.join(os.getenv("SystemDrive"), '_acestream_cache_') settings.setSetting('acestream_cachefolder', cachefoldersetting) else: cachefoldersetting = os.path.join('/sdcard', '.ACEStream', 'cache') settings.setSetting('acestream_cachefolder', cachefoldersetting) else: if xbmc.getCondVisibility( 'system.platform.linux' ) and not xbmc.getCondVisibility('system.platform.Android'): if not 'arm' in os.uname()[4]: cachefoldersetting = os.path.join( '/', cachefoldersetting[0].replace("'", ""), '.acestream_cache') settings.setSetting('acestream_cachefolder', cachefoldersetting) else: cachefoldersetting = cachefoldersetting[0] if cachefoldersetting: addDir( translate(70013) + "[COLOR orange][ " + cachefoldersetting + " ][/COLOR]", str(cachefoldersetting), 309, 'p2p', 2, False) else: addDir( translate(70013) + "[COLOR orange][" + cachefoldersetting + "][/COLOR]", cachefoldersetting, 309, 'p2p', 2, False) buffer_type = re.compile( "S'live_cache_type'\np(\d+)\nS(.*)").findall(settings_content) if xbmc.getCondVisibility('system.platform.Android'): if buffer_type: if 'memory' in buffer_type[0][1]: addDir( translate(70041) + "[COLOR orange] [ Memory ][/COLOR]", 'p2p', 312, 'p2p', 2, False) elif 'disk' in buffer_type[0][1]: addDir( translate(70041) + "[COLOR orange] [ Disk ][/COLOR]", 'p2p', 312, 'p2p', 2, False) else: pass livebuffervalue = re.compile("S'live_buffer_time'\np(\d+)\nI(\d+)" ).findall(settings_content) if livebuffervalue: addDir( translate(600017) + "[COLOR orange][ " + livebuffervalue[0][1] + " ][/COLOR]", 'live_buffer_time|' + str(livebuffervalue) + '|' + str(len(number_of_settings)), 308, 'p2p', 2, False) else: addDir( translate(600017) + "[COLOR orange][3][/COLOR]", 'live_buffer_time|' + str(len(number_of_settings)), 308, 'p2p', 2, False) vodbuffervalue = re.compile("S'player_buffer_time'\np(\d+)\nI(\d+)" ).findall(settings_content) if vodbuffervalue: addDir( translate(600016) + "[COLOR orange][ " + vodbuffervalue[0][1] + " ][/COLOR]", 'player_buffer_time|' + str(vodbuffervalue) + '|' + str(len(number_of_settings)), 308, 'p2p', 2, False) else: addDir( translate(600016) + "[COLOR orange][10][/COLOR]", 'player_buffer_time|' + str(len(number_of_settings)), 308, 'p2p', 2, False) downloadlimit = re.compile( "S'total_max_download_rate'\np(\d+)\nI(\d+)").findall( settings_content) if downloadlimit: addDir( translate(600018) + "[COLOR orange][ " + downloadlimit[0][1] + " ][/COLOR]", 'total_max_download_rate|' + str(downloadlimit) + '|' + str(len(number_of_settings)), 308, 'p2p', 2, False) else: addDir( translate(600018) + "[COLOR orange][0][/COLOR]", 'total_max_download_rate|' + str(len(number_of_settings)), 308, 'p2p', 2, False) uploadlimit = re.compile("S'total_max_upload_rate'\np(\d+)\nI(\d+)" ).findall(settings_content) if uploadlimit: addDir( translate(600019) + "[COLOR orange][ " + uploadlimit[0][1] + " ][/COLOR]", 'total_max_upload_rate|' + str(uploadlimit) + '|' + str(len(number_of_settings)), 308, 'p2p', 2, False) else: addDir( translate(600019) + "[COLOR orange][0][/COLOR]", 'total_max_upload_rate|' + str(len(number_of_settings)), 308, 'p2p', 2, False) maxconnection_per_stream = re.compile( "S'max_peers'\np(\d+)\nI(\d+)").findall(settings_content) if maxconnection_per_stream: addDir( translate(600021) + "[COLOR orange][ " + maxconnection_per_stream[0][1] + " ][/COLOR]", 'max_peers|' + str(maxconnection_per_stream) + '|' + str(len(number_of_settings)), 308, 'p2p', 2, False) else: addDir( translate(600021) + "[COLOR orange][50][/COLOR]", 'max_peers|' + str(len(number_of_settings)), 308, 'p2p', 2, False)
def addon_parsers_menu(): if settings.getSetting("parser_disclaimer_three") == "true": opcao = xbmcgui.Dialog().yesno(translate(40000), translate(70004), translate(70005), translate(70006)) if opcao: settings.setSetting("parser_disclaimer_three", "false") dirs, files = xbmcvfs.listdir(base_dir) if not dirs: dirpackages, filespackages = xbmcvfs.listdir(parser_packages_folder) if filespackages: for fich in filespackages: shutil.copyfile(os.path.join(parser_packages_folder, fich), os.path.join(parser_core_folder, fich)) xbmc.sleep(100) import tarfile if tarfile.is_tarfile(os.path.join(parser_core_folder, fich)): download_tools().extract(os.path.join(parser_core_folder, fich), parser_core_folder) download_tools().remove(os.path.join(parser_core_folder, fich)) else: dirsuserdata, files = xbmcvfs.listdir(parser_folder) for fich in files: dictionary_module = eval(readfile(os.path.join(parser_folder, fich))) if "url" in dictionary_module.keys(): add_new_parser(dictionary_module["url"]) else: xbmcvfs.copy( os.path.join(parser_packages_folder, fich.replace(".txt", ".tar.gz")), os.path.join(parser_core_folder, fich.replace(".txt", ".tar.gz")), ) import tarfile if tarfile.is_tarfile(os.path.join(parser_core_folder, fich.replace(".txt", ".tar.gz"))): download_tools().extract( os.path.join(parser_core_folder, fich.replace(".txt", ".tar.gz")), parser_core_folder ) download_tools().remove(os.path.join(parser_core_folder, fich.replace(".txt", ".tar.gz"))) dirs, files = xbmcvfs.listdir(base_dir) parser_dict = {} for module in dirs: module_dir = os.path.join(base_dir, module) module_cfg = os.path.join(module_dir, "module.cfg") module_icon = os.path.join(module_dir, "icon.png") module_fanart = os.path.join(module_dir, "fanart.jpg") if xbmcvfs.exists(module_icon): thumbnail = module_icon else: thumbnail = 'os.path.join(module_dir,"")' if xbmcvfs.exists(module_fanart): fanart = module_fanart else: fanart = "%s/fanart.jpg" % settings.getAddonInfo("path") if xbmcvfs.exists(module_cfg): cfg = readfile(module_cfg) try: cfg = eval(cfg) module_name = cfg["name"] except: module_name = None if module_name: parser_dict[module_name] = [module, thumbnail, fanart] total_parsers = len(parser_dict.keys()) if settings.getSetting("parser_sync") == "true": try: t1 = datetime.datetime.strptime(settings.getSetting("parsers_last_sync_two"), "%Y-%m-%d %H:%M:%S.%f") except: t1 = datetime.datetime.fromtimestamp( time.mktime(time.strptime(settings.getSetting("parsers_last_sync_two"), "%Y-%m-%d %H:%M:%S.%f")) ) t2 = datetime.datetime.now() hoursList = [10, 15, 20, 24] interval = int(settings.getSetting("parser_sync_cron")) update = abs(t2 - t1) > datetime.timedelta(hours=hoursList[interval]) if update: sync_parser() settings.setSetting("parsers_last_sync_two", value=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")) for key in sorted(parser_dict.keys()): addDir( key, MainURL, 401, parser_dict[key][1], total_parsers, True, parser=parser_dict[key][0], fan_art=parser_dict[key][2], ) addDir(translate(400011), MainURL, 402, addonpath + art + "plus-menu.png", 2, False)
def addon_parsers_menu(): if settings.getSetting('parser_disclaimer_three') == "true": opcao = xbmcgui.Dialog().yesno(translate(40000), translate(70004), translate(70005), translate(70006)) if opcao: settings.setSetting('parser_disclaimer_three', "false") dirs, files = xbmcvfs.listdir(base_dir) if not dirs: dirpackages, filespackages = xbmcvfs.listdir(parser_packages_folder) if filespackages: for fich in filespackages: shutil.copyfile(os.path.join(parser_packages_folder, fich), os.path.join(parser_core_folder, fich)) xbmc.sleep(100) import tarfile if tarfile.is_tarfile(os.path.join(parser_core_folder, fich)): download_tools().extract( os.path.join(parser_core_folder, fich), parser_core_folder) download_tools().remove( os.path.join(parser_core_folder, fich)) else: dirsuserdata, files = xbmcvfs.listdir(parser_folder) for fich in files: dictionary_module = eval( readfile(os.path.join(parser_folder, fich))) if "url" in dictionary_module.keys(): add_new_parser(dictionary_module["url"]) else: xbmcvfs.copy( os.path.join(parser_packages_folder, fich.replace('.txt', '.tar.gz')), os.path.join(parser_core_folder, fich.replace('.txt', '.tar.gz'))) import tarfile if tarfile.is_tarfile( os.path.join(parser_core_folder, fich.replace('.txt', '.tar.gz'))): download_tools().extract( os.path.join(parser_core_folder, fich.replace('.txt', '.tar.gz')), parser_core_folder) download_tools().remove( os.path.join(parser_core_folder, fich.replace('.txt', '.tar.gz'))) dirs, files = xbmcvfs.listdir(base_dir) parser_dict = {} for module in dirs: module_dir = os.path.join(base_dir, module) module_cfg = os.path.join(module_dir, "module.cfg") module_icon = os.path.join(module_dir, "icon.png") module_fanart = os.path.join(module_dir, "fanart.jpg") if xbmcvfs.exists(module_icon): thumbnail = module_icon else: thumbnail = 'os.path.join(module_dir,"")' if xbmcvfs.exists(module_fanart): fanart = module_fanart else: fanart = "%s/fanart.jpg" % settings.getAddonInfo("path") if xbmcvfs.exists(module_cfg): cfg = readfile(module_cfg) try: cfg = eval(cfg) module_name = cfg['name'] except: module_name = None if module_name: parser_dict[module_name] = [module, thumbnail, fanart] total_parsers = len(parser_dict.keys()) if settings.getSetting('parser_sync') == "true": try: t1 = datetime.datetime.strptime( settings.getSetting("parsers_last_sync_two"), "%Y-%m-%d %H:%M:%S.%f") except: t1 = datetime.datetime.fromtimestamp( time.mktime( time.strptime(settings.getSetting("parsers_last_sync_two"), "%Y-%m-%d %H:%M:%S.%f"))) t2 = datetime.datetime.now() hoursList = [10, 15, 20, 24] interval = int(settings.getSetting("parser_sync_cron")) update = abs(t2 - t1) > datetime.timedelta(hours=hoursList[interval]) if update: sync_parser() settings.setSetting( 'parsers_last_sync_two', value=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")) for key in sorted(parser_dict.keys()): addDir(key, MainURL, 401, parser_dict[key][1], total_parsers, True, parser=parser_dict[key][0], fan_art=parser_dict[key][2]) addDir(translate(400011), MainURL, 402, addonpath + art + 'plus-menu.png', 2, False)
def advanced_menu(): addLink('[COLOR orange]XBMC Advancedsettings.xml:[/COLOR]','',addonpath + art + 'settings_menu.png') lock_file = xbmc.translatePath('special://temp/'+ 'ts.lock') if xbmcvfs.exists(lock_file): addDir(translate(40068),MainURL,306,'',2,False) userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8'))) advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml') advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml') addDir(translate(40058),MainURL,301,'p2p',2,False) if xbmcvfs.exists(advancedsettings_var): addDir(translate(40063),MainURL,303,'p2p',2,False) addDir(translate(40065),MainURL,304,'p2p',2,False) if xbmcvfs.exists(advancedsettingsbackup_var): addDir(translate(40061),MainURL,302,'p2p',2,False) addLink('','','p2p') if xbmcvfs.exists(advancedsettings_var): content = readfile(advancedsettings_var) match = re.compile('<cachemembuffersize>(.+?)</cachemembuffersize>').findall(content) if match: if match[0] != '252420': valuebuff = '[COLOR red]' + match[0] + '[/COLOR]' else : valuebuff = '[COLOR green]' + match[0] + '[/COLOR]' addLink(translate(40067) +valuebuff+']','','p2p') addLink('','','p2p') #Apply shutdown hooks addLink('[COLOR orange]'+translate(70025)+'[/COLOR]','',addonpath + art + 'settings_menu.png') addDir(translate(70026),MainURL,310,'p2p',2,False) #Change engine settings from xbmc menus eligible = False if xbmc.getCondVisibility('system.platform.linux') and settings.getSetting('force_android') != "true": if os.uname()[4] == "armv6l" or os.uname()[4] == "armv7l": eligible = True elif xbmc.getCondVisibility('system.platform.OSX'): eligible = False elif settings.getSetting('openeleci386') == "true": eligible = False elif settings.getSetting('force_android') == "true": eligible = False else: eligible = False if eligible and os.path.exists(os.path.join(pastaperfil,'acestream','ace','ACEStream','values')): addLink('[COLOR orange]Acestream engine settings:[/COLOR]','',addonpath + art + 'settings_menu.png') acestream_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache') acestream_cache_size = str(int(getDirectorySize(acestream_cachefolder))/(1024*1024)) addDir(translate(70003) + '[COLOR orange] [' + acestream_cache_size + ' MB][/COLOR]',acestream_cachefolder,307,'p2p',1,False) try: porta = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","port.txt")) except: porta = "N/A" try: acestream_settings_file = os.path.join(os.getenv("HOME"),'.ACEStream','sessconfig.pickle') sessconfig = readfile(acestream_settings_file) portvector = re.compile("S'minport'\np(\d+)\nI(\d+)\n").findall(sessconfig) maxport = re.compile("S'maxport'\np(\d+)\nI(\d+)\n").findall(sessconfig) except: portvector = [];maxport=[] addDir(translate(600015) +"[COLOR orange][ " + str(int(porta))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","port.txt") + '|' + str(portvector)+'|'+str(maxport),305,'p2p',2,False) try: vodbuffer = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","vodbuffer.txt")) except: vodbuffer = "N/A" addDir(translate(600016) + "[COLOR orange][ " + str(int(vodbuffer))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","vodbuffer.txt"),305,'p2p',2,False) try: livebuffer = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","livebuffer.txt")) except: livebuffer = "N/A" addDir(translate(600017)+"[COLOR orange][ " + str(int(livebuffer))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","livebuffer.txt"),305,'p2p',2,False) try: downloadlimit = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","downloadlimit.txt")) except: downloadlimit = "N/A" addDir(translate(600018) +"[COLOR orange][ " + str(int(downloadlimit))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","downloadlimit.txt"),305,'p2p',2,False) try: uploadlimit = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","uploadlimit.txt")) except: uploadlimit = "N/A" addDir(translate(600019)+"[COLOR orange][ " + str(int(uploadlimit))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","uploadlimit.txt"),305,'p2p',2,False) try: maxconnections = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnections.txt")) except: maxconnections = "N/A" addDir(translate(600020)+"[COLOR orange][ " + str(int(maxconnections))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnections.txt"),305,'p2p',2,False) try: maxconnectionsstream = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnectionsstream.txt")) except: maxconnectionsstream = "N/A" addDir(translate(600021)+"[COLOR orange][ " + str(int(maxconnectionsstream))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnectionsstream.txt"),305,'',2,False) elif eligible and not os.path.exists(os.path.join(pastaperfil,'acestream','ace','ACEStream','values')): addLink("[COLOR red][B]"+translate(600027)+"[/COLOR][/B]","",addonpath + art + 'processwarning.png') else: pass if (not eligible and xbmc.getCondVisibility('system.platform.linux') and settings.getSetting('ace_cmd') == "0") or (not eligible and xbmc.getCondVisibility('system.platform.windows')) or (not eligible and xbmc.getCondVisibility('system.platform.Android') and settings.getSetting('engine_app') == "0") or (settings.getSetting('force_android') == "true" and settings.getSetting('engine_app') == "0"): if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android'): default_acefolder = os.path.join(os.getenv("HOME"),'.ACEStream') default_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache','.acestream_cache') pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Linux/playerconf.pickle' if settings.getSetting('acestream_cachefolder') == '': acestream_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache','.acestream_cache') else: acestream_cachefolder = settings.getSetting('acestream_cachefolder') acestream_settings_file = os.path.join(os.getenv("HOME"),'.ACEStream','playerconf.pickle') elif xbmc.getCondVisibility('system.platform.Android'): default_acefolder = os.path.join('/sdcard','.ACEStream') default_cachefolder = os.path.join('/sdcard','.ACEStream','.acestream_cache') pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Android/playerconf.pickle' if settings.getSetting('acestream_cachefolder') == '': acestream_cachefolder = os.path.join('/sdcard','.ACEStream','.acestream_cache') else: acestream_cachefolder = os.path.join(settings.getSetting('acestream_cachefolder'),'.acestream_cache') if not os.path.exists(acestream_cachefolder):xbmcvfs.mkdir(acestream_cachefolder) acestream_settings_file = os.path.join('/sdcard','.ACEStream','playerconf.pickle') elif xbmc.getCondVisibility('system.platform.windows'): default_acefolder = os.path.join(os.getenv("APPDATA"),".ACEStream") pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Windows/playerconf.pickle' default_cachefolder = os.path.join(os.getenv("SystemDrive"),'\_acestream_cache_') acestream_cachefolder = default_cachefolder acestream_settings_file = os.path.join(os.getenv("APPDATA"),".ACEStream","playerconf.pickle") #workaround to keep settings file in place if they get deleted if not os.path.exists(default_acefolder): xbmcvfs.mkdir(default_acefolder) if not os.path.exists(default_cachefolder): xbmcvfs.mkdir(default_cachefolder) if not os.path.exists(acestream_settings_file): local_file = os.path.join(default_acefolder,pickle_repo.split("/")[-1]) download_tools().Downloader(pickle_repo,local_file,'',translate(40000)) xbmc.sleep(200) if xbmcvfs.exists(acestream_settings_file): settings_text = readfile(acestream_settings_file) save(acestream_settings_file,settings_text.replace('my_cache_folder',default_cachefolder)) if xbmcvfs.exists(acestream_settings_file) and os.path.exists(acestream_cachefolder): addLink('[COLOR orange]Acestream engine settings:[/COLOR]','',addonpath + art + 'settings_menu.png') xbmc.sleep(200) #Change default port for Android if xbmc.getCondVisibility('system.platform.Android'): android_port = settings.getSetting('android_port') addDir(translate(600015) +"[COLOR orange] [ " + android_port + " ][/COLOR]",'p2p',311,'p2p',2,False) # acestream_cache_size = str(int(getDirectorySize(acestream_cachefolder))/(1024*1024)) addDir(translate(70003) + '[COLOR orange] [' + acestream_cache_size + ' MB][/COLOR]',acestream_cachefolder,307,'p2p',1,False) settings_content = readfile(acestream_settings_file) number_of_settings = re.compile('p(\d+)\n').findall(settings_content) cachefoldersetting = re.compile("'download_dir'\np\d+\n.+?/(.+?)\n").findall(settings_content) if not cachefoldersetting: if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android'): if not 'arm' in os.uname()[4]: cachefoldersetting = os.path.join(os.getenv("HOME"),'.ACEStream','cache','.acestream_cache') settings.setSetting('acestream_cachefolder',cachefoldersetting) else: cachefoldersetting = os.path.join('/sdcard','.ACEStream','cache') settings.setSetting('acestream_cachefolder',cachefoldersetting) elif xbmc.getCondVisibility('system.platform.windows'): cachefoldersetting = os.path.join(os.getenv("SystemDrive"),'_acestream_cache_') settings.setSetting('acestream_cachefolder',cachefoldersetting) else: cachefoldersetting = os.path.join('/sdcard','.ACEStream','cache') settings.setSetting('acestream_cachefolder',cachefoldersetting) else: if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android'): if not 'arm' in os.uname()[4]: cachefoldersetting = os.path.join('/',cachefoldersetting[0].replace("'",""),'.acestream_cache') settings.setSetting('acestream_cachefolder',cachefoldersetting) else: cachefoldersetting = cachefoldersetting[0] if cachefoldersetting: addDir(translate(70013)+"[COLOR orange][ " + cachefoldersetting + " ][/COLOR]",str(cachefoldersetting),309,'p2p',2,False) else: addDir(translate(70013)+"[COLOR orange][" + cachefoldersetting + "][/COLOR]",cachefoldersetting,309,'p2p',2,False) buffer_type = re.compile("S'live_cache_type'\np(\d+)\nS(.*)").findall(settings_content) if xbmc.getCondVisibility('system.platform.Android'): if buffer_type: if 'memory' in buffer_type[0][1]: addDir(translate(70041)+"[COLOR orange] [ Memory ][/COLOR]",'p2p',312,'p2p',2,False) elif 'disk' in buffer_type[0][1]: addDir(translate(70041)+"[COLOR orange] [ Disk ][/COLOR]",'p2p',312,'p2p',2,False) else: pass livebuffervalue = re.compile("S'live_buffer_time'\np(\d+)\nI(\d+)").findall(settings_content) if livebuffervalue: addDir(translate(600017)+"[COLOR orange][ " + livebuffervalue[0][1] + " ][/COLOR]",'live_buffer_time|' + str(livebuffervalue)+'|'+str(len(number_of_settings)),308,'p2p',2,False) else: addDir(translate(600017)+"[COLOR orange][3][/COLOR]",'live_buffer_time|'+str(len(number_of_settings)),308,'p2p',2,False) vodbuffervalue = re.compile("S'player_buffer_time'\np(\d+)\nI(\d+)").findall(settings_content) if vodbuffervalue: addDir(translate(600016)+"[COLOR orange][ " + vodbuffervalue[0][1] + " ][/COLOR]",'player_buffer_time|'+str(vodbuffervalue)+'|'+str(len(number_of_settings)),308,'p2p',2,False) else: addDir(translate(600016)+"[COLOR orange][10][/COLOR]",'player_buffer_time|'+str(len(number_of_settings)),308,'p2p',2,False) downloadlimit = re.compile("S'total_max_download_rate'\np(\d+)\nI(\d+)").findall(settings_content) if downloadlimit: addDir(translate(600018)+"[COLOR orange][ " + downloadlimit[0][1] + " ][/COLOR]",'total_max_download_rate|'+str(downloadlimit)+'|'+str(len(number_of_settings)),308,'p2p',2,False) else: addDir(translate(600018)+"[COLOR orange][0][/COLOR]",'total_max_download_rate|'+str(len(number_of_settings)),308,'p2p',2,False) uploadlimit = re.compile("S'total_max_upload_rate'\np(\d+)\nI(\d+)").findall(settings_content) if uploadlimit: addDir(translate(600019)+"[COLOR orange][ " + uploadlimit[0][1] + " ][/COLOR]",'total_max_upload_rate|'+str(uploadlimit)+'|'+str(len(number_of_settings)),308,'p2p',2,False) else: addDir(translate(600019)+"[COLOR orange][0][/COLOR]",'total_max_upload_rate|'+str(len(number_of_settings)),308,'p2p',2,False) maxconnection_per_stream = re.compile("S'max_peers'\np(\d+)\nI(\d+)").findall(settings_content) if maxconnection_per_stream: addDir(translate(600021)+"[COLOR orange][ " + maxconnection_per_stream[0][1] + " ][/COLOR]",'max_peers|'+str(maxconnection_per_stream)+'|'+str(len(number_of_settings)),308,'p2p',2,False) else: addDir(translate(600021)+"[COLOR orange][50][/COLOR]",'max_peers|'+str(len(number_of_settings)),308,'p2p',2,False)