def setting_torrent(item): logger.info() default = config.get_setting("torrent_client", server="torrent", default=0) torrent_options = [ config.get_localized_string(30006), config.get_localized_string(70254), config.get_localized_string(70255) ] torrent_options.extend(platformtools.torrent_client_installed()) list_controls = [{ "id": "list_torrent", "type": "list", "label": config.get_localized_string(70256), "default": default, "enabled": True, "visible": True, "lvalues": torrent_options }] platformtools.show_channel_settings( list_controls=list_controls, callback='save_setting_torrent', item=item, caption=config.get_localized_string(70257), custom_button={'visible': False})
def get_video_url(page_url, premium=False, user='', password='', video_password=''): torrent_options = platformtools.torrent_client_installed(show_tuple=True) if len(torrent_options) == 0: from platformcode import elementum_download elementum_download.download() info('server=torrent, the url is the good') if page_url.startswith('magnet:'): video_urls = [['magnet: [torrent]', page_url]] else: video_urls = [['.torrent [torrent]', page_url]] return video_urls
def reactivate_unrar(init=False, mute=True): logger.info() if not mute: platformtools.dialog_notification("Iniciando recuperación de", "UnRARs interrumpidos") torrent_options = [] #torrent_options.append(["Cliente interno BT"]) #torrent_options.append(["Cliente interno MCT"]) torrent_options.extend( platformtools.torrent_client_installed(show_tuple=False)) download_paths = [] for torr_client in torrent_options: # Localizamos el path de descarga del .torrent torr_client = torr_client.replace('Plugin externo: ', '').replace('Cliente interno ', '') save_path_videos = '' __settings__ = xbmcaddon.Addon( id="plugin.video.%s" % torr_client) # Apunta settings del cliente torrent if torr_client == 'torrenter': save_path_videos = str( xbmc.translatePath(__settings__.getSetting('storage'))) if not save_path_videos: save_path_videos = str(filetools.join(xbmc.translatePath("special://home/"), \ "cache", "xbmcup", "plugin.video.torrenter", "Torrenter")) else: save_path_videos = str( xbmc.translatePath(__settings__.getSetting('download_path'))) if __settings__.getSetting( 'download_storage') == '1': # Descarga en memoria? continue # pasamos if not save_path_videos: # No hay path de descarga? continue # pasamos for t_client, download_path in download_paths: if save_path_videos == download_path: break else: download_paths.append( (torr_client, save_path_videos)) # Agregamos el path para este Cliente search_for_unrar_in_error(download_paths, init=init)
def setting_torrent(item): logger.info() default = config.get_setting("torrent_client", server="torrent", default=0) torrent_options = ["Preguntar", "Cliente interno", "Cliente interno - MCT"] torrent_options.extend(platformtools.torrent_client_installed()) list_controls = [ { "id": "list_torrent", "type": "list", "label": "¿Qué cliente quiere usar para reproducir torrent?", "default": default, "enabled": True, "visible": True, "lvalues": torrent_options } ] platformtools.show_channel_settings(list_controls=list_controls, callback='save_setting_torrent', item=item, caption="configuración -- Torrent", custom_button={'visible': False})
def get_environment(): """ Devuelve las variables de entorno del OS, de Kodi y de Alfa más habituales, necesarias para el diagnóstico de fallos """ try: import base64 import ast environment = config.get_platform(full_version=True) environment['num_version'] = str(environment['num_version']) environment['python_version'] = str(platform.python_version()) environment['os_release'] = str(platform.release()) if xbmc.getCondVisibility("system.platform.Windows"): try: if platform._syscmd_ver()[2]: environment['os_release'] = str(platform._syscmd_ver()[2]) except: pass environment['prod_model'] = '' if xbmc.getCondVisibility("system.platform.Android"): environment['os_name'] = 'Android' try: for label_a in subprocess.check_output('getprop').split('\n'): if 'build.version.release' in label_a: environment['os_release'] = str( scrapertools.find_single_match( label_a, ':\s*\[(.*?)\]$')) if 'product.model' in label_a: environment['prod_model'] = str( scrapertools.find_single_match( label_a, ':\s*\[(.*?)\]$')) except: try: for label_a in filetools.read(os.environ['ANDROID_ROOT'] + '/build.prop').split(): if 'build.version.release' in label_a: environment['os_release'] = str( scrapertools.find_single_match( label_a, '=(.*?)$')) if 'product.model' in label_a: environment['prod_model'] = str( scrapertools.find_single_match( label_a, '=(.*?)$')) except: pass elif xbmc.getCondVisibility("system.platform.Linux.RaspberryPi"): environment['os_name'] = 'RaspberryPi' else: environment['os_name'] = str(platform.system()) environment['machine'] = str(platform.machine()) environment['architecture'] = str(sys.maxsize > 2**32 and "64-bit" or "32-bit") environment['language'] = str(xbmc.getInfoLabel('System.Language')) environment['cpu_usage'] = str(xbmc.getInfoLabel('System.CpuUsage')) environment['mem_total'] = str( xbmc.getInfoLabel('System.Memory(total)')).replace('MB', '').replace( 'KB', '') environment['mem_free'] = str( xbmc.getInfoLabel('System.Memory(free)')).replace('MB', '').replace( 'KB', '') if not environment['mem_total'] or not environment['mem_free']: try: if environment['os_name'].lower() == 'windows': kernel32 = ctypes.windll.kernel32 c_ulong = ctypes.c_ulong c_ulonglong = ctypes.c_ulonglong class MEMORYSTATUS(ctypes.Structure): _fields_ = [('dwLength', c_ulong), ('dwMemoryLoad', c_ulong), ('dwTotalPhys', c_ulonglong), ('dwAvailPhys', c_ulonglong), ('dwTotalPageFile', c_ulonglong), ('dwAvailPageFile', c_ulonglong), ('dwTotalVirtual', c_ulonglong), ('dwAvailVirtual', c_ulonglong), ('availExtendedVirtual', c_ulonglong)] memoryStatus = MEMORYSTATUS() memoryStatus.dwLength = ctypes.sizeof(MEMORYSTATUS) kernel32.GlobalMemoryStatus(ctypes.byref(memoryStatus)) environment['mem_total'] = str( int(memoryStatus.dwTotalPhys) / (1024**2)) environment['mem_free'] = str( int(memoryStatus.dwAvailPhys) / (1024**2)) else: with open('/proc/meminfo') as f: meminfo = f.read() environment['mem_total'] = str( int( re.search(r'MemTotal:\s+(\d+)', meminfo).groups()[0]) / 1024) environment['mem_free'] = str( int( re.search(r'MemAvailable:\s+(\d+)', meminfo).groups()[0]) / 1024) except: environment['mem_total'] = '' environment['mem_free'] = '' try: environment['kodi_buffer'] = '20' environment['kodi_bmode'] = '0' environment['kodi_rfactor'] = '4.0' if filetools.exists( filetools.join(xbmc.translatePath("special://userdata"), "advancedsettings.xml")): advancedsettings = filetools.read( filetools.join(xbmc.translatePath("special://userdata"), "advancedsettings.xml")).split('\n') for label_a in advancedsettings: if 'memorysize' in label_a: environment['kodi_buffer'] = str( int( scrapertools.find_single_match( label_a, '>(\d+)<\/')) / 1024**2) if 'buffermode' in label_a: environment['kodi_bmode'] = str( scrapertools.find_single_match( label_a, '>(\d+)<\/')) if 'readfactor' in label_a: environment['kodi_rfactor'] = str( scrapertools.find_single_match( label_a, '>(.*?)<\/')) except: pass environment['userdata_path'] = str( xbmc.translatePath(config.get_data_path())) try: if environment['os_name'].lower() == 'windows': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(environment['userdata_path']), None, None, ctypes.pointer(free_bytes)) environment['userdata_free'] = str( round(float(free_bytes.value) / (1024**3), 3)) else: disk_space = os.statvfs(environment['userdata_path']) if not disk_space.f_frsize: disk_space.f_frsize = disk_space.f_frsize.f_bsize environment['userdata_free'] = str(round((float(disk_space.f_bavail) / \ (1024**3)) * float(disk_space.f_frsize), 3)) except: environment['userdata_free'] = '?' try: environment['videolab_series'] = '?' environment['videolab_episodios'] = '?' environment['videolab_pelis'] = '?' environment['videolab_path'] = str( xbmc.translatePath(config.get_videolibrary_path())) if filetools.exists(filetools.join(environment['videolab_path'], \ config.get_setting("folder_tvshows"))): environment['videolab_series'] = str(len(filetools.listdir(filetools.join(environment['videolab_path'], \ config.get_setting("folder_tvshows"))))) counter = 0 for root, folders, files in filetools.walk(filetools.join(environment['videolab_path'], \ config.get_setting("folder_tvshows"))): for file in files: if file.endswith('.strm'): counter += 1 environment['videolab_episodios'] = str(counter) if filetools.exists(filetools.join(environment['videolab_path'], \ config.get_setting("folder_movies"))): environment['videolab_pelis'] = str(len(filetools.listdir(filetools.join(environment['videolab_path'], \ config.get_setting("folder_movies"))))) except: pass try: video_updates = ['No', 'Inicio', 'Una vez', 'Inicio+Una vez'] environment['videolab_update'] = str( video_updates[config.get_setting("update", "videolibrary")]) except: environment['videolab_update'] = '?' try: if environment['os_name'].lower() == 'windows': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(environment['videolab_path']), None, None, ctypes.pointer(free_bytes)) environment['videolab_free'] = str( round(float(free_bytes.value) / (1024**3), 3)) else: disk_space = os.statvfs(environment['videolab_path']) if not disk_space.f_frsize: disk_space.f_frsize = disk_space.f_frsize.f_bsize environment['videolab_free'] = str(round((float(disk_space.f_bavail) / \ (1024**3)) * float(disk_space.f_frsize), 3)) except: environment['videolab_free'] = '?' environment['torrentcli_option'] = '' environment['torrentcli_name'] = '' environment['torrentcli_dload_path'] = '' environment['torrentcli_buffer'] = '' environment['torrentcli_dload_estrgy'] = '' environment['torrentcli_mem_size'] = '' environment['torrentcli_free'] = '' torrent_id = config.get_setting("torrent_client", server="torrent", default=0) environment['torrentcli_option'] = str(torrent_id) if torrent_id > 0: torrent_id = torrent_id - 3 if torrent_id < 0: logger.error('torrent_id: ' + str(torrent_id) + ' / torrent_options: ' + str(platformtools.torrent_client_installed())) torrent_options = platformtools.torrent_client_installed() if torrent_options and torrent_id >= 0: environment['torrentcli_name'] = torrent_options[ torrent_id].replace('Plugin externo: ', '') if xbmc.getCondVisibility('System.HasAddon("plugin.video.%s")' % environment['torrentcli_name']): __settings__ = xbmcaddon.Addon(id="plugin.video.%s" % environment['torrentcli_name']) environment['torrentcli_name'] = environment[ 'torrentcli_name'].capitalize() if environment['torrentcli_name'] == 'Torrenter': environment['torrentcli_dload_path'] = str( xbmc.translatePath(__settings__.getSetting('storage'))) environment['torrentcli_buffer'] = str( __settings__.getSetting('pre_buffer_bytes')) else: environment['torrentcli_dload_path'] = str( xbmc.translatePath( __settings__.getSetting('download_path'))) environment['torrentcli_buffer'] = str( __settings__.getSetting('buffer_size')) environment['torrentcli_dload_estrgy'] = str( __settings__.getSetting('download_storage')) environment['torrentcli_mem_size'] = str( __settings__.getSetting('memory_size')) if environment['torrentcli_dload_path']: try: if environment['os_name'].lower() == 'windows': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(environment['torrentcli_dload_path']), None, None, ctypes.pointer(free_bytes)) environment['torrentcli_free'] = str(round(float(free_bytes.value) / \ (1024**3), 3)) else: disk_space = os.statvfs( environment['torrentcli_dload_path']) if not disk_space.f_frsize: disk_space.f_frsize = disk_space.f_frsize.f_bsize environment['torrentcli_free'] = str(round((float(disk_space.f_bavail) / \ (1024**3)) * float(disk_space.f_frsize), 3)) except: environment['torrentcli_free'] = '?' environment['proxy_active'] = '' try: proxy_channel_bloqued_str = base64.b64decode( config.get_setting('proxy_channel_bloqued')).decode('utf-8') proxy_channel_bloqued = dict() proxy_channel_bloqued = ast.literal_eval(proxy_channel_bloqued_str) for channel_bloqued, proxy_active in proxy_channel_bloqued.items(): if proxy_active == 'ON': environment['proxy_active'] += channel_bloqued + ', ' except: pass if not environment['proxy_active']: environment['proxy_active'] = 'OFF' environment['proxy_active'] = environment['proxy_active'].rstrip(', ') for root, folders, files in filetools.walk( xbmc.translatePath("special://logpath/")): for file in files: if file.lower() in ['kodi.log', 'jarvis.log', 'spmc.log', 'cemc.log', \ 'mygica.log', 'wonderbox.log', 'leiapp,log', \ 'leianmc.log', 'kodiapp.log', 'anmc.log', \ 'latin-anmc.log']: environment['log_path'] = str(filetools.join(root, file)) break else: environment['log_path'] = '' break if environment['log_path']: environment['log_size_bytes'] = str( filetools.getsize(environment['log_path'])) environment['log_size'] = str(round(float(environment['log_size_bytes']) / \ (1024*1024), 3)) else: environment['log_size_bytes'] = '' environment['log_size'] = '' environment['debug'] = str(config.get_setting('debug')) environment['addon_version'] = str(config.get_addon_version()) except: logger.error(traceback.format_exc()) environment = {} environment['log_size'] = '' environment['cpu_usage'] = '' environment['python_version'] = '' environment['log_path'] = '' environment['userdata_free'] = '' environment['mem_total'] = '' environment['torrentcli_mem_size'] = '' environment['torrentcli_dload_path'] = '' environment['torrentcli_dload_estrgy'] = '' environment['machine'] = '' environment['platform'] = '' environment['torrentcli_buffer'] = '' environment['videolab_path'] = '' environment['num_version'] = '' environment['os_name'] = '' environment['torrentcli_free'] = '' environment['video_db'] = '' environment['userdata_path'] = '' environment['log_size_bytes'] = '' environment['name_version'] = '' environment['language'] = '' environment['mem_free'] = '' environment['prod_model'] = '' environment['proxy_active'] = '' environment['architecture'] = '' environment['os_release'] = '' environment['videolab_free'] = '' environment['torrentcli_name'] = '' environment['kodi_buffer'] = '' environment['kodi_bmode'] = '' environment['kodi_rfactor'] = '' environment['videolab_series'] = '' environment['videolab_episodios'] = '' environment['videolab_pelis'] = '' environment['videolab_update'] = '' environment['debug'] = '' environment['addon_version'] = '' environment['torrentcli_option'] = '' return environment
def get_environment(): """ Devuelve las variables de entorno del OS, de Kodi y de Alfa más habituales, necesarias para el diagnóstico de fallos """ try: import base64 import ast environment = config.get_platform(full_version=True) environment['num_version'] = str(environment['num_version']) environment['python_version'] = '%s (%s, %s)' % (str(platform.python_version()), \ str(sys.api_version), str(platform.python_implementation())) environment['os_release'] = str(platform.release()) environment['prod_model'] = '' try: import multiprocessing environment['proc_num'] = ' (%sx)' % str( multiprocessing.cpu_count()) except: environment['proc_num'] = '' if xbmc.getCondVisibility("system.platform.Windows"): try: if platform.platform(): environment['os_release'] = str( platform.platform()).replace('Windows-', '') elif platform._syscmd_ver()[2]: environment['os_release'] = str(platform._syscmd_ver()[2]) command = ["wmic", "cpu", "get", "name"] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=0x08000000) output_cmd, error_cmd = p.communicate() if PY3 and isinstance(output_cmd, bytes): output_cmd = output_cmd.decode() output_cmd = re.sub(r'\n|\r|\s{2}', '', output_cmd) environment['prod_model'] = str(scrapertools.find_single_match(output_cmd, \ '\w+.*?(?i)(?:Intel\(R\))?(?:\s*Core\(TM\))\s*(.*?CPU.*?)\s*(?:\@|$)')) except: pass if xbmc.getCondVisibility("system.platform.Android"): environment['os_name'] = 'Android' try: for label_a in subprocess.check_output('getprop').split(FF): if PY3 and isinstance(label_a, bytes): label_a = label_a.decode() if 'build.version.release' in label_a: environment['os_release'] = str( scrapertools.find_single_match( label_a, ':\s*\[(.*?)\]$')) if 'product.model' in label_a: environment['prod_model'] = str( scrapertools.find_single_match( label_a, ':\s*\[(.*?)\]$')) except: try: for label_a in filetools.read(os.environ['ANDROID_ROOT'] + '/build.prop').split(): if 'build.version.release' in label_a: environment['os_release'] = str( scrapertools.find_single_match( label_a, '=(.*?)$')) if 'product.model' in label_a: environment['prod_model'] = str( scrapertools.find_single_match( label_a, '=(.*?)$')) except: pass environment['prod_model'] += ' (%s)' % config.is_rooted( silent=True) elif xbmc.getCondVisibility("system.platform.Linux"): environment['os_name'] = 'Linux' try: for label_a in subprocess.check_output('hostnamectl').split( FF): if PY3 and isinstance(label_a, bytes): label_a = label_a.decode() if 'Operating' in label_a: environment['os_release'] = str( scrapertools.find_single_match( label_a, 'Operating\s*S\w+:\s*(.*?)\s*$')) break for label_a in subprocess.check_output( ['cat', '/proc/cpuinfo']).split(FF): if PY3 and isinstance(label_a, bytes): label_a = label_a.decode() if 'model name' in label_a: environment['prod_model'] = str(scrapertools.find_single_match(label_a, \ 'model.*?:\s*(?i)(?:Intel\(R\))?(?:\s*Core\(TM\))\s*(.*?CPU.*?)\s*(?:\@|$)')) break except: pass elif xbmc.getCondVisibility("system.platform.Linux.RaspberryPi"): environment['os_name'] = 'RaspberryPi' else: environment['os_name'] = str(platform.system()) if not environment['os_release']: environment['os_release'] = str(platform.release()) if environment['proc_num'] and environment['prod_model']: environment['prod_model'] += environment['proc_num'] environment['machine'] = str(platform.machine()) environment['architecture'] = str(sys.maxsize > 2**32 and "64-bit" or "32-bit") environment['language'] = str(xbmc.getInfoLabel('System.Language')) environment['cpu_usage'] = str(xbmc.getInfoLabel('System.CpuUsage')) environment['mem_total'] = str( xbmc.getInfoLabel('System.Memory(total)')).replace('MB', '').replace( 'KB', '') environment['mem_free'] = str( xbmc.getInfoLabel('System.Memory(free)')).replace('MB', '').replace( 'KB', '') if not environment['mem_total'] or not environment['mem_free']: try: if environment['os_name'].lower() == 'windows': kernel32 = ctypes.windll.kernel32 c_ulong = ctypes.c_ulong c_ulonglong = ctypes.c_ulonglong class MEMORYSTATUS(ctypes.Structure): _fields_ = [('dwLength', c_ulong), ('dwMemoryLoad', c_ulong), ('dwTotalPhys', c_ulonglong), ('dwAvailPhys', c_ulonglong), ('dwTotalPageFile', c_ulonglong), ('dwAvailPageFile', c_ulonglong), ('dwTotalVirtual', c_ulonglong), ('dwAvailVirtual', c_ulonglong), ('availExtendedVirtual', c_ulonglong)] memoryStatus = MEMORYSTATUS() memoryStatus.dwLength = ctypes.sizeof(MEMORYSTATUS) kernel32.GlobalMemoryStatus(ctypes.byref(memoryStatus)) environment['mem_total'] = str( old_div(int(memoryStatus.dwTotalPhys), (1024**2))) environment['mem_free'] = str( old_div(int(memoryStatus.dwAvailPhys), (1024**2))) else: with open('/proc/meminfo') as f: meminfo = f.read() environment['mem_total'] = str( old_div( int( re.search(r'MemTotal:\s+(\d+)', meminfo).groups()[0]), 1024)) environment['mem_free'] = str( old_div( int( re.search(r'MemAvailable:\s+(\d+)', meminfo).groups()[0]), 1024)) except: environment['mem_total'] = '' environment['mem_free'] = '' try: environment['kodi_buffer'] = '20' environment['kodi_bmode'] = '0' environment['kodi_rfactor'] = '4.0' if filetools.exists( filetools.join("special://userdata", "advancedsettings.xml")): advancedsettings = filetools.read( filetools.join("special://userdata", "advancedsettings.xml")).split('\n') for label_a in advancedsettings: if 'memorysize' in label_a: environment['kodi_buffer'] = str( old_div( int( scrapertools.find_single_match( label_a, '>(\d+)<\/')), 1024**2)) if 'buffermode' in label_a: environment['kodi_bmode'] = str( scrapertools.find_single_match( label_a, '>(\d+)<\/')) if 'readfactor' in label_a: environment['kodi_rfactor'] = str( scrapertools.find_single_match( label_a, '>(.*?)<\/')) except: pass environment['userdata_path'] = str(config.get_data_path()) environment['userdata_path_perm'] = filetools.file_info( environment['userdata_path']) if not environment['userdata_path_perm']: del environment['userdata_path_perm'] try: if environment['os_name'].lower() == 'windows': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(environment['userdata_path']), None, None, ctypes.pointer(free_bytes)) environment['userdata_free'] = str( round(float(free_bytes.value) / (1024**3), 3)) else: disk_space = os.statvfs(environment['userdata_path']) if not disk_space.f_frsize: disk_space.f_frsize = disk_space.f_frsize.f_bsize environment['userdata_free'] = str(round((float(disk_space.f_bavail) / \ (1024**3)) * float(disk_space.f_frsize), 3)) except: environment['userdata_free'] = '?' if environment['userdata_path_perm']: environment['userdata_path'] = environment['userdata_path_perm'] del environment['userdata_path_perm'] environment['torrent_lang'] = '%s/%s' % (config.get_setting("channel_language", default="").upper(), \ config.get_setting("second_language", default="").upper()) try: environment['videolab_series'] = '?' environment['videolab_episodios'] = '?' environment['videolab_pelis'] = '?' environment['videolab_path'] = str(config.get_videolibrary_path()) environment['videolab_path_perm'] = filetools.file_info( environment['videolab_path']) if not environment['videolab_path_perm']: environment['videolab_path_perm'] = environment[ 'videolab_path'] if filetools.exists(filetools.join(environment['videolab_path'], \ config.get_setting("folder_tvshows"))): environment['videolab_series'] = str(len(filetools.listdir(filetools.join(environment['videolab_path'], \ config.get_setting("folder_tvshows"))))) counter = 0 for root, folders, files in filetools.walk(filetools.join(environment['videolab_path'], \ config.get_setting("folder_tvshows"))): for file in files: if file.endswith('.strm'): counter += 1 environment['videolab_episodios'] = str(counter) if filetools.exists(filetools.join(environment['videolab_path'], \ config.get_setting("folder_movies"))): environment['videolab_pelis'] = str(len(filetools.listdir(filetools.join(environment['videolab_path'], \ config.get_setting("folder_movies"))))) except: pass try: video_updates = [ 'No', 'Inicio', 'Una vez', 'Inicio+Una vez', 'Dos veces al día' ] environment['videolab_update'] = str( video_updates[config.get_setting("update", "videolibrary")]) except: environment['videolab_update'] = '?' try: if environment['os_name'].lower() == 'windows': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(environment['videolab_path']), None, None, ctypes.pointer(free_bytes)) environment['videolab_free'] = str( round(float(free_bytes.value) / (1024**3), 3)) else: disk_space = os.statvfs(environment['videolab_path']) if not disk_space.f_frsize: disk_space.f_frsize = disk_space.f_frsize.f_bsize environment['videolab_free'] = str(round((float(disk_space.f_bavail) / \ (1024**3)) * float(disk_space.f_frsize), 3)) except: environment['videolab_free'] = '?' environment['torrent_list'] = [] environment['torrentcli_option'] = '' environment['torrent_error'] = '' environment['torrentcli_rar'] = config.get_setting("mct_rar_unpack", server="torrent", default=True) environment['torrentcli_backgr'] = config.get_setting( "mct_background_download", server="torrent", default=True) environment['torrentcli_lib_path'] = config.get_setting( "libtorrent_path", server="torrent", default="") if environment['torrentcli_lib_path']: lib_path = 'Activo' else: lib_path = 'Inactivo' if config.get_setting("libtorrent_version", server="torrent", default=""): lib_path += '-%s' % config.get_setting( "libtorrent_version", server="torrent", default="") environment['torrentcli_unrar'] = config.get_setting("unrar_path", server="torrent", default="") if environment['torrentcli_unrar']: if xbmc.getCondVisibility("system.platform.Android"): unrar = 'Android' else: unrar = filetools.dirname(environment['torrentcli_unrar']) unrar = filetools.basename(unrar).capitalize() else: unrar = 'Inactivo' torrent_id = config.get_setting("torrent_client", server="torrent", default=0) environment['torrentcli_option'] = str(torrent_id) torrent_options = platformtools.torrent_client_installed() if lib_path != 'Inactivo': torrent_options = ['MCT'] + torrent_options torrent_options = ['BT'] + torrent_options environment['torrent_list'].append({'Torrent_opt': str(torrent_id), 'Libtorrent': lib_path, \ 'RAR_Auto': str(environment['torrentcli_rar']), \ 'RAR_backgr': str(environment['torrentcli_backgr']), \ 'UnRAR': unrar}) environment['torrent_error'] = config.get_setting("libtorrent_error", server="torrent", default="") if environment['torrent_error']: environment['torrent_list'].append( {'Libtorrent_error': environment['torrent_error']}) for torrent_option in torrent_options: cliente = dict() cliente['D_load_Path'] = '' cliente['Libre'] = '?' cliente['Plug_in'] = torrent_option.replace('Plugin externo: ', '') if cliente['Plug_in'] == 'BT': cliente['D_load_Path'] = str( config.get_setting("bt_download_path", server="torrent", default='')) if not cliente['D_load_Path']: continue cliente['D_load_Path'] = filetools.join( cliente['D_load_Path'], 'BT-torrents') cliente['D_load_Path_perm'] = filetools.file_info( cliente['D_load_Path']) if not cliente['D_load_Path_perm']: del cliente['D_load_Path_perm'] cliente['Buffer'] = str( config.get_setting("bt_buffer", server="torrent", default=50)) elif cliente['Plug_in'] == 'MCT': cliente['D_load_Path'] = str( config.get_setting("mct_download_path", server="torrent", default='')) if not cliente['D_load_Path']: continue cliente['D_load_Path'] = filetools.join( cliente['D_load_Path'], 'MCT-torrent-videos') cliente['D_load_Path_perm'] = filetools.file_info( cliente['D_load_Path']) if not cliente['D_load_Path_perm']: del cliente['D_load_Path_perm'] cliente['Buffer'] = str( config.get_setting("mct_buffer", server="torrent", default=50)) elif xbmc.getCondVisibility('System.HasAddon("plugin.video.%s")' % cliente['Plug_in']): try: __settings__ = xbmcaddon.Addon(id="plugin.video.%s" % cliente['Plug_in']) except: continue cliente['Plug_in'] = cliente['Plug_in'].capitalize() if cliente['Plug_in'] == 'Torrenter': cliente['D_load_Path'] = str( filetools.translatePath( __settings__.getSetting('storage'))) if not cliente['D_load_Path']: cliente['D_load_Path'] = str(filetools.join("special://home/", \ "cache", "xbmcup", "plugin.video.torrenter", "Torrenter")) cliente['D_load_Path_perm'] = filetools.file_info( cliente['D_load_Path']) if not cliente['D_load_Path_perm']: del cliente['D_load_Path_perm'] cliente['Buffer'] = str( __settings__.getSetting('pre_buffer_bytes')) else: cliente['D_load_Path'] = str( filetools.translatePath( __settings__.getSetting('download_path'))) cliente['D_load_Path_perm'] = filetools.file_info( cliente['D_load_Path']) if not cliente['D_load_Path_perm']: del cliente['D_load_Path_perm'] cliente['Buffer'] = str( __settings__.getSetting('buffer_size')) if __settings__.getSetting( 'download_storage' ) == '1' and __settings__.getSetting('memory_size'): cliente['Memoria'] = str( __settings__.getSetting('memory_size')) if cliente['D_load_Path']: try: if environment['os_name'].lower() == 'windows': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(cliente['D_load_Path']), None, None, ctypes.pointer(free_bytes)) cliente['Libre'] = str(round(float(free_bytes.value) / \ (1024**3), 3)).replace('.', ',') else: disk_space = os.statvfs(cliente['D_load_Path']) if not disk_space.f_frsize: disk_space.f_frsize = disk_space.f_frsize.f_bsize cliente['Libre'] = str(round((float(disk_space.f_bavail) / \ (1024**3)) * float(disk_space.f_frsize), 3)).replace('.', ',') except: pass if cliente['D_load_Path_perm']: cliente['D_load_Path'] = cliente['D_load_Path_perm'] del cliente['D_load_Path_perm'] environment['torrent_list'].append(cliente) environment['proxy_active'] = '' try: proxy_channel_bloqued_str = base64.b64decode( config.get_setting('proxy_channel_bloqued')).decode('utf-8') proxy_channel_bloqued = dict() proxy_channel_bloqued = ast.literal_eval(proxy_channel_bloqued_str) for channel_bloqued, proxy_active in list( proxy_channel_bloqued.items()): if proxy_active != 'OFF': environment['proxy_active'] += channel_bloqued + ', ' except: pass if not environment['proxy_active']: environment['proxy_active'] = 'OFF' environment['proxy_active'] = environment['proxy_active'].rstrip(', ') for root, folders, files in filetools.walk("special://logpath/"): for file in files: if file.lower() in ['kodi.log', 'jarvis.log', 'spmc.log', 'cemc.log', \ 'mygica.log', 'wonderbox.log', 'leiapp,log', \ 'leianmc.log', 'kodiapp.log', 'anmc.log', \ 'latin-anmc.log']: environment['log_path'] = str(filetools.join(root, file)) break else: environment['log_path'] = '' break if environment['log_path']: environment['log_size_bytes'] = str( filetools.getsize(environment['log_path'])) environment['log_size'] = str(round(float(environment['log_size_bytes']) / \ (1024*1024), 3)) else: environment['log_size_bytes'] = '' environment['log_size'] = '' environment['debug'] = str(config.get_setting('debug')) environment['addon_version'] = '%s (Upd: %s h.)' % (str(config.get_addon_version()), \ str(config.get_setting("addon_update_timer", default=12)).replace('0', 'No')) environment['assistant_version'] = str(None) if filetools.exists( filetools.join(config.get_data_path(), 'alfa-mobile-assistant.version')): environment['assistant_version'] = filetools.read( filetools.join(config.get_data_path(), 'alfa-mobile-assistant.version')) environment['assistant_cf_ua'] = str( config.get_setting('cf_assistant_ua', None)) except: logger.error(traceback.format_exc()) environment = {} environment['log_size'] = '' environment['cpu_usage'] = '' environment['python_version'] = '' environment['log_path'] = '' environment['userdata_free'] = '' environment['mem_total'] = '' environment['machine'] = '' environment['platform'] = '' environment['videolab_path'] = '' environment['num_version'] = '' environment['os_name'] = '' environment['video_db'] = '' environment['userdata_path'] = '' environment['log_size_bytes'] = '' environment['name_version'] = '' environment['language'] = '' environment['mem_free'] = '' environment['prod_model'] = '' environment['proxy_active'] = '' environment['architecture'] = '' environment['os_release'] = '' environment['videolab_free'] = '' environment['kodi_buffer'] = '' environment['kodi_bmode'] = '' environment['kodi_rfactor'] = '' environment['videolab_series'] = '' environment['videolab_episodios'] = '' environment['videolab_pelis'] = '' environment['videolab_update'] = '' environment['videolab_path_perm'] = '' environment['debug'] = '' environment['addon_version'] = '' environment['torrent_list'] = [] environment['torrent_lang'] = '' environment['torrentcli_option'] = '' environment['torrentcli_rar'] = '' environment['torrentcli_lib_path'] = '' environment['torrentcli_unrar'] = '' environment['torrent_error'] = '' environment['assistant_version'] = '' environment['assistant_cf_ua'] = '' return environment
def setting_torrent(item): logger.info() LIBTORRENT_PATH = config.get_setting("libtorrent_path", server="torrent", default="") LIBTORRENT_ERROR = config.get_setting("libtorrent_error", server="torrent", default="") default = config.get_setting("torrent_client", server="torrent", default=0) BUFFER = config.get_setting("mct_buffer", server="torrent", default="50") DOWNLOAD_PATH = config.get_setting( "mct_download_path", server="torrent", default=config.get_setting("downloadpath")) if not DOWNLOAD_PATH: DOWNLOAD_PATH = filetools.join(config.get_data_path(), 'downloads') BACKGROUND = config.get_setting("mct_background_download", server="torrent", default=True) RAR = config.get_setting("mct_rar_unpack", server="torrent", default=True) DOWNLOAD_LIMIT = config.get_setting("mct_download_limit", server="torrent", default="") BUFFER_BT = config.get_setting("bt_buffer", server="torrent", default="50") DOWNLOAD_PATH_BT = config.get_setting( "bt_download_path", server="torrent", default=config.get_setting("downloadpath")) if not DOWNLOAD_PATH_BT: DOWNLOAD_PATH_BT = filetools.join(config.get_data_path(), 'downloads') MAGNET2TORRENT = config.get_setting("magnet2torrent", server="torrent", default=False) CAPTURE_THRU_ROWSER_PATH = config.get_setting("capture_thru_browser_path", server="torrent", default="") ALLOW_SEEDING = config.get_setting('allow_seeding', server='torrent', default=True) torrent_options = [ config.get_localized_string(30006), config.get_localized_string(70254), config.get_localized_string(70255) ] torrent_options.extend(platformtools.torrent_client_installed()) if len(torrent_options) < default + 1: default = 0 list_controls = [{ "id": "libtorrent_path", "type": "text", "label": "Libtorrent path", "default": LIBTORRENT_PATH, "enabled": True, "visible": False }, { "id": "libtorrent_error", "type": "text", "label": "libtorrent error", "default": LIBTORRENT_ERROR, "enabled": True, "visible": False }, { "id": "list_torrent", "type": "list", "label": config.get_localized_string(70256), "default": default, "enabled": True, "visible": True, "lvalues": torrent_options }, { "id": "mct_buffer", "type": "text", "label": "MCT - Tamaño del Buffer a descargar antes de la reproducción", "default": BUFFER, "enabled": True, "visible": "eq(-1,%s)" % torrent_options[2] }, { "id": "mct_download_path", "type": "text", "label": "MCT - Ruta de la carpeta de descarga", "default": DOWNLOAD_PATH, "enabled": True, "visible": "eq(-2,%s)" % torrent_options[2] }, { "id": "bt_buffer", "type": "text", "label": "BT - Tamaño del Buffer a descargar antes de la reproducción", "default": BUFFER_BT, "enabled": True, "visible": "eq(-3,%s)" % torrent_options[1] }, { "id": "bt_download_path", "type": "text", "label": "BT - Ruta de la carpeta de descarga", "default": DOWNLOAD_PATH_BT, "enabled": True, "visible": "eq(-4,%s)" % torrent_options[1] }, { "id": "mct_download_limit", "type": "text", "label": "Límite (en Kb's) de la velocidad de descarga en segundo plano (NO afecta a RAR)", "default": DOWNLOAD_LIMIT, "enabled": True, "visible": "eq(-5,%s) | eq(-5,%s)" % (torrent_options[1], torrent_options[2]) }, { "id": "mct_rar_unpack", "type": "bool", "label": "¿Quiere que se descompriman los archivos RAR y ZIP para su reproducción?", "default": RAR, "enabled": True, "visible": True }, { "id": "mct_background_download", "type": "bool", "label": "¿Se procesa la descompresión de RARs en segundo plano?", "default": BACKGROUND, "enabled": True, "visible": True }, { "id": "magnet2torrent", "type": "bool", "label": "¿Quiere convertir los Magnets a Torrents para ver tamaños y almacenarlos?", "default": MAGNET2TORRENT, "enabled": True, "visible": True }, { "id": "capture_thru_browser_path", "type": "text", "label": "Path para descargar con un browser archivos .torrent bloqueados", "default": CAPTURE_THRU_ROWSER_PATH, "enabled": True, "visible": True }, { "id": "allow_seeding", "type": "bool", "label": "¿Quiere permitir el semillado de los torrents descargados?", "default": ALLOW_SEEDING, "enabled": True, "visible": True }] platformtools.show_channel_settings( list_controls=list_controls, callback='save_setting_torrent', item=item, caption=config.get_localized_string(70257), custom_button={'visible': False}) if item.item_org: item_org = Item().fromurl(item.item_org) if item_org.torrent_info: del item_org.torrent_info platformtools.itemlist_update(item_org)
def reactivate_unrar(init=False, mute=True): logger.info() if not mute: platformtools.dialog_notification("Iniciando recuperación de", "UnRARs interrumpidos") torrent_options = [] torrent_options.append("Cliente interno BT") torrent_options.append("Cliente interno MCT") torrent_options.extend( platformtools.torrent_client_installed(show_tuple=False)) download_paths = [] for torr_client in torrent_options: # Localizamos el path de descarga del .torrent torr_client = torr_client.replace('Plugin externo: ', '').replace('Cliente interno ', '') save_path_videos = '' __settings__ = '' if torr_client != 'BT' and torr_client != 'MCT': __settings__ = xbmcaddon.Addon( id="plugin.video.%s" % torr_client) # Apunta settings del cliente torrent externo if torr_client == 'BT'and str(config.get_setting("bt_download_path", \ server="torrent", default='')): save_path_videos = filetools.join(str(config.get_setting("bt_download_path", \ server="torrent", default='')), 'BT-torrents') elif torr_client == 'MCT' and str(config.get_setting("mct_download_path", \ server="torrent", default='')): save_path_videos = filetools.join(str(config.get_setting("mct_download_path", \ server="torrent", default='')), 'MCT-torrent-videos') elif torr_client == 'torrenter': save_path_videos = str( xbmc.translatePath(__settings__.getSetting('storage'))) if not save_path_videos: save_path_videos = str(filetools.join(xbmc.translatePath("special://home/"), \ "cache", "xbmcup", "plugin.video.torrenter", "Torrenter")) else: save_path_videos = str( xbmc.translatePath(__settings__.getSetting('download_path'))) filetools.remove( filetools.join(save_path_videos, 'torrents', 'cliente_torrent_Alfa.torrent') ) # Borramos .torrent zombie if __settings__.getSetting( 'download_storage') == '1': # Descarga en memoria? continue # pasamos if not save_path_videos: # No hay path de descarga? continue # pasamos for t_client, download_path in download_paths: if save_path_videos == download_path: break else: # Borramos archivos de control "zombies" rar_control = {} if filetools.exists( filetools.join(save_path_videos, '_rar_control.json')): rar_control = jsontools.load( filetools.read( filetools.join(save_path_videos, '_rar_control.json'))) if rar_control and len(rar_control['rar_files']) == 1: ret = filetools.remove(filetools.join(save_path_videos, '_rar_control.json'), silent=True) download_paths.append( (torr_client, save_path_videos)) # Agregamos el path para este Cliente search_for_unrar_in_error(download_paths, init=init)