def play_torrent(item, xlistitem, mediaurl): logger.info("platformtools play_torrent") # Opciones disponibles para Reproducir torrents torrent_options = list() torrent_options.append(["Cliente interno (necesario libtorrent)"]) torrent_options.append(["Cliente interno MCT (necesario libtorrent)"]) # Plugins externos se pueden añadir otros if xbmc.getCondVisibility('System.HasAddon("plugin.video.xbmctorrent")'): torrent_options.append(["Plugin externo: xbmctorrent", "plugin://plugin.video.xbmctorrent/play/%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.pulsar")'): torrent_options.append(["Plugin externo: pulsar", "plugin://plugin.video.pulsar/play?uri=%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.quasar")'): torrent_options.append(["Plugin externo: quasar", "plugin://plugin.video.quasar/play?uri=%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.stream")'): torrent_options.append(["Plugin externo: stream", "plugin://plugin.video.stream/play/%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.torrenter")'): torrent_options.append(["Plugin externo: torrenter", "plugin://plugin.video.torrenter/?action=playSTRM&url=%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.torrentin")'): torrent_options.append(["Plugin externo: torrentin", "plugin://plugin.video.torrentin/?uri=%s&image="]) if len(torrent_options) > 1: seleccion = dialog_select("Abrir torrent con...", [opcion[0] for opcion in torrent_options]) else: seleccion = 0 # Plugins externos if seleccion > 1: mediaurl = urllib.quote_plus(item.url) xbmc.executebuiltin("PlayMedia(" + torrent_options[seleccion][1] % mediaurl + ")") if seleccion == 1: from platformcode import mct mct.play(mediaurl, xlistitem, subtitle=item.subtitle) # Reproductor propio (libtorrent) if seleccion == 0: import time played = False debug = (config.get_setting("debug") == "true") # Importamos el cliente from btserver import Client # Iniciamos el cliente: c = Client(url=mediaurl, is_playing_fnc=xbmc.Player().isPlaying, wait_time=None, timeout=10, temp_path=os.path.join(config.get_data_path(), "torrent"), print_status=debug) # Mostramos el progreso progreso = dialog_progress("Pelisalacarta - Torrent", "Iniciando...") # Mientras el progreso no sea cancelado ni el cliente cerrado while not c.closed: try: # Obtenemos el estado del torrent s = c.status if debug: # Montamos las tres lineas con la info del torrent txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d) | DHT:%s (%d) | Trakers: %d' % \ (s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete, s.dht_state, s.dht_nodes, s.trackers) txt3 = 'Origen Peers TRK: %d DHT: %d PEX: %d LSD %d ' % \ (s.trk_peers, s.dht_peers, s.pex_peers, s.lsd_peers) else: txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d)' % (s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete) try: txt3 = 'Deteniendo automaticamente en: %ss' % (int(s.timeout)) except: txt3 = '' progreso.update(s.buffer, txt, txt2, txt3) time.sleep(0.5) if progreso.iscanceled(): progreso.close() if s.buffer == 100: if dialog_yesno("Pelisalacarta - Torrent", "¿Deseas iniciar la reproduccion?"): played = False progreso = dialog_progress("Pelisalacarta - Torrent", "") progreso.update(s.buffer, txt, txt2, txt3) else: progreso = dialog_progress("Pelisalacarta - Torrent", "") break else: if dialog_yesno("Pelisalacarta - Torrent", "¿Deseas cancelar el proceso?"): progreso = dialog_progress("Pelisalacarta - Torrent", "") break else: progreso = dialog_progress("Pelisalacarta - Torrent", "") progreso.update(s.buffer, txt, txt2, txt3) # Si el buffer se ha llenado y la reproduccion no ha sido iniciada, se inicia if s.buffer == 100 and not played: # Cerramos el progreso progreso.close() # Obtenemos el playlist del torrent videourl = c.get_play_list() # Iniciamos el reproductor playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() playlist.add(videourl, xlistitem) xbmc_player = xbmc.Player() xbmc_player.play(playlist) # Marcamos como reproducido para que no se vuelva a iniciar played = True # Y esperamos a que el reproductor se cierre while xbmc.Player().isPlaying(): time.sleep(1) # Cuando este cerrado, Volvemos a mostrar el dialogo progreso = dialog_progress("Pelisalacarta - Torrent", "") progreso.update(s.buffer, txt, txt2, txt3) except: import traceback logger.info(traceback.format_exc()) break progreso.update(100, "Terminando y eliminando datos", " ", " ") # Detenemos el cliente if not c.closed: c.stop() # Y cerramos el progreso progreso.close()
def play_torrent(item, xlistitem, mediaurl): logger.info() # Opciones disponibles para Reproducir torrents torrent_options = list() torrent_options.append(["Cliente interno (necesario libtorrent)"]) torrent_options.append(["Cliente interno MCT (necesario libtorrent)"]) torrent_options.extend(torrent_client_installed(show_tuple=True)) torrent_client = config.get_setting("torrent_client", server="torrent") if torrent_client and torrent_client - 1 <= len(torrent_options): if torrent_client == 0: seleccion = dialog_select( "Abrir torrent con...", [opcion[0] for opcion in torrent_options]) else: seleccion = torrent_client - 1 else: if len(torrent_options) > 1: seleccion = dialog_select( "Abrir torrent con...", [opcion[0] for opcion in torrent_options]) else: seleccion = 0 # Plugins externos if seleccion > 1: mediaurl = urllib.quote_plus(item.url) xbmc.executebuiltin("PlayMedia(" + torrent_options[seleccion][1] % mediaurl + ")") if seleccion == 1: from platformcode import mct mct.play(mediaurl, xlistitem, subtitle=item.subtitle, item=item) # Reproductor propio (libtorrent) if seleccion == 0: import time played = False debug = (config.get_setting("debug") == True) # Importamos el cliente from btserver import Client client_tmp_path = config.get_setting("downloadpath") if not client_tmp_path: client_tmp_path = config.get_data_path() # Iniciamos el cliente: c = Client(url=mediaurl, is_playing_fnc=xbmc.Player().isPlaying, wait_time=None, timeout=10, temp_path=os.path.join(client_tmp_path, "alfa-torrent"), print_status=debug) # Mostramos el progreso progreso = dialog_progress("Alfa - Torrent", "Iniciando...") # Mientras el progreso no sea cancelado ni el cliente cerrado while not c.closed: try: # Obtenemos el estado del torrent s = c.status if debug: # Montamos las tres lineas con la info del torrent txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d) | DHT:%s (%d) | Trakers: %d' % \ (s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete, s.dht_state, s.dht_nodes, s.trackers) txt3 = 'Origen Peers TRK: %d DHT: %d PEX: %d LSD %d ' % \ (s.trk_peers, s.dht_peers, s.pex_peers, s.lsd_peers) else: txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d)' % ( s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete) try: txt3 = 'Deteniendo automaticamente en: %ss' % (int( s.timeout)) except: txt3 = '' progreso.update(s.buffer, txt, txt2, txt3) time.sleep(0.5) if progreso.iscanceled(): progreso.close() if s.buffer == 100: if dialog_yesno("Alfa - Torrent", "¿Deseas iniciar la reproduccion?"): played = False progreso = dialog_progress("Alfa - Torrent", "") progreso.update(s.buffer, txt, txt2, txt3) else: progreso = dialog_progress("Alfa - Torrent", "") break else: if dialog_yesno("Alfa - Torrent", "¿Deseas cancelar el proceso?"): progreso = dialog_progress("Alfa - Torrent", "") break else: progreso = dialog_progress("Alfa - Torrent", "") progreso.update(s.buffer, txt, txt2, txt3) # Si el buffer se ha llenado y la reproduccion no ha sido iniciada, se inicia if s.buffer == 100 and not played: # Cerramos el progreso progreso.close() # Obtenemos el playlist del torrent videourl = c.get_play_list() # Iniciamos el reproductor playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() playlist.add(videourl, xlistitem) xbmc_player = xbmc.Player() xbmc_player.play(playlist) # Marcamos como reproducido para que no se vuelva a iniciar played = True # si es un archivo de la videoteca enviar a marcar como visto if item.strm_path: from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_auto_as_watched(item) # Y esperamos a que el reproductor se cierre while xbmc.Player().isPlaying(): time.sleep(1) # Cuando este cerrado, Volvemos a mostrar el dialogo progreso = dialog_progress("Alfa - Torrent", "") progreso.update(s.buffer, txt, txt2, txt3) except: import traceback logger.error(traceback.format_exc()) break progreso.update(100, "Terminando y eliminando datos", " ", " ") # Detenemos el cliente if not c.closed: c.stop() # Y cerramos el progreso progreso.close()
def play_torrent(self, item): import time import os played = False #Importamos el cliente from btserver import Client #Iniciamos el cliente: c = Client(url=item.url, is_playing_fnc=self.is_playing, wait_time=None, timeout=5, temp_path=os.path.join(config.get_data_path(), "torrent")) #Mostramos el progreso progreso = self.dialog_progress("Pelisalacarta - Torrent", "Iniciando...") #Mientras el progreso no sea cancelado ni el cliente cerrado while not progreso.iscanceled() and not c.closed: try: #Obtenemos el estado del torrent s = c.status #Montamos las tres lineas con la info del torrent txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d) | DHT:%s (%d) | Trakers: %d' % \ (s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete, s.dht_state, s.dht_nodes, s.trackers) txt3 = 'Origen Peers TRK: %d DHT: %d PEX: %d LSD %d ' % \ (s.trk_peers,s.dht_peers, s.pex_peers, s.lsd_peers) progreso.update(s.buffer, txt, txt2, txt3) time.sleep(1) #Si el buffer se ha llenado y la reproduccion no ha sido iniciada, se inicia if s.buffer == 100 and not played: #Cerramos el progreso progreso.close() #Obtenemos el playlist del torrent item.video_url = c.get_play_list() item.server = "directo" self.play_video(item) #Marcamos como reproducido para que no se vuelva a iniciar played = True #Y esperamos a que el reproductor se cierre while self.is_playing(): time.sleep(1) #Cuando este cerrado, Volvemos a mostrar el dialogo progreso = self.dialog_progress("Pelisalacarta - Torrent", "Iniciando...") except: import traceback logger.info(traceback.format_exc()) break progreso.update(100, "Terminando y eliminando datos", " ", " ") #Detenemos el cliente if not c.closed: c.stop() #Y cerramos el progreso progreso.close() return
def play_torrent(item): """ Reproduce un torrent :param item: :return: """ logger.trace() # Creamos el listItem listitem = xbmcgui.ListItem() # Asignamos los datos viewtools.set_item_info(item, listitem) listitem.setArt({'fanart': item.fanart}) listitem.setArt({'poster': item.poster}) listitem.setArt({'banner': item.banner}) listitem.setArt({'thumb': item.thumb}) # Opciones disponibles para Reproducir torrents options = list() try: from btserver import Client except Exception: pass else: options.append(["Cliente interno", True]) # Plugins externos se pueden añadir otros if xbmc.getCondVisibility('System.HasAddon("plugin.video.xbmctorrent")'): options.append([ "Plugin externo: xbmctorrent", "plugin://plugin.video.xbmctorrent/play/%s" ]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.pulsar")'): options.append([ "Plugin externo: pulsar", "plugin://plugin.video.pulsar/play?uri=%s" ]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.quasar")'): options.append([ "Plugin externo: quasar", "plugin://plugin.video.quasar/play?uri=%s" ]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.stream")'): options.append( ["Plugin externo: stream", "plugin://plugin.video.stream/play/%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.torrenter")'): options.append([ "Plugin externo: torrenter", "plugin://plugin.video.torrenter/?action=playSTRM&url=%s" ]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.torrentin")'): options.append([ "Plugin externo: torrentin", "plugin://plugin.video.torrentin/?uri=%s&image=" ]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.elementum")'): data = '' if item.mediatype == 'movie': data += '&tmdb=%s&type=movie' % item.tmdb_id else: data += '&show=%s' % item.tmdb_id if item.mediatype == 'episode': data += '&season=%s&episode=%s' % (item.season, item.episode) options.append([ "Plugin externo: Elementum", "plugin://plugin.video.elementum/play?uri=%%s%s" % data ]) if len(options) > 1: index = dialog_select("Abrir torrent con...", [o[0] for o in options]) elif not len(options): platformtools.dialog_ok( 'MediaExplorer', 'No se ha detectado ningun cliente torrent compatible', 'Instala alguno y vuelve a intentarlo') index = -1 else: index = 0 # Comprobamos si necesitamos un proxy o no if not httptools.downloadpage(item.url, only_headers=True).sucess: data = httptools.downloadpage(item.url, use_proxy=True).data if data: import tempfile with tempfile.NamedTemporaryFile(delete=False) as t: t.write(data) item.url = t.name if index >= 0 and options[index][1] is True: # Reproductor propio (libtorrent) played = False first = True debug = settings.get_setting("debug") == 3 # Importamos el cliente from btserver import Client # Directorio torrent client_tmp_path = os.path.join(sysinfo.data_path, 'torrent') # Si no existe el directorio lo creamos if not os.path.isdir(client_tmp_path): os.makedirs(client_tmp_path) # Iniciamos el cliente: c = Client(url=item.url, is_playing_fnc=xbmc.Player().isPlaying, wait_time=None, timeout=10, temp_path=client_tmp_path, print_status=debug) # Mostramos el progreso dialog = dialog_progress("Torrent", "Iniciando...") # Mientras el progreso no sea cancelado ni el cliente cerrado while not c.closed: try: # Obtenemos el estado del torrent s = c.status if debug: # Montamos las tres lineas con la info del torrent txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % ( s.progress_file, s.file_size, s.str_state, s.download_rate) txt2 = 'S: %d(%d) P: %d(%d) | DHT:%s (%d) | Trakers: %d' % ( s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete, s.dht_state, s.dht_nodes, s.trackers) txt3 = 'Origen Peers TRK: %d DHT: %d PEX: %d LSD %d ' % ( s.trk_peers, s.dht_peers, s.pex_peers, s.lsd_peers) else: txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % ( s.progress_file, s.file_size, s.str_state, s.download_rate) txt2 = 'S: %d(%d) P: %d(%d)' % ( s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete) txt3 = 'Deteniendo automaticamente en: %s' % s.timeout dialog.update(s.buffer, txt, txt2, txt3) time.sleep(0.5) if dialog.iscanceled(): dialog.close() if s.buffer == 100: if dialog_yesno("Torrent", "¿Deseas iniciar la reproduccion?"): played = False dialog = dialog_progress("Torrent", "") dialog.update(s.buffer, txt, txt2, txt3) else: dialog = dialog_progress("Torrent", "") break else: if dialog_yesno("Torrent", "¿Deseas cancelar el proceso?"): dialog = dialog_progress("Torrent", "") break else: dialog = dialog_progress("Torrent", "") dialog.update(s.buffer, txt, txt2, txt3) # Si el buffer se ha llenado y la reproduccion no ha sido iniciada, se inicia if s.buffer == 100 and not played: # Cerramos el progreso dialog.close() # Reproducimos if not settings.get_setting( 'setResolvedUrl', platformsettings.__file__) or not first: # Creamos el playlist playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() # Añadimos la url y reproducimos playlist.add(c.get_play_list(), listitem) xbmc.Player().play(playlist, listitem) # Kodi 18 - Evitar que se quede en loading al reproducir xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=False) else: first = False # Añadimos la url y reproducimos listitem.setPath(c.get_play_list()) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) logger.debug(xbmc.Player().isPlaying()) time.sleep(1) # Marcamos como reproducido para que no se vuelva a iniciar played = True # Y esperamos a que el reproductor se cierre while xbmc.Player().isPlaying(): time.sleep(1) # Cuando este cerrado, Volvemos a mostrar el dialogo dialog = dialog_progress("Torrent", "") dialog.update(s.buffer, txt, txt2, txt3) except Exception: logger.error() break dialog.update(100, "Terminando y eliminando datos", " ", " ") # Detenemos el cliente if not c.closed: c.stop() # Y cerramos el progreso dialog.close() elif index >= 0: # Plugins externos logger.debug("Llamando a %s..." % options[index][0]) if not settings.get_setting('setResolvedUrl', platformsettings.__file__): # Creamos el playlist playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() # Añadimos la url y reproducimos playlist.add(options[index][1] % urllib.quote_plus(item.url), listitem) xbmc.Player().play(playlist, listitem) else: # Añadimos la url y reproducimos listitem.setPath(options[index][1] % urllib.quote_plus(item.url)) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) else: # Fix ventana Lista Abortada if settings.get_setting('setResolvedUrl', platformsettings.__file__): xbmcplugin.setResolvedUrl( int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(sysinfo.runtime_path, "resources", "nomedia"))) xbmc.Player().stop() # Eliminar temporales si es necesario if os.path.isfile(item.url): os.remove(item.url)
def play_video(item,desdefavoritos=False,desdedescargados=False,desderrordescargas=False,strmfile=False): from core import servertools logger.info("streamondemand.platformcode.xbmctools play_video") #logger.info(item.tostring('\n')) try: item.server = item.server.lower() except: item.server = "" if item.server=="": item.server="directo" view = False # Abre el diálogo de selección opciones = [] default_action = config.get_setting("default_action") logger.info("default_action="+default_action) # Si no es el modo normal, no muestra el diálogo porque cuelga XBMC muestra_dialogo = (config.get_setting("player_mode")=="0" and not strmfile) # Extrae las URL de los vídeos, y si no puedes verlo te dice el motivo video_urls,puedes,motivo = servertools.resolve_video_urls_for_playing(item.server,item.url,item.password,muestra_dialogo) # Si puedes ver el vídeo, presenta las opciones if puedes: for video_url in video_urls: opciones.append(config.get_localized_string(30151) + " " + video_url[0]) if item.server=="local": opciones.append(config.get_localized_string(30164)) else: opcion = config.get_localized_string(30153) opciones.append(opcion) # "Descargar" if item.channel=="favoritos": opciones.append(config.get_localized_string(30154)) # "Quitar de favoritos" else: opciones.append(config.get_localized_string(30155)) # "Añadir a favoritos" if not strmfile: opciones.append(config.get_localized_string(30161)) # "Añadir a Biblioteca" if item.channel!="descargas": opciones.append(config.get_localized_string(30157)) # "Añadir a lista de descargas" else: if item.category=="errores": opciones.append(config.get_localized_string(30159)) # "Borrar descarga definitivamente" opciones.append(config.get_localized_string(30160)) # "Pasar de nuevo a lista de descargas" else: opciones.append(config.get_localized_string(30156)) # "Quitar de lista de descargas" if config.get_setting("jdownloader_enabled")=="true": opciones.append(config.get_localized_string(30158)) # "Enviar a JDownloader" if default_action=="3": seleccion = len(opciones)-1 # Busqueda de trailers en youtube if not item.channel in ["Trailer","ecarteleratrailers"]: opciones.append(config.get_localized_string(30162)) # "Buscar Trailer" # Si no puedes ver el vídeo te informa else: if item.server!="": advertencia = xbmcgui.Dialog() if "<br/>" in motivo: resultado = advertencia.ok("Non è possibile guardare il video perché...", motivo.split("<br/>")[0], motivo.split("<br/>")[1], item.url) else: resultado = advertencia.ok("Non è possibile guardare il video perché...", motivo, item.url) else: resultado = advertencia.ok("Non è possibile guardare il video perché...", "Il server che lo ospita non è", "ancora supportato da streamondemand", item.url) if item.channel=="favoritos": opciones.append(config.get_localized_string(30154)) # "Quitar de favoritos" if item.channel=="descargas": if item.category=="errores": opciones.append(config.get_localized_string(30159)) # "Borrar descarga definitivamente" else: opciones.append(config.get_localized_string(30156)) # "Quitar de lista de descargas" if len(opciones)==0: return # Si la accion por defecto es "Preguntar", pregunta if default_action=="0": # and server!="torrent": dia = xbmcgui.Dialog() seleccion = dia.select(config.get_localized_string(30163), opciones) # "Elige una opción" #dia.close() ''' elif default_action=="0" and server=="torrent": advertencia = xbmcgui.Dialog() logger.info("video_urls[0]="+str(video_urls[0][1])) if puedes and ('"status":"COMPLETED"' in video_urls[0][1] or '"percent_done":100' in video_urls[0][1]): listo = "y está listo para ver" else: listo = "y se está descargando" resultado = advertencia.ok( "Torrent" , "El torrent ha sido añadido a la lista" , listo ) seleccion=-1 ''' elif default_action=="1": seleccion = 0 elif default_action=="2": seleccion = len(video_urls)-1 elif default_action=="3": seleccion = seleccion else: seleccion=0 logger.info("seleccion=%d" % seleccion) logger.info("seleccion=%s" % opciones[seleccion]) # No ha elegido nada, lo más probable porque haya dado al ESC if seleccion==-1: #Para evitar el error "Uno o más elementos fallaron" al cancelar la selección desde fichero strm listitem = xbmcgui.ListItem( item.title, iconImage="DefaultVideo.png", thumbnailImage=item.thumbnail) xbmcplugin.setResolvedUrl(int(sys.argv[ 1 ]),False,listitem) # JUR Added #if config.get_setting("subtitulo") == "true": # config.set_setting("subtitulo", "false") return if opciones[seleccion]==config.get_localized_string(30158): # "Enviar a JDownloader" #d = {"web": url}urllib.urlencode(d) from core import scrapertools if item.subtitle!="": data = scrapertools.cachePage(config.get_setting("jdownloader")+"/action/add/links/grabber0/start1/web="+item.url+ " " +item.thumbnail + " " + item.subtitle) else: data = scrapertools.cachePage(config.get_setting("jdownloader")+"/action/add/links/grabber0/start1/web="+item.url+ " " +item.thumbnail) return if opciones[seleccion]==config.get_localized_string(30158).replace("jDownloader","pyLoad"): # "Enviar a pyLoad" logger.info("Enviando a pyload...") if item.show!="": package_name = item.show else: package_name = "streamondemand" from core import pyload_client pyload_client.download(url=item.url,package_name=package_name) return elif opciones[seleccion]==config.get_localized_string(30164): # Borrar archivo en descargas # En "extra" está el nombre del fichero en favoritos os.remove( item.url ) xbmc.executebuiltin( "Container.Refresh" ) return # Ha elegido uno de los vídeos elif seleccion < len(video_urls): mediaurl = video_urls[seleccion][1] if len(video_urls[seleccion])>3: wait_time = video_urls[seleccion][2] item.subtitle = video_urls[seleccion][3] elif len(video_urls[seleccion])>2: wait_time = video_urls[seleccion][2] else: wait_time = 0 view = True # Descargar elif opciones[seleccion]==config.get_localized_string(30153): # "Descargar" download_title = item.fulltitle if item.hasContentDetails=="true": download_title = item.contentTitle # El vídeo de más calidad es el último mediaurl = video_urls[len(video_urls)-1][1] from core import downloadtools keyboard = xbmc.Keyboard(download_title) keyboard.doModal() if (keyboard.isConfirmed()): download_title = keyboard.getText() devuelve = downloadtools.downloadbest(video_urls,download_title) if devuelve==0: advertencia = xbmcgui.Dialog() resultado = advertencia.ok("plugin", "Scaricato con successo") elif devuelve==-1: advertencia = xbmcgui.Dialog() resultado = advertencia.ok("plugin", "Download interrotto") else: advertencia = xbmcgui.Dialog() resultado = advertencia.ok("plugin", "Errore nel download") return elif opciones[seleccion]==config.get_localized_string(30154): #"Quitar de favoritos" from channels import favoritos # En "extra" está el nombre del fichero en favoritos favoritos.deletebookmark(urllib.unquote_plus( item.extra )) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30102) , item.title , config.get_localized_string(30105)) # 'Se ha quitado de favoritos' xbmc.executebuiltin( "Container.Refresh" ) return elif opciones[seleccion]==config.get_localized_string(30159): #"Borrar descarga definitivamente" from channels import descargas descargas.delete_error_bookmark(urllib.unquote_plus( item.extra )) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30101) , item.title , config.get_localized_string(30106)) # 'Se ha quitado de la lista' xbmc.executebuiltin( "Container.Refresh" ) return elif opciones[seleccion]==config.get_localized_string(30160): #"Pasar de nuevo a lista de descargas": from channels import descargas descargas.mover_descarga_error_a_pendiente(urllib.unquote_plus( item.extra )) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30101) , item.title , config.get_localized_string(30107)) # 'Ha pasado de nuevo a la lista de descargas' return elif opciones[seleccion]==config.get_localized_string(30155): #"Añadir a favoritos": from channels import favoritos from core import downloadtools download_title = item.fulltitle download_thumbnail = item.thumbnail download_plot = item.plot if item.hasContentDetails=="true": download_title = item.contentTitle download_thumbnail = item.contentThumbnail download_plot = item.contentPlot keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(download_title)+" ["+item.channel+"]") keyboard.doModal() if keyboard.isConfirmed(): title = keyboard.getText() favoritos.savebookmark(titulo=title,url=item.url,thumbnail=download_thumbnail,server=item.server,plot=download_plot,fulltitle=title) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30102) , title , config.get_localized_string(30108)) # 'se ha añadido a favoritos' return elif opciones[seleccion]==config.get_localized_string(30156): #"Quitar de lista de descargas": # La categoría es el nombre del fichero en la lista de descargas from channels import descargas descargas.deletebookmark((urllib.unquote_plus( item.extra ))) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30101) , item.title , config.get_localized_string(30106)) # 'Se ha quitado de lista de descargas' xbmc.executebuiltin( "Container.Refresh" ) return elif opciones[seleccion]==config.get_localized_string(30157): #"Añadir a lista de descargas": from core import downloadtools download_title = item.fulltitle download_thumbnail = item.thumbnail download_plot = item.plot if item.hasContentDetails=="true": download_title = item.contentTitle download_thumbnail = item.contentThumbnail download_plot = item.contentPlot keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(download_title)) keyboard.doModal() if keyboard.isConfirmed(): download_title = keyboard.getText() from channels import descargas descargas.savebookmark(titulo=download_title,url=item.url,thumbnail=download_thumbnail,server=item.server,plot=download_plot,fulltitle=download_title) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30101) , download_title , config.get_localized_string(30109)) # 'se ha añadido a la lista de descargas' return elif opciones[seleccion] == config.get_localized_string(30161): # "Añadir a Biblioteca": # Library titulo = item.fulltitle if titulo == "": titulo = item.title #library.savelibrary(titulo,item.url,item.thumbnail,item.server,item.plot,canal=item.channel,category=item.category,Serie=item.show) # TODO ¿SOLO peliculas? #logger.debug(item.tostring('\n')) new_item = item.clone(title=titulo, action="play_from_library", category="Cine", fulltitle=item.fulltitle, channel=item.channel) #logger.debug(new_item.tostring('\n')) insertados, sobreescritos, fallidos = library.save_library_movie(new_item) advertencia = xbmcgui.Dialog() if fallidos == 0: advertencia.ok(config.get_localized_string(30131), titulo, config.get_localized_string(30135)) # 'se ha añadido a la biblioteca' return elif opciones[seleccion]==config.get_localized_string(30162): #"Buscar Trailer": config.set_setting("subtitulo", "false") xbmc.executebuiltin("XBMC.RunPlugin(%s?%s)" % ( sys.argv[ 0 ] , item.clone(channel="trailertools", action="buscartrailer", contextual=True).tourl())) return # Si no hay mediaurl es porque el vídeo no está :) logger.info("streamondemand.platformcode.xbmctools mediaurl="+mediaurl) if mediaurl=="": if server == "unknown": alertUnsopportedServer() else: alertnodisponibleserver(item.server) return # Si hay un tiempo de espera (como en megaupload), lo impone ahora if wait_time>0: continuar = handle_wait(wait_time,server,"Cargando vídeo...") if not continuar: return # Obtención datos de la Biblioteca (solo strms que estén en la biblioteca) if strmfile: xlistitem = getLibraryInfo(mediaurl) else: play_title = item.fulltitle play_thumbnail = item.thumbnail play_plot = item.plot if item.hasContentDetails=="true": play_title = item.contentTitle play_thumbnail = item.contentThumbnail play_plot = item.contentPlot try: xlistitem = xbmcgui.ListItem( play_title, iconImage="DefaultVideo.png", thumbnailImage=play_thumbnail, path=mediaurl) except: xlistitem = xbmcgui.ListItem( play_title, iconImage="DefaultVideo.png", thumbnailImage=play_thumbnail) xlistitem.setInfo( "video", { "Title": play_title, "Plot" : play_plot , "Studio" : item.channel , "Genre" : item.category } ) #set_infoLabels(listitem,plot) # Modificacion introducida por super_berny para añadir infoLabels al ListItem # Lanza el reproductor # Lanza el reproductor if strmfile and not item.from_biblioteca: #Si es un fichero strm no hace falta el play xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem) if item.subtitle != "": xbmc.sleep(2000) xbmc.Player().setSubtitles(item.subtitle) #Movido del conector "torrent" aqui elif item.server=="torrent": #Opciones disponibles para Reproducir torrents torrent_options = [] torrent_options.append(["Cliente interno (necesario libtorrent)"]) torrent_options.append(["Cliente interno MCT (necesario libtorrent)"]) #Plugins externos se pueden añadir otros if xbmc.getCondVisibility('System.HasAddon("plugin.video.xbmctorrent")'): torrent_options.append(["Plugin externo: xbmctorrent","plugin://plugin.video.xbmctorrent/play/%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.pulsar")'): torrent_options.append(["Plugin externo: pulsar","plugin://plugin.video.pulsar/play?uri=%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.quasar")'): torrent_options.append(["Plugin externo: quasar","plugin://plugin.video.quasar/play?uri=%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.stream")'): torrent_options.append(["Plugin externo: stream","plugin://plugin.video.stream/play/%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.torrenter")'): torrent_options.append(["Plugin externo: torrenter","plugin://plugin.video.torrenter/?action=playSTRM&url=%s"]) if xbmc.getCondVisibility('System.HasAddon("plugin.video.torrentin")'): torrent_options.append(["Plugin externo: torrentin","plugin://plugin.video.torrentin/?uri=%s&image="]) if len(torrent_options)>1: seleccion = xbmcgui.Dialog().select("Abrir torrent con...", [opcion[0] for opcion in torrent_options]) else: seleccion = 0 #Plugins externos if seleccion > 1: mediaurl = urllib.quote_plus(item.url) xbmc.executebuiltin( "PlayMedia(" + torrent_options[seleccion][1] % mediaurl +")" ) if seleccion ==1: from platformcode import mct mct.play( mediaurl, xbmcgui.ListItem("", iconImage=item.thumbnail, thumbnailImage=item.thumbnail), subtitle=item.subtitle ) #Reproductor propio (libtorrent) if seleccion == 0: import time videourl = None played = False #Importamos el cliente from btserver import Client #Iniciamos el cliente: c = Client(url=mediaurl, is_playing_fnc= xbmc.Player().isPlaying, wait_time=None, timeout=5, temp_path =os.path.join(config.get_data_path(),"torrent") ) #Mostramos el progreso progreso = xbmcgui.DialogProgress() progreso.create( "streamondemand - Torrent" , "Iniciando...") #Mientras el progreso no sea cancelado ni el cliente cerrado while not progreso.iscanceled() and not c.closed: try: #Obtenemos el estado del torrent s = c.status #Montamos las tres lineas con la info del torrent txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d) | DHT:%s (%d) | Trakers: %d' % \ (s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete, s.dht_state, s.dht_nodes, s.trackers) txt3 = 'Origen Peers TRK: %d DHT: %d PEX: %d LSD %d ' % \ (s.trk_peers,s.dht_peers, s.pex_peers, s.lsd_peers) progreso.update(s.buffer,txt, txt2, txt3) time.sleep(1) #Si el buffer se ha llenado y la reproduccion no ha sido iniciada, se inicia if s.buffer == 100 and not played: #Cerramos el progreso progreso.close() #Obtenemos el playlist del torrent videourl = c.get_play_list() #Iniciamos el reproductor playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO ) playlist.clear() playlist.add( videourl, xlistitem ) xbmcPlayer = xbmc.Player() xbmcPlayer.play(playlist) #Marcamos como reproducido para que no se vuelva a iniciar played = True #Y esperamos a que el reproductor se cierre while xbmc.Player().isPlaying(): time.sleep(1) #Cuando este cerrado, Volvemos a mostrar el dialogo progreso.create( "streamondemand - Torrent" , "Iniciando...") except: import traceback logger.info(traceback.format_exc()) break progreso.update(100,"Terminato, elimina dati"," "," ") #Detenemos el cliente if not c.closed: c.stop() #Y cerramos el progreso progreso.close() return else: logger.info("player_mode="+config.get_setting("player_mode")) logger.info("mediaurl="+mediaurl) if config.get_setting("player_mode")=="3" or "megacrypter.com" in mediaurl: import download_and_play download_and_play.download_and_play( mediaurl , "download_and_play.tmp" , config.get_setting("downloadpath") ) return elif config.get_setting("player_mode")=="0" or (config.get_setting("player_mode")=="3" and mediaurl.startswith("rtmp")): # Añadimos el listitem a una lista de reproducción (playlist) playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO ) playlist.clear() playlist.add( mediaurl, xlistitem ) # Reproduce playersettings = config.get_setting('player_type') logger.info("streamondemand.platformcode.xbmctools playersettings="+playersettings) if config.get_system_platform()=="xbox": player_type = xbmc.PLAYER_CORE_AUTO if playersettings == "0": player_type = xbmc.PLAYER_CORE_AUTO logger.info("streamondemand.platformcode.xbmctools PLAYER_CORE_AUTO") elif playersettings == "1": player_type = xbmc.PLAYER_CORE_MPLAYER logger.info("streamondemand.platformcode.xbmctools PLAYER_CORE_MPLAYER") elif playersettings == "2": player_type = xbmc.PLAYER_CORE_DVDPLAYER logger.info("streamondemand.platformcode.xbmctools PLAYER_CORE_DVDPLAYER") xbmcPlayer = xbmc.Player( player_type ) else: xbmcPlayer = xbmc.Player() xbmcPlayer.play(playlist) if item.channel=="cuevana" and item.subtitle!="": logger.info("subtitulo="+subtitle) if item.subtitle!="" and (opciones[seleccion].startswith("Ver") or opciones[seleccion].startswith("Watch")): logger.info("streamondemand.platformcode.xbmctools Con subtitulos") setSubtitles() elif config.get_setting("player_mode")=="1": logger.info("mediaurl :"+ mediaurl) logger.info("Tras setResolvedUrl") xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=mediaurl)) elif config.get_setting("player_mode")=="2": xbmc.executebuiltin( "PlayMedia("+mediaurl+")" ) if item.subtitle!="" and view: logger.info("Subtítulos externos: "+item.subtitle) xbmc.Player().setSubtitles(item.subtitle)
def bt_client(mediaurl, xlistitem, rar_files, subtitle=None, password=None, item=None): logger.info() # Importamos el cliente from btserver import Client played = False debug = False save_path_videos = filetools.join(config.get_setting("bt_download_path", server="torrent", default=config.get_setting("downloadpath")), 'BT-torrents') if not save_path_videos: save_path_videos = filetools.join(config.get_data_path(), 'BT-torrents') UNRAR = config.get_setting("unrar_path", server="torrent", default="") BACKGROUND = config.get_setting("mct_background_download", server="torrent", default=True) RAR = config.get_setting("mct_rar_unpack", server="torrent", default=True) try: BUFFER = int(config.get_setting("bt_buffer", server="torrent", default="50")) except: BUFFER = 50 DOWNLOAD_LIMIT = config.get_setting("mct_download_limit", server="torrent", default="") if DOWNLOAD_LIMIT: try: DOWNLOAD_LIMIT = int(DOWNLOAD_LIMIT) except: DOWNLOAD_LIMIT = 0 else: DOWNLOAD_LIMIT = 0 UPLOAD_LIMIT = 100 torr_client = 'BT' rar_file = '' rar_names = [] rar = False rar_res = False bkg_user = False video_names = [] video_file = '' video_path = '' videourl = '' msg_header = 'Alfa %s Cliente Torrent' % torr_client extensions_list = ['.aaf', '.3gp', '.asf', '.avi', '.flv', '.mpeg', '.m1v', '.m2v', '.m4v', '.mkv', '.mov', '.mpg', '.mpe', '.mp4', '.ogg', '.rar', '.wmv', '.zip'] for entry in rar_files: for file, path in entry.items(): if file == 'path' and '.rar' in str(path): for file_r in path: rar_names += [file_r] rar = True if RAR and BACKGROUND: bkg_user = True elif file == 'path' and not '.rar' in str(path): for file_r in path: if os.path.splitext(file_r)[1] in extensions_list: video_names += [file_r] elif file == '__name': video_path = path if rar: rar_file = '%s/%s' % (video_path, rar_names[0]) erase_file_path = filetools.join(save_path_videos, video_path) video_path = erase_file_path if video_names: video_file = video_names[0] if not video_file and mediaurl.startswith('magnet'): video_file = urllib.unquote_plus(scrapertools.find_single_match(mediaurl, '(?:\&|&)dn=([^\&]+)\&')) erase_file_path = filetools.join(save_path_videos, video_file) if rar and RAR and not UNRAR: if not platformtools.dialog_yesno(msg_header, 'Se ha detectado un archivo .RAR en la descarga', \ 'No tiene instalado el extractor UnRAR', '¿Desea descargarlo en cualquier caso?'): return # Iniciamos el cliente: c = Client(url=mediaurl, is_playing_fnc=xbmc_player.isPlaying, wait_time=None, auto_shutdown=False, timeout=10, temp_path=save_path_videos, print_status=debug, auto_delete=False) activo = True finalizado = False dp_cerrado = True # Mostramos el progreso if rar and RAR and BACKGROUND: # Si se descarga un RAR... progreso = platformtools.dialog_progress_bg(msg_header) platformtools.dialog_notification("Descarga de RAR en curso", "Puedes realizar otras tareas en Kodi mientrastanto. " + \ "Te informaremos...", time=10000) else: progreso = platformtools.dialog_progress('Alfa %s Cliente Torrent' % torr_client, '') dp_cerrado = False # Mientras el progreso no sea cancelado ni el cliente cerrado while not c.closed and not xbmc.abortRequested: # Obtenemos el estado del torrent s = c.status if debug: # Montamos las tres lineas con la info del torrent txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d) | DHT:%s (%d) | Trakers: %d | Pi: %d(%d)' % \ (s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete, s.dht_state, s.dht_nodes, s.trackers, s.pieces_sum, s.pieces_len) txt3 = 'Origen Peers TRK: %d DHT: %d PEX: %d LSD %d ' % \ (s.trk_peers, s.dht_peers, s.pex_peers, s.lsd_peers) else: txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d) | DHT:%s (%d) | Trakers: %d | Pi: %d(%d)' % \ (s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete, s.dht_state, s.dht_nodes, s.trackers, s.pieces_sum, s.pieces_len) txt3 = video_file if rar and RAR and BACKGROUND or bkg_user: progreso.update(s.buffer, txt, txt2) else: progreso.update(s.buffer, txt, txt2, txt3) time.sleep(1) if (not bkg_user and progreso.iscanceled()) and (not (rar and RAR and BACKGROUND) and progreso.iscanceled()): if not dp_cerrado: progreso.close() dp_cerrado = True if 'Finalizado' in s.str_state or 'Seeding' in s.str_state: """ if not rar and platformtools.dialog_yesno(msg_header, config.get_localized_string(70198)): played = False dp_cerrado = False progreso = platformtools.dialog_progress(msg_header, '') progreso.update(s.buffer, txt, txt2, txt3) else: """ dp_cerrado = False progreso = platformtools.dialog_progress(msg_header, '') break else: if platformtools.dialog_yesno(msg_header, "¿Borramos los archivo descargados? (incompletos)", "Selecciona NO para seguir descargando en segundo plano"): dp_cerrado = False progreso = platformtools.dialog_progress(msg_header, '') break else: bkg_user = True if not dp_cerrado: progreso.close() dp_cerrado = False progreso = platformtools.dialog_progress_bg(msg_header) progreso.update(s.buffer, txt, txt2) if not c.closed: c.set_speed_limits(DOWNLOAD_LIMIT, UPLOAD_LIMIT) # Bajamos la velocidad en background # Si el buffer se ha llenado y la reproduccion no ha sido iniciada, se inicia if ((s.pieces_sum >= BUFFER or 'Finalizado' in s.str_state or 'Seeding' in s.str_state) and not rar and not bkg_user) or \ (s.pieces_sum >= s.pieces_len - 3 and s.pieces_len > 0 and ('Finalizado' in s.str_state or 'Seeding' \ in s.str_state) and (rar or bkg_user)) and not played: if rar and RAR and UNRAR: c.stop() activo = False finalizado = True bkg_user = False dp_cerrado = False video_file, rar_res, video_path, erase_file_path = extract_files(rar_file, \ save_path_videos, password, progreso, item, torr_client) # ... extraemos el vídeo del RAR if rar_res and not xbmc.abortRequested: time.sleep(1) else: break elif (rar and not UNRAR) or (rar and not RAR): break elif bkg_user: finalizado = True break # Cerramos el progreso if not dp_cerrado: progreso.close() dp_cerrado = True # Reproducimos el vídeo extraido, si no hay nada en reproducción if not c.closed: c.set_speed_limits(DOWNLOAD_LIMIT, UPLOAD_LIMIT) # Bajamos la velocidad en background bkg_auto = True while xbmc_player.isPlaying() and not xbmc.abortRequested: time.sleep(3) # Obtenemos el playlist del torrent #videourl = c.get_play_list() if not rar_res: # Es un Magnet ? video_file = filetools.join(save_path_videos, s.file_name) if erase_file_path == save_path_videos: erase_file_path = video_file videourl = video_file else: videourl = filetools.join(video_path, video_file) # Iniciamos el reproductor playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() playlist.add(videourl, xlistitem) # xbmc_player = xbmc_player log("##### videourl: %s" % videourl) xbmc_player.play(playlist) # Marcamos como reproducido para que no se vuelva a iniciar played = True mark_auto_as_watched(item) # Y esperamos a que el reproductor se cierre bkg_auto = True dp_cerrado = True while xbmc_player.isPlaying() and not xbmc.abortRequested: time.sleep(1) if xbmc.getCondVisibility('Player.Playing'): if not dp_cerrado: dp_cerrado = True progreso.close() if xbmc.getCondVisibility('Player.Paused') and not rar_res: if not c.closed: s = c.status txt = '%.2f%% de %.1fMB %s | %.1f kB/s' % \ (s.progress_file, s.file_size, s.str_state, s._download_rate) txt2 = 'S: %d(%d) P: %d(%d) | DHT:%s (%d) | Trakers: %d | Pi: %d(%d)' % \ (s.num_seeds, s.num_complete, s.num_peers, s.num_incomplete, s.dht_state, s.dht_nodes, s.trackers, s.pieces_sum, s.pieces_len) txt3 = video_file[:99] if dp_cerrado: dp_cerrado = False progreso = xbmcgui.DialogProgressBG() progreso.create(msg_header) progreso.update(s.buffer, msg_header, '[CR][CR]' + txt + '[CR]' + txt2) if not dp_cerrado: dp_cerrado = True progreso.close() # Miramos si se ha completado la descarga para borrar o no los archivos if activo: s = c.status if s.pieces_sum == s.pieces_len: finalizado = True break if platformtools.dialog_yesno(msg_header, "¿Borramos los archivo descargados? (incompletos)", "Selecciona NO para seguir descargando en segundo plano"): progreso = platformtools.dialog_progress(msg_header, '') dp_cerrado = False break else: bkg_user = True played = False if not dp_cerrado: progreso.close() progreso = platformtools.dialog_progress_bg(msg_header) progreso.update(s.buffer, txt, txt2) dp_cerrado = False continue # Cuando este cerrado, Volvemos a mostrar el dialogo if not (rar and bkg_user): progreso = platformtools.dialog_progress(msg_header, '') progreso.update(s.buffer, txt, txt2, txt3) dp_cerrado = False break if not dp_cerrado: if rar or bkg_user: progreso.update(100, config.get_localized_string(70200), " ") else: progreso.update(100, config.get_localized_string(70200), " ", " ") # Detenemos el cliente if activo and not c.closed: c.stop() activo = False # Cerramos el progreso if not dp_cerrado: progreso.close() dp_cerrado = True # Y borramos los archivos de descarga restantes time.sleep(1) if filetools.exists(erase_file_path) and not bkg_user: if finalizado and not platformtools.dialog_yesno(msg_header, '¿Borrarmos los archivos descargados? (completos)'): return log("##### erase_file_path: %s" % erase_file_path) for x in range(10): if filetools.isdir(erase_file_path): if erase_file_path != save_path_videos: filetools.rmdirtree(erase_file_path) else: break else: filetools.remove(erase_file_path) time.sleep(5) if not filetools.exists(erase_file_path): break