def download_url(url,titulo,server): url = url.replace("\\","") print "Analizando enlace "+url # Averigua el servidor if server=="": itemlist = servertools.find_video_items(data=url) if len(itemlist)==0: print "No se puede identificar el enlace" return item = itemlist[0] print "Es un enlace en "+item.server else: item = Item() item.server = server # Obtiene las URL de descarga video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing(item.server,url) if len(video_urls)==0: print "No se ha encontrado nada para descargar" return # Descarga el de mejor calidad, como hace pelisalacarta print "Descargando..." print video_urls devuelve = downloadtools.downloadbest(video_urls,titulo,continuar=True)
def download_from_server(item): unsupported_servers = ["torrent"] progreso = platformtools.dialog_progress("Descargas", "Probando con: %s" % item.server) channel = __import__('channels.%s' % item.contentChannel, None, None, ["channels.%s" % item.contentChannel]) if hasattr(channel, "play"): progreso.update(50, "Probando con: %s" % item.server, "Conectando con %s..." % item.contentChannel) try: itemlist = getattr(channel, "play")(item.clone(channel=item.contentChannel, action=item.contentAction)) except: logger.error("Error en el canal %s" % item.contentChannel) else: if len(itemlist): download_item = item.clone(**itemlist[0].__dict__) download_item.contentAction = download_item.action download_item.infoLabels = item.infoLabels item = download_item else: logger.info("No hay nada que reproducir") return {"downloadStatus": STATUS_CODES.error} logger.info("contentAction: %s | contentChannel: %s | server: %s | url: %s" % (item.contentAction, item.contentChannel, item.server, item.url)) progreso.close() if not item.server or not item.url or not item.contentAction == "play" or item.server in unsupported_servers: logger.error("El Item no contiene los parametros necesarios.") return {"downloadStatus": STATUS_CODES.error} video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing(item.server, item.url, item.password, True) # Si no esta disponible, salimos if not puedes: logger.info("El vídeo **NO** está disponible") return {"downloadStatus": STATUS_CODES.error} else: logger.info("El vídeo **SI** está disponible") result = {} # Recorre todas las opciones hasta que consiga descargar una correctamente for video_url in reversed(video_urls): result = download_from_url(video_url[1], item) if result["downloadStatus"] in [STATUS_CODES.canceled, STATUS_CODES.completed]: break # Error en la descarga, continuamos con la siguiente opcion if result["downloadStatus"] == STATUS_CODES.error: continue # Devolvemos el estado return result
def _parse_gplus(html): sources = [] match = re.search('<c-wiz.+?track:impression,click".*?jsdata\s*=\s*".*?(http[^"]+)"', html, re.DOTALL) if match: source = match.group(1).replace('&', '&').split(';')[0] resolved = servertools.findvideos(data=source, skip=True) if resolved: resolved, ok, msg = servertools.resolve_video_urls_for_playing(url=resolved[0][1], server=resolved[0][2]) if ok: sources.append(['Unknown Quality', resolved[0][1]]) return sources
def play_menu(item): if item.server == "": item.server = "directo" if item.video_urls: video_urls, puedes, motivo = item.video_urls, True, "" else: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, True) if not "strmfile" in item: item.strmfile = False #TODO: unificar show y Serie ya que se usan indistintamente. if not "Serie" in item: item.Serie = item.show if item.server == "": item.server = "directo" opciones = check_video_options(item, video_urls) if not puedes: if item.server != "directo": motivo = motivo.replace("<br/>", "\n") platformtools.dialog_ok("No puedes ver ese vídeo porque...", motivo + "\n" + item.url) else: platformtools.dialog_ok( "No puedes ver ese vídeo porque...", "El servidor donde está alojado no está\nsoportado en pelisalacarta todavía\n" + item.url) if len(opciones) == 0: return default_action = config.get_setting("default_action") logger.info("default_action=%s" % (default_action)) # Si la accion por defecto es "Preguntar", pregunta if default_action == 0: seleccion = platformtools.dialog_select( config.get_localized_string(30163), [opcion.option for opcion in opciones]) elif default_action == 1: seleccion = 0 elif default_action == 2: seleccion = len(video_urls) - 1 elif default_action == 3: seleccion = seleccion else: seleccion = 0 if seleccion > -1: logger.info("seleccion=%d" % seleccion) logger.info("seleccion=%s" % opciones[seleccion].option) selecteditem = opciones[seleccion] del selecteditem.option run(opciones[seleccion]) return
def _parse_gplus(html): sources = [] match = re.search('<c-wiz.+?track:impression,click".*?jsdata\s*=\s*".*?(http[^"]+)"', html, re.DOTALL) if match: source = match.group(1).replace('&', '&').split(';')[0] resolved = servertools.findvideos(data=source, skip=True) if resolved: resolved, ok, msg = servertools.resolve_video_urls_for_playing(url=resolved[0][1], server=resolved[0][2]) if ok: sources.append(['Unknown Quality', resolved[0][1]]) return sources
def download_video(item, parent_item): logger.info(item) logger.info(parent_item) if item.video_urls: video_urls, puedes, motivo = item.video_urls, True, "" else: from core import servertools url_referer = item.url_referer if item.url_referer else parent_item.url video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, url_referer=url_referer) if not puedes: platformtools.dialog_ok("No puedes descargar este vídeo porque...", motivo, item.url) return False opciones = [] for video_url in video_urls: opciones.append("Descargar " + video_url[0]) # Si hay varias opciones dar a elegir, si sólo hay una reproducir directamente if len(opciones) > 1: seleccion = platformtools.dialog_select("Elige una opción", opciones) else: seleccion = 0 if seleccion == -1: return True else: mediaurl, view, mpd = platformtools.get_video_seleccionado( item, seleccion, video_urls) if mediaurl == '': platformtools.dialog_ok(config.__addon_name, 'No se encuentra el vídeo!') return False if mediaurl.endswith( '.m3u8') or 'm3u8' in video_urls[seleccion][0].lower(): platformtools.dialog_ok(config.__addon_name, 'No se puede descargar en formato m3u8') return False if parent_item.contentType == 'movie': file_name = '%s' % parent_item.contentTitle # config.text_clean(...) else: file_name = '%s - S%02dE%02d' % (parent_item.contentSerieName, parent_item.contentSeason, parent_item.contentEpisodeNumber) ch_name = parent_item.channel if parent_item.channel != 'tracking' else item.channel file_name += ' [%s][%s]' % (ch_name, item.server) return do_download(mediaurl, file_name, parent_item, item)
def play_menu(item): if item.server=="": item.server="directo" if item.video_urls: video_urls,puedes,motivo = item.video_urls, True, "" else: video_urls,puedes,motivo = servertools.resolve_video_urls_for_playing(item.server,item.url,item.password,True) if not "strmfile" in item: item.strmfile=False #TODO: unificar show y Serie ya que se usan indistintamente. if not "Serie" in item: item.Serie = item.show if item.server=="": item.server="directo" opciones = check_video_options(item, video_urls) if not puedes: if item.server!="directo": motivo = motivo.replace("<br/>", "\n") platformtools.dialog_ok("No puedes ver ese vídeo porque...",motivo+"\n"+item.url) else: platformtools.dialog_ok("No puedes ver ese vídeo porque...","El servidor donde está alojado no está\nsoportado en pelisalacarta todavía\n"+item.url) if len(opciones)==0: return default_action = config.get_setting("default_action") logger.info("default_action="+default_action) # Si la accion por defecto es "Preguntar", pregunta if default_action=="0": seleccion = platformtools.dialog_select(config.get_localized_string(30163), [opcion.option for opcion in opciones]) elif default_action=="1": seleccion = 0 elif default_action=="2": seleccion = len(video_urls)-1 elif default_action=="3": seleccion = seleccion else: seleccion=0 if seleccion > -1: logger.info("seleccion=%d" % seleccion) logger.info("seleccion=%s" % opciones[seleccion].option) selecteditem = opciones[seleccion] del selecteditem.option run(opciones[seleccion]) return
def onAction(self, action): global window_select, result if action == 92 or action == 110: self.result = "no_video" result = "no_video" self.close() window_select.pop() if not window_select: if not self.item.windowed: del window_select else: window_select[-1].doModal() try: if (action == 7 or action == 100) and self.getFocusId() == 6: selectitem = self.control_list.getSelectedItem() item = Item().fromurl(selectitem.getProperty("item_copy")) if item.action == "play" and self.item.windowed: video_urls, puede, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url) self.close() xbmc.sleep(200) if puede: result = video_urls[-1][1] self.result = video_urls[-1][1] else: result = None self.result = None elif item.action == "play" and not self.item.windowed: for window in window_select: window.close() retorna = platformtools.play_video(item, force_direct=True) if not retorna: while True: xbmc.sleep(1000) if not xbmc.Player().isPlaying(): break window_select[-1].doModal() else: self.close() buscartrailer(item) except: import traceback logger.error(traceback.format_exc())
def onAction(self,action): global window_select, result if action == 92 or action == 110: self.result = "no_video" result = "no_video" self.close() window_select.pop() if not window_select: if not self.item.windowed: del window_select else: window_select[-1].doModal() try: if (action == 7 or action == 100) and self.getFocusId() == 6: selectitem = self.control_list.getSelectedItem() item = Item().fromurl(selectitem.getProperty("item_copy")) if item.action == "play" and self.item.windowed: video_urls, puede, motivo = servertools.resolve_video_urls_for_playing(item.server, item.url) self.close() xbmc.sleep(200) if puede: result = video_urls[-1][1] self.result = video_urls[-1][1] else: result = None self.result = None elif item.action == "play" and not self.item.windowed: for window in window_select: window.close() retorna = platformtools.play_video(item) if not retorna: while True: xbmc.sleep(1000) if not xbmc.Player().isPlaying(): break window_select[-1].doModal() else: self.close() buscartrailer(item) except: import traceback logger.info(traceback.format_exc())
def download_from_server(item): logger.info("pelisalacarta.channels.descargas download_from_server") if item.server == "torrent": # De momento las descargas torrents no estan permitidas, ya que funcionan de forma diferente puedes = False else: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, True) # Si no esta disponible, salimos if not puedes: logger.info( "pelisalacarta.channels.descargas get_video_urls_from_item: EL VIDEO NO ESTA DISPONIBLE" ) return {"downloadStatus": 3} else: logger.info( "pelisalacarta.channels.descargas download_video - EL VIDEO SI ESTA DISPONIBLE" ) result = {"downloadStatus": 3} # Recorre todas las opciones hasta que consiga descargar una correctamente for video_url in reversed(video_urls): result = download_from_url(video_url[1], item) # Descarga cancelada, no probamos mas if result["downloadStatus"] == 1: break # Descarga completada, no probamos mas if result["downloadStatus"] == 2: break # Error en la descarga, continuamos con la siguiente opcion if result["downloadStatus"] == 3: continue # Devolvemos el estado return result
def download_from_server(item): logger.info("pelisalacarta.channels.descargas download_from_server") if item.server == "torrent": # De momento las descargas torrents no estan permitidas, ya que funcionan de forma diferente puedes = False else: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing(item.server, item.url, item.password, True) # Si no esta disponible, salimos if not puedes: logger.info("pelisalacarta.channels.descargas get_video_urls_from_item: EL VIDEO NO ESTA DISPONIBLE") return {"downloadStatus": 3} else: logger.info("pelisalacarta.channels.descargas download_video - EL VIDEO SI ESTA DISPONIBLE") result = {"downloadStatus": 3} # Recorre todas las opciones hasta que consiga descargar una correctamente for video_url in reversed(video_urls): result = download_from_url(video_url[1], item) # Descarga cancelada, no probamos mas if result["downloadStatus"] == 1: break # Descarga completada, no probamos mas if result["downloadStatus"] == 2: break # Error en la descarga, continuamos con la siguiente opcion if result["downloadStatus"] == 3: continue # Devolvemos el estado return result
def descargar_lista(item, url): logger.info() from core import httptools, scrapertools if 'tinyupload.com/' in url: try: from urlparse import urlparse data = httptools.downloadpage(url).data logger.debug(data) down_url, url_name = scrapertools.find_single_match( data, ' href="(download\.php[^"]*)"><b>([^<]*)') url_json = '{uri.scheme}://{uri.netloc}/'.format( uri=urlparse(url)) + down_url except: platformtools.dialog_ok('Alfa', config.get_localized_string(70655), url) return False elif 'zippyshare.com/' in url: from core import servertools video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( 'zippyshare', url) if not puedes: platformtools.dialog_ok('Alfa', config.get_localized_string(70655), motivo) return False url_json = video_urls[0][ 1] # https://www58.zippyshare.com/d/qPzzQ0UM/25460/alfavorites-testeanding.json url_name = url_json[url_json.rfind('/') + 1:] elif 'friendpaste.com/' in url: url_json = url if url.endswith('/raw') else url + '/raw' url_name = 'friendpaste' else: url_json = url url_name = url[url.rfind('/') + 1:] # Download json data = httptools.downloadpage(url_json).data # Verificar formato json de alfavorites y añadir info de la descarga jsondata = jsontools.load(data) if 'user_favorites' not in jsondata or 'info_lista' not in jsondata: logger.debug(data) platformtools.dialog_ok('Alfa', config.get_localized_string(70656)) return False jsondata['info_lista']['downloaded_date'] = fechahora_actual() jsondata['info_lista']['downloaded_from'] = url data = jsontools.dump(jsondata) # Pedir nombre para la lista descargada nombre = get_name_from_filename(url_name) titulo = platformtools.dialog_input( default=nombre, heading=config.get_localized_string(70657)) if titulo is None or titulo == '': return False titulo = text_clean(titulo, blank_char='_') filename = get_filename_from_name(titulo) fullfilename = os.path.join(config.get_data_path(), filename) # Si el nuevo nombre ya existe pedir confirmación para sobrescribir if os.path.exists(fullfilename): if not platformtools.dialog_yesno( 'Alfa', config.get_localized_string(70613), config.get_localized_string(70658), filename): return False if not filetools.write(fullfilename, data): platformtools.dialog_ok('Alfa', config.get_localized_string(70659), filename) platformtools.dialog_ok('Alfa', config.get_localized_string(70660), filename) platformtools.itemlist_refresh() return True
def download_all_episodes(item, first_episode="", preferred_server="vidspot", filter_language=""): logger.info("show=" + item.show) channel = ImportarCanal(item) show_title = item.show # Obtiene el listado desde el que se llamó action = item.extra # Esta marca es porque el item tiene algo más aparte en el atributo "extra" if "###" in item.extra: action = item.extra.split("###")[0] item.extra = item.extra.split("###")[1] exec "episode_itemlist = channel." + action + "(item)" # Ordena los episodios para que funcione el filtro de first_episode episode_itemlist = sorted(episode_itemlist, key=lambda Item: Item.title) from core import downloadtools from core import scrapertools best_server = preferred_server worst_server = "moevideos" # Para cada episodio if first_episode == "": empezar = True else: empezar = False for episode_item in episode_itemlist: try: logger.info("episode=" + episode_item.title) episode_title = scrapertools.get_match(episode_item.title, "(\d+x\d+)") logger.info("episode=" + episode_title) except: import traceback logger.error(traceback.format_exc()) continue if first_episode != "" and episode_title == first_episode: empezar = True if episodio_ya_descargado(show_title, episode_title): continue if not empezar: continue # Extrae los mirrors try: mirrors_itemlist = channel.findvideos(episode_item) except: mirrors_itemlist = servertools.find_video_items(episode_item) print mirrors_itemlist descargado = False new_mirror_itemlist_1 = [] new_mirror_itemlist_2 = [] new_mirror_itemlist_3 = [] new_mirror_itemlist_4 = [] new_mirror_itemlist_5 = [] new_mirror_itemlist_6 = [] for mirror_item in mirrors_itemlist: # Si está en español va al principio, si no va al final if "(Español)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_1.append(mirror_item) else: new_mirror_itemlist_2.append(mirror_item) elif "(Latino)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_3.append(mirror_item) else: new_mirror_itemlist_4.append(mirror_item) elif "(VOS)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_3.append(mirror_item) else: new_mirror_itemlist_4.append(mirror_item) else: if best_server in mirror_item.title.lower(): new_mirror_itemlist_5.append(mirror_item) else: new_mirror_itemlist_6.append(mirror_item) mirrors_itemlist = new_mirror_itemlist_1 + new_mirror_itemlist_2 + new_mirror_itemlist_3 + new_mirror_itemlist_4 + new_mirror_itemlist_5 + new_mirror_itemlist_6 for mirror_item in mirrors_itemlist: logger.info("mirror=" + mirror_item.title) if "(Español)" in mirror_item.title: idioma = "(Español)" codigo_idioma = "es" elif "(Latino)" in mirror_item.title: idioma = "(Latino)" codigo_idioma = "lat" elif "(VOS)" in mirror_item.title: idioma = "(VOS)" codigo_idioma = "vos" elif "(VO)" in mirror_item.title: idioma = "(VO)" codigo_idioma = "vo" else: idioma = "(Desconocido)" codigo_idioma = "desconocido" logger.info("filter_language=#" + filter_language + "#, codigo_idioma=#" + codigo_idioma + "#") if filter_language == "" or (filter_language != "" and filter_language == codigo_idioma): logger.info("downloading mirror") else: logger.info("language " + codigo_idioma + " filtered, skipping") continue if hasattr(channel, 'play'): video_items = channel.play(mirror_item) else: video_items = [mirror_item] if len(video_items) > 0: video_item = video_items[0] # Comprueba que esté disponible video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( video_item.server, video_item.url, video_password="", muestra_dialogo=False) # Lo añade a la lista de descargas if puedes: logger.info("downloading mirror started...") # El vídeo de más calidad es el último mediaurl = video_urls[len(video_urls) - 1][1] devuelve = downloadtools.downloadbest( video_urls, show_title + " " + episode_title + " " + idioma + " [" + video_item.server + "]", continuar=False) if devuelve == 0: logger.info("download ok") descargado = True break elif devuelve == -1: try: platformtools.dialog_ok("plugin", "Descarga abortada") except: pass return else: logger.info("download error, try another mirror") continue else: logger.info( "downloading mirror not available... trying next") if not descargado: logger.info("EPISODIO NO DESCARGADO " + episode_title)
def get_dialogo_opciones(item, default_action, strm): logger.info("platformtools get_dialogo_opciones") #logger.debug(item.tostring('\n')) from core import servertools opciones = [] error = False try: item.server = item.server.lower() except AttributeError: item.server = "" if item.server == "": item.server = "directo" # Si no es el modo normal, no muestra el diálogo porque cuelga XBMC muestra_dialogo = (config.get_setting("player_mode") == "0" and not strm) # Extrae las URL de los vídeos, y si no puedes verlo te dice el motivo #Permitir varias calidades para server "directo" if item.video_urls: video_urls, puedes, motivo = item.video_urls, True, "" else: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, muestra_dialogo) seleccion = 0 # 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: # "Descargar" opcion = config.get_localized_string(30153) opciones.append(opcion) if item.isFavourite: # "Quitar de favoritos" opciones.append(config.get_localized_string(30154)) else: # "Añadir a favoritos" opciones.append(config.get_localized_string(30155)) if not strm and item.contentType == 'movie': # "Añadir a Biblioteca" opciones.append(config.get_localized_string(30161)) if config.get_setting("jdownloader_enabled") == "true": # "Enviar a JDownloader" opciones.append(config.get_localized_string(30158)) if default_action == "3": seleccion = len(opciones) - 1 # Busqueda de trailers en youtube if item.channel not in ["Trailer", "ecarteleratrailers"]: # "Buscar Trailer" opciones.append(config.get_localized_string(30162)) # Si no puedes ver el vídeo te informa else: if item.server != "": if "<br/>" in motivo: dialog_ok("No puedes ver ese vídeo porque...", motivo.split("<br/>")[0], motivo.split("<br/>")[1], item.url) else: dialog_ok("No puedes ver ese vídeo porque...", motivo, item.url) else: dialog_ok("No puedes ver ese vídeo porque...", "El servidor donde está alojado no está", "soportado en pelisalacarta todavía", item.url) if item.channel == "favoritos": # "Quitar de favoritos" opciones.append(config.get_localized_string(30154)) if len(opciones) == 0: error = True return opciones, video_urls, seleccion, error
def download_all_episodes(item,first_episode="",preferred_server="vidspot",filter_language=""): logger.info("pelisalacarta.platformcode.launcher download_all_episodes, show="+item.show) channel = ImportarCanal(item) show_title = item.show # Obtiene el listado desde el que se llamó action = item.extra # Esta marca es porque el item tiene algo más aparte en el atributo "extra" if "###" in item.extra: action = item.extra.split("###")[0] item.extra = item.extra.split("###")[1] exec "episode_itemlist = channel."+action+"(item)" # Ordena los episodios para que funcione el filtro de first_episode episode_itemlist = sorted(episode_itemlist, key=lambda Item: Item.title) from core import downloadtools from core import scrapertools best_server = preferred_server worst_server = "moevideos" # Para cada episodio if first_episode=="": empezar = True else: empezar = False for episode_item in episode_itemlist: try: logger.info("pelisalacarta.platformcode.launcher download_all_episodes, episode="+episode_item.title) episode_title = scrapertools.get_match(episode_item.title,"(\d+x\d+)") logger.info("pelisalacarta.platformcode.launcher download_all_episodes, episode="+episode_title) except: import traceback logger.info(traceback.format_exc()) continue if first_episode!="" and episode_title==first_episode: empezar = True if episodio_ya_descargado(show_title,episode_title): continue if not empezar: continue # Extrae los mirrors try: mirrors_itemlist = channel.findvideos(episode_item) except: mirrors_itemlist = servertools.find_video_items(episode_item) print mirrors_itemlist descargado = False new_mirror_itemlist_1 = [] new_mirror_itemlist_2 = [] new_mirror_itemlist_3 = [] new_mirror_itemlist_4 = [] new_mirror_itemlist_5 = [] new_mirror_itemlist_6 = [] for mirror_item in mirrors_itemlist: # Si está en español va al principio, si no va al final if "(Español)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_1.append(mirror_item) else: new_mirror_itemlist_2.append(mirror_item) elif "(Latino)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_3.append(mirror_item) else: new_mirror_itemlist_4.append(mirror_item) elif "(VOS)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_3.append(mirror_item) else: new_mirror_itemlist_4.append(mirror_item) else: if best_server in mirror_item.title.lower(): new_mirror_itemlist_5.append(mirror_item) else: new_mirror_itemlist_6.append(mirror_item) mirrors_itemlist = new_mirror_itemlist_1 + new_mirror_itemlist_2 + new_mirror_itemlist_3 + new_mirror_itemlist_4 + new_mirror_itemlist_5 + new_mirror_itemlist_6 for mirror_item in mirrors_itemlist: logger.info("pelisalacarta.platformcode.launcher download_all_episodes, mirror="+mirror_item.title) if "(Español)" in mirror_item.title: idioma="(Español)" codigo_idioma="es" elif "(Latino)" in mirror_item.title: idioma="(Latino)" codigo_idioma="lat" elif "(VOS)" in mirror_item.title: idioma="(VOS)" codigo_idioma="vos" elif "(VO)" in mirror_item.title: idioma="(VO)" codigo_idioma="vo" else: idioma="(Desconocido)" codigo_idioma="desconocido" logger.info("pelisalacarta.platformcode.launcher filter_language=#"+filter_language+"#, codigo_idioma=#"+codigo_idioma+"#") if filter_language=="" or (filter_language!="" and filter_language==codigo_idioma): logger.info("pelisalacarta.platformcode.launcher download_all_episodes, downloading mirror") else: logger.info("pelisalacarta.platformcode.launcher language "+codigo_idioma+" filtered, skipping") continue if hasattr(channel, 'play'): video_items = channel.play(mirror_item) else: video_items = [mirror_item] if len(video_items)>0: video_item = video_items[0] # Comprueba que esté disponible video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( video_item.server , video_item.url , video_password="" , muestra_dialogo=False) # Lo añade a la lista de descargas if puedes: logger.info("pelisalacarta.platformcode.launcher download_all_episodes, downloading mirror started...") # El vídeo de más calidad es el último mediaurl = video_urls[len(video_urls)-1][1] devuelve = downloadtools.downloadbest(video_urls,show_title+" "+episode_title+" "+idioma+" ["+video_item.server+"]",continuar=False) if devuelve==0: logger.info("pelisalacarta.platformcode.launcher download_all_episodes, download ok") descargado = True break elif devuelve==-1: try: platformtools.dialog_ok("plugin" , "Descarga abortada") except: pass return else: logger.info("pelisalacarta.platformcode.launcher download_all_episodes, download error, try another mirror") continue else: logger.info("pelisalacarta.platformcode.launcher download_all_episodes, downloading mirror not available... trying next") if not descargado: logger.info("pelisalacarta.platformcode.launcher download_all_episodes, EPISODIO NO DESCARGADO "+episode_title)
def download_from_server(item): unsupported_servers = ["torrent"] progreso = platformtools.dialog_progress("Descargas", "Probando con: %s" % item.server) channel = __import__('channels.%s' % item.contentChannel, None, None, ["channels.%s" % item.contentChannel]) if hasattr(channel, "play") and not item.play_menu: progreso.update(50, "Probando con: %s" % item.server, "Conectando con %s..." % item.contentChannel) try: itemlist = getattr(channel, "play")(item.clone(channel=item.contentChannel, action=item.contentAction)) except: logger.error("Error en el canal %s" % item.contentChannel) else: if len(itemlist): download_item = item.clone(**itemlist[0].__dict__) download_item.contentAction = download_item.action download_item.infoLabels = item.infoLabels item = download_item else: logger.info("No hay nada que reproducir") return {"downloadStatus": STATUS_CODES.error} logger.info( "contentAction: %s | contentChannel: %s | server: %s | url: %s" % (item.contentAction, item.contentChannel, item.server, item.url)) progreso.close() if not item.server or not item.url or not item.contentAction == "play" or item.server in unsupported_servers: logger.error("El Item no contiene los parametros necesarios.") return {"downloadStatus": STATUS_CODES.error} video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, True) # Si no esta disponible, salimos if not puedes: logger.info("El vídeo **NO** está disponible") return {"downloadStatus": STATUS_CODES.error} else: logger.info("El vídeo **SI** está disponible") result = {} # Recorre todas las opciones hasta que consiga descargar una correctamente for video_url in reversed(video_urls): result = download_from_url(video_url[1], item) if result["downloadStatus"] in [ STATUS_CODES.canceled, STATUS_CODES.completed ]: break # Error en la descarga, continuamos con la siguiente opcion if result["downloadStatus"] == STATUS_CODES.error: continue # Devolvemos el estado return result
def get_dialogo_opciones(item, default_action, strm): logger.info() # logger.debug(item.tostring('\n')) from core import servertools opciones = [] error = False try: item.server = item.server.lower() except AttributeError: item.server = "" if item.server == "": item.server = "directo" # Si no es el modo normal, no muestra el diálogo porque cuelga XBMC muestra_dialogo = (config.get_setting("player_mode") == 0 and not strm) # Extrae las URL de los vídeos, y si no puedes verlo te dice el motivo # Permitir varias calidades para server "directo" if item.video_urls: video_urls, puedes, motivo = item.video_urls, True, "" else: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, muestra_dialogo) seleccion = 0 # 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: # "Descargar" opcion = config.get_localized_string(30153) opciones.append(opcion) if item.isFavourite: # "Quitar de favoritos" opciones.append(config.get_localized_string(30154)) else: # "Añadir a favoritos" opciones.append(config.get_localized_string(30155)) if not strm and item.contentType == 'movie': # "Añadir a Biblioteca" opciones.append(config.get_localized_string(30161)) if config.get_setting("jdownloader_enabled") == True: # "Enviar a JDownloader" opciones.append(config.get_localized_string(30158)) if default_action == "3": seleccion = len(opciones) - 1 # Si no puedes ver el vídeo te informa else: if item.server != "": if "<br/>" in motivo: dialog_ok("You can not see that video because...", motivo.split("<br/>")[0], motivo.split("<br/>")[1], item.url) else: dialog_ok("You can not see that video because...", motivo, item.url) else: dialog_ok("You can not see that video because...", "The server where it is hosted is not", "supported in dss yet", item.url) if item.channel == "favoritos": # "Quitar de favoritos" opciones.append(config.get_localized_string(30154)) if len(opciones) == 0: error = True return opciones, video_urls, seleccion, error
def download_all_episodes(item, channel, first_episode="", preferred_server="vidspot", filter_language=""): logger.info("show= " + item.show) show_title = item.show # Gets the listing from which it was called action = item.extra # This mark is because the item has something else apart in the "extra" attribute if "###" in item.extra: action = item.extra.split("###")[0] item.extra = item.extra.split("###")[1] episode_itemlist = getattr(channel, action)(item) # Sort episodes for the first_episode filter to work episode_itemlist = sorted(episode_itemlist, key=lambda it: it.title) from core import servertools from core import scrapertools best_server = preferred_server # worst_server = "moevideos" # For each episode if first_episode == "": empezar = True else: empezar = False for episode_item in episode_itemlist: try: logger.info("episode= " + episode_item.title) episode_title = scrapertools.find_single_match(episode_item.title, r"(\d+x\d+)") logger.info("episode= " + episode_title) except: import traceback logger.error(traceback.format_exc()) continue if first_episode != "" and episode_title == first_episode: empezar = True if episodio_ya_descargado(show_title, episode_title): continue if not empezar: continue # Extract the mirrors try: mirrors_itemlist = channel.findvideos(episode_item) except: mirrors_itemlist = servertools.find_video_items(episode_item) print(mirrors_itemlist) descargado = False new_mirror_itemlist_1 = [] new_mirror_itemlist_2 = [] new_mirror_itemlist_3 = [] new_mirror_itemlist_4 = [] new_mirror_itemlist_5 = [] new_mirror_itemlist_6 = [] for mirror_item in mirrors_itemlist: # If it is in Spanish it goes to the beginning, if it does not go to the end if "(Italiano)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_1.append(mirror_item) else: new_mirror_itemlist_2.append(mirror_item) if "(Español)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_1.append(mirror_item) else: new_mirror_itemlist_2.append(mirror_item) elif "(Latino)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_3.append(mirror_item) else: new_mirror_itemlist_4.append(mirror_item) elif "(VOS)" in mirror_item.title: if best_server in mirror_item.title.lower(): new_mirror_itemlist_3.append(mirror_item) else: new_mirror_itemlist_4.append(mirror_item) else: if best_server in mirror_item.title.lower(): new_mirror_itemlist_5.append(mirror_item) else: new_mirror_itemlist_6.append(mirror_item) mirrors_itemlist = (new_mirror_itemlist_1 + new_mirror_itemlist_2 + new_mirror_itemlist_3 + new_mirror_itemlist_4 + new_mirror_itemlist_5 + new_mirror_itemlist_6) for mirror_item in mirrors_itemlist: logger.info("mirror= " + mirror_item.title) if "(Italiano)" in mirror_item.title: idioma = "(Italiano)" codigo_idioma = "it" if "(Español)" in mirror_item.title: idioma = "(Español)" codigo_idioma = "es" elif "(Latino)" in mirror_item.title: idioma = "(Latino)" codigo_idioma = "lat" elif "(VOS)" in mirror_item.title: idioma = "(VOS)" codigo_idioma = "vos" elif "(VO)" in mirror_item.title: idioma = "(VO)" codigo_idioma = "vo" else: idioma = "(Desconocido)" codigo_idioma = "desconocido" logger.info("filter_language=#" + filter_language + "#, codigo_idioma=#" + codigo_idioma + "#") if filter_language == "" or (filter_language != "" and filter_language == codigo_idioma): logger.info("downloading mirror") else: logger.info("language " + codigo_idioma + " filtered, skipping") continue if hasattr(channel, 'play'): video_items = channel.play(mirror_item) else: video_items = [mirror_item] if len(video_items) > 0: video_item = video_items[0] # Check that it is available video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing(video_item.server, video_item.url, video_password="", muestra_dialogo=False) # Adds it to the download list if puedes: logger.info("downloading mirror started...") # The highest quality video is the latest # mediaurl = video_urls[len(video_urls) - 1][1] devuelve = downloadbest(video_urls, show_title + " " + episode_title + " " + idioma + " [" + video_item.server + "]", continuar=False) if devuelve == 0: logger.info("download ok") descargado = True break elif devuelve == -1: try: from platformcode import platformtools platformtools.dialog_ok("plugin", "Descarga abortada") except: pass return else: logger.info("download error, try another mirror") continue else: logger.info("downloading mirror not available... trying next") if not descargado: logger.info("UNDOWNLOADED EPISODE " + episode_title)
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 search_trailers(item): logger.info() from core.tmdb import Tmdb import xbmcgui, xbmc tipo = 'movie' if item.contentType == 'movie' else 'tv' nombre = item.contentTitle if item.contentType == 'movie' else item.contentSerieName if item.infoLabels['tmdb_id']: tmdb_search = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], tipo=tipo, idioma_busqueda='es') else: anyo = item.infoLabels['year'] if item.infoLabels['year'] else '-' tmdb_search = Tmdb(texto_buscado=nombre, tipo=tipo, year=anyo, idioma_busqueda='es') opciones = [] resultados = tmdb_search.get_videos() for res in resultados: # ~ logger.debug(res) it = xbmcgui.ListItem(res['name'], '[%sp] (%s)' % (res['size'], res['language'])) if item.thumbnail: it.setArt({'thumb': item.thumbnail}) opciones.append(it) if len(resultados) == 0: platformtools.dialog_ok(nombre, 'No se encuentra ningún tráiler en TMDB') else: while not xbmc.Monitor().abortRequested(): # (while True) ret = xbmcgui.Dialog().select('Tráilers para %s' % nombre, opciones, useDetails=True) if ret == -1: break platformtools.dialog_notification(resultados[ret]['name'], 'Cargando tráiler ...', time=3000, sound=False) from core import servertools if 'youtube' in resultados[ret]['url']: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( 'youtube', resultados[ret]['url']) else: video_urls = [] #TODO si no es youtube ... logger.debug(resultados[ret]) if len(video_urls) > 0: # ~ logger.debug(video_urls) xbmc.Player().play( video_urls[-1][1]) # el último es el de más calidad xbmc.sleep(1000) while not xbmc.Monitor().abortRequested() and xbmc.Player( ).isPlaying(): xbmc.sleep(1000) else: platformtools.dialog_notification( resultados[ret]['name'], 'No se puede reproducir el tráiler', time=3000, sound=False) if len(resultados) == 1: break # si sólo hay un vídeo no volver al diálogo de tráilers
def play_menu(item): if type(item) == list and len(item) == 1: item = item[0] #Modo Normal if type(item) == Item: if item.server == "": item.server = "directo" video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, True) #Modo "Play" en canal, puede devolver varias url elif type(item) == list and len(item) > 1: itemlist = item #En este caso en el argumento item, en realidad hay un itemlist item = itemlist[0] #Se asigna al item, el item primero del itemlist video_urls = [] for videoitem in itemlist: if videoitem.server == "": videoitem.server = "directo" opcion_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( videoitem.server, videoitem.url) opcion_urls[0][ 0] = opcion_urls[0][0] + " [" + videoitem.fulltitle + "]" video_urls.extend(opcion_urls) item = itemlist[0] puedes = True motivo = "" if not "strmfile" in item: item.strmfile = False #TODO: unificar show y Serie ya que se usan indistintamente. if not "Serie" in item: item.Serie = item.show if item.server == "": item.server = "directo" opciones = check_video_options(item, video_urls) if not puedes: if item.server != "directo": motivo = motivo.replace("<br/>", "\n") platformtools.dialog_ok("No puedes ver ese vídeo porque...", motivo + "\n" + item.url) else: platformtools.dialog_ok( "No puedes ver ese vídeo porque...", "El servidor donde está alojado no está\nsoportado en pelisalacarta todavía\n" + item.url) if len(opciones) == 0: return default_action = config.get_setting("default_action") logger.info("default_action=" + default_action) # Si la accion por defecto es "Preguntar", pregunta if default_action == "0": seleccion = platformtools.dialog_select( config.get_localized_string(30163), [opcion.option for opcion in opciones]) elif default_action == "1": seleccion = 0 elif default_action == "2": seleccion = len(video_urls) - 1 elif default_action == "3": seleccion = seleccion else: seleccion = 0 if seleccion > -1: logger.info("seleccion=%d" % seleccion) logger.info("seleccion=%s" % opciones[seleccion].option) selecteditem = opciones[seleccion] del selecteditem.option run(opciones[seleccion]) return
def play_menu(item): if type(item) ==list and len(item)==1: item = item[0] #Modo Normal if type(item) == Item: if item.server=="": item.server="directo" video_urls,puedes,motivo = servertools.resolve_video_urls_for_playing(item.server,item.url,item.password,True) #Modo "Play" en canal, puede devolver varias url elif type(item) ==list and len(item)>1: itemlist = item #En este caso en el argumento item, en realidad hay un itemlist item = itemlist[0] #Se asigna al item, el item primero del itemlist video_urls = [] for videoitem in itemlist: if videoitem.server=="": videoitem.server="directo" opcion_urls,puedes,motivo = servertools.resolve_video_urls_for_playing(videoitem.server,videoitem.url) opcion_urls[0][0] = opcion_urls[0][0] + " [" + videoitem.fulltitle + "]" video_urls.extend(opcion_urls) item = itemlist[0] puedes = True motivo = "" if not "strmfile" in item: item.strmfile=False #TODO: unificar show y Serie ya que se usan indistintamente. if not "Serie" in item: item.Serie = item.show if item.server=="": item.server="directo" opciones = check_video_options(item, video_urls) if not puedes: if item.server!="directo": motivo = motivo.replace("<br/>", "\n") platformtools.dialog_ok("No puedes ver ese vídeo porque...",motivo+"\n"+item.url) else: platformtools.dialog_ok("No puedes ver ese vídeo porque...","El servidor donde está alojado no está\nsoportado en pelisalacarta todavía\n"+item.url) if len(opciones)==0: return default_action = config.get_setting("default_action") logger.info("default_action="+default_action) # Si la accion por defecto es "Preguntar", pregunta if default_action=="0": seleccion = platformtools.dialog_select(config.get_localized_string(30163), [opcion.option for opcion in opciones]) elif default_action=="1": seleccion = 0 elif default_action=="2": seleccion = len(video_urls)-1 elif default_action=="3": seleccion = seleccion else: seleccion=0 if seleccion > -1: logger.info("seleccion=%d" % seleccion) logger.info("seleccion=%s" % opciones[seleccion].option) selecteditem = opciones[seleccion] del selecteditem.option run(opciones[seleccion]) return
def download_from_server(item): logger.info(item.tostring()) unsupported_servers = ["torrent"] progreso = platformtools.dialog_progress( config.get_localized_string(30101), config.get_localized_string(70178) % item.server) channel = __import__('channels.%s' % item.contentChannel, None, None, ['channels.%s' % item.contentChannel]) if hasattr(channel, "play") and not item.play_menu: progreso.update( 50, config.get_localized_string(70178) % item.server, config.get_localized_string(60003) % item.contentChannel) try: itemlist = getattr(channel, "play")(item.clone(channel=item.contentChannel, action=item.contentAction)) except: logger.error("Error in the channel %s" % item.contentChannel) else: if len(itemlist) and isinstance(itemlist[0], Item): download_item = item.clone(**itemlist[0].__dict__) download_item.contentAction = download_item.action download_item.infoLabels = item.infoLabels item = download_item elif len(itemlist) and isinstance(itemlist[0], list): item.video_urls = itemlist if not item.server: item.server = "directo" else: logger.info("There is nothing to reproduce") return {"downloadStatus": STATUS_CODES.error} progreso.close() logger.info( "contentAction: %s | contentChannel: %s | server: %s | url: %s" % (item.contentAction, item.contentChannel, item.server, item.url)) if not item.server or not item.url or not item.contentAction == "play" or item.server in unsupported_servers: logger.error("The Item does not contain the necessary parameters.") return {"downloadStatus": STATUS_CODES.error} if not item.video_urls: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, True) else: video_urls, puedes, motivo = item.video_urls, True, "" # Si no esta disponible, salimos if not puedes: logger.info("The video is NOT available") return {"downloadStatus": STATUS_CODES.error} else: logger.info("YES Video is available") result = {} # Recorre todas las opciones hasta que consiga descargar una correctamente for video_url in reversed(video_urls): result = download_from_url(video_url[1], item) if result["downloadStatus"] in [ STATUS_CODES.canceled, STATUS_CODES.completed ]: break # Error en la descarga, continuamos con la siguiente opcion if result["downloadStatus"] == STATUS_CODES.error: continue # Devolvemos el estado return result
def play_video(item, parent_item, autoplay=False): logger.info(item) logger.info(parent_item) if item.video_urls: video_urls, puedes, motivo = item.video_urls, True, "" else: from core import servertools url_referer = item.url_referer if item.url_referer else parent_item.url video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, url_referer=url_referer) if not puedes: if not autoplay: dialog_ok("No puedes ver este vídeo porque...", motivo, item.url) return False if len(video_urls) == 1 and '.rar' in video_urls[0][0]: if not autoplay: dialog_ok("No puedes ver este vídeo porque...", 'Está comprimido en formato rar', item.url) return False opciones = [] for video_url in video_urls: opciones.append("Ver el vídeo" + " " + video_url[0]) # Si hay varias opciones dar a elegir, si sólo hay una reproducir directamente if len(opciones) > 1: if not autoplay: seleccion = dialog_select("Elige una opción", opciones) else: seleccion = len(opciones) - 1 # la última es la de más calidad !? else: seleccion = 0 if seleccion == -1: play_fake() return True else: mediaurl, view, mpd = get_video_seleccionado(item, seleccion, video_urls) if mediaurl == '': if not autoplay: dialog_ok(config.__addon_name, 'No se encuentra el vídeo!') return False if mpd and not is_mpd_enabled(): if not autoplay: dialog_ok( config.__addon_name, 'Para ver el formato MPD se require el addon inputstream.adaptive' ) return False if item.server == 'torrent': return play_torrent(mediaurl, parent_item) # ~ Para evitar ERROR: CCurlFile::Stat - Failed: Peer certificate cannot be authenticated with given CA certificates(60) if item.server not in ['m3u8hls', 'zembed']: if 'verifypeer=false' not in mediaurl: mediaurl += '|' if '|' not in mediaurl else '&' mediaurl += 'verifypeer=false' xlistitem = xbmcgui.ListItem(path=mediaurl) set_infolabels(xlistitem, parent_item, True) if mpd: xlistitem.setProperty('inputstreamaddon', 'inputstream.adaptive') xlistitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem) # ~ xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xlistitem) # para probar forzando como si fallara if item.subtitle: logger.info('Subtítulos: %s' % item.subtitle) xbmc.sleep(2000) xbmc.Player().setSubtitles(item.subtitle) # espera de unos segundos y comprobar si está funcionando !? # ~ return xbmc.Player().isPlaying() return True
def play_video(item,desdefavoritos=False,desdedescargados=False,desderrordescargas=False,strmfile=False): from core import servertools logger.info("pelisalacarta.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 config.get_setting("pyload_enabled")=="true": opciones.append(config.get_localized_string(30158).replace("jDownloader","pyLoad")) # "Enviar a pyLoad" 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( "No puedes ver ese vídeo porque...",motivo.split("<br/>")[0],motivo.split("<br/>")[1],item.url) else: resultado = advertencia.ok( "No puedes ver ese vídeo porque...",motivo,item.url) else: resultado = advertencia.ok( "No puedes ver ese vídeo porque...","El servidor donde está alojado no está","soportado en pelisalacarta todavía",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 = "pelisalacarta" 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" , "Descargado con éxito") elif devuelve==-1: advertencia = xbmcgui.Dialog() resultado = advertencia.ok("plugin" , "Descarga abortada") else: advertencia = xbmcgui.Dialog() resultado = advertencia.ok("plugin" , "Error en la descarga") 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" 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": 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=download_title,url=item.url,thumbnail=download_thumbnail,server=item.server,plot=download_plot,fulltitle=item.title) advertencia = xbmcgui.Dialog() resultado = advertencia.ok(config.get_localized_string(30102) , item.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 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() 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("pelisalacarta.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( "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 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( "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 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("pelisalacarta.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("pelisalacarta.platformcode.xbmctools PLAYER_CORE_AUTO") elif playersettings == "1": player_type = xbmc.PLAYER_CORE_MPLAYER logger.info("pelisalacarta.platformcode.xbmctools PLAYER_CORE_MPLAYER") elif playersettings == "2": player_type = xbmc.PLAYER_CORE_DVDPLAYER logger.info("pelisalacarta.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("pelisalacarta.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 downloadall(item): logger.info("[descargas.py] downloadall") # Lee la lista de ficheros if usingsamba: ficheros = samba.get_files(DOWNLOAD_LIST_PATH) else: ficheros = os.listdir(DOWNLOAD_LIST_PATH) logger.info("[descargas.py] numero de ficheros=%d" % len(ficheros)) # La ordena ficheros.sort() # Crea un listado con las entradas de favoritos for fichero in ficheros: # El primer video de la lista logger.info("[descargas.py] fichero=" + fichero) if fichero != "error" and fichero != ".DS_Store": # Descarga el vídeo try: # Lee el bookmark canal, titulo, thumbnail, plot, server, url, fulltitle = \ favoritos.readbookmark(fichero, DOWNLOAD_LIST_PATH) logger.info("[descargas.py] url=" + url) # Averigua la URL del vídeo video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( server, url, "", False) # La última es la de mayor calidad, lo mejor para la descarga mediaurl = video_urls[len(video_urls) - 1][1] logger.info("[descargas.py] mediaurl=" + mediaurl) # Genera el NFO nfofilepath = downloadtools.getfilefromtitle( "sample.nfo", fulltitle) outfile = open(nfofilepath, "w") outfile.write("<movie>\n") outfile.write("<title>(" + fulltitle + ")</title>\n") outfile.write("<originaltitle></originaltitle>\n") outfile.write("<rating>0.000000</rating>\n") outfile.write("<year>2009</year>\n") outfile.write("<top250>0</top250>\n") outfile.write("<votes>0</votes>\n") outfile.write("<outline></outline>\n") outfile.write("<plot>" + plot + "</plot>\n") outfile.write("<tagline></tagline>\n") outfile.write("<runtime></runtime>\n") outfile.write("<thumb></thumb>\n") outfile.write("<mpaa>Not available</mpaa>\n") outfile.write("<playcount>0</playcount>\n") outfile.write("<watched>false</watched>\n") outfile.write("<id>tt0432337</id>\n") outfile.write("<filenameandpath></filenameandpath>\n") outfile.write("<trailer></trailer>\n") outfile.write("<genre></genre>\n") outfile.write("<credits></credits>\n") outfile.write("<director></director>\n") outfile.write("<actor>\n") outfile.write("<name></name>\n") outfile.write("<role></role>\n") outfile.write("</actor>\n") outfile.write("</movie>") outfile.flush() outfile.close() logger.info("[descargas.py] Creado fichero NFO") # Descarga el thumbnail if thumbnail != "": logger.info("[descargas.py] thumbnail=" + thumbnail) thumbnailfile = downloadtools.getfilefromtitle( thumbnail, fulltitle) thumbnailfile = thumbnailfile[:-4] + ".tbn" logger.info("[descargas.py] thumbnailfile=" + thumbnailfile) try: downloadtools.downloadfile(thumbnail, thumbnailfile) logger.info("[descargas.py] Thumbnail descargado") except: logger.info( "[descargas.py] error al descargar thumbnail") for line in sys.exc_info(): logger.error("%s" % line) # Descarga el video dev = downloadtools.downloadbest(video_urls, fulltitle) if dev == -1: # El usuario ha cancelado la descarga logger.info("[descargas.py] Descarga cancelada") return elif dev == -2: # Error en la descarga, lo mueve a ERROR y continua con el siguiente logger.info("[descargas.py] ERROR EN DESCARGA DE " + fichero) if not usingsamba: origen = os.path.join(DOWNLOAD_LIST_PATH, fichero) destino = os.path.join(ERROR_PATH, fichero) import shutil shutil.move(origen, destino) else: favoritos.savebookmark(canal, titulo, url, thumbnail, server, plot, fulltitle, ERROR_PATH) favoritos.deletebookmark(fichero, DOWNLOAD_LIST_PATH) else: logger.info("[descargas.py] Video descargado") # Borra el bookmark e itera para obtener el siguiente video filepath = os.path.join(DOWNLOAD_LIST_PATH, fichero) if usingsamba: os.remove(filepath) else: favoritos.deletebookmark(fichero, DOWNLOAD_LIST_PATH) logger.info("[descargas.py] " + fichero + " borrado") except: logger.info("[descargas.py] ERROR EN DESCARGA DE " + fichero) import sys for line in sys.exc_info(): logger.error("%s" % line) if not usingsamba: origen = os.path.join(DOWNLOAD_LIST_PATH, fichero) destino = os.path.join(ERROR_PATH, fichero) import shutil shutil.move(origen, destino) else: favoritos.savebookmark(canal, titulo, url, thumbnail, server, plot, fulltitle, ERROR_PATH) favoritos.deletebookmark(fichero, DOWNLOAD_LIST_PATH)
def get_dialogo_opciones(item, default_action, strm): logger.info("platformtools get_dialogo_opciones") #logger.debug(item.tostring('\n')) from core import servertools opciones = [] error = False try: item.server = item.server.lower() except AttributeError: item.server = "" if item.server == "": item.server = "directo" # Si no es el modo normal, no muestra el diálogo porque cuelga XBMC muestra_dialogo = (config.get_setting("player_mode") == "0" and not strm) # 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) seleccion = 0 # 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: # "Descargar" opcion = config.get_localized_string(30153) opciones.append(opcion) if item.isFavourite: # "Quitar de favoritos" opciones.append(config.get_localized_string(30154)) else: # "Añadir a favoritos" opciones.append(config.get_localized_string(30155)) if not strm and item.contentType == 'movie': # "Añadir a Biblioteca" opciones.append(config.get_localized_string(30161)) if config.get_setting("jdownloader_enabled") == "true": # "Enviar a JDownloader" opciones.append(config.get_localized_string(30158)) if default_action == "3": seleccion = len(opciones) - 1 # Busqueda de trailers en youtube if item.channel not in ["Trailer", "ecarteleratrailers"]: # "Buscar Trailer" opciones.append(config.get_localized_string(30162)) # Si no puedes ver el vídeo te informa else: if item.server != "": if "<br/>" in motivo: dialog_ok("No puedes ver ese vídeo porque...", motivo.split("<br/>")[0], motivo.split("<br/>")[1], item.url) else: dialog_ok("No puedes ver ese vídeo porque...", motivo, item.url) else: dialog_ok("No puedes ver ese vídeo porque...", "El servidor donde está alojado no está", "soportado en pelisalacarta todavía", item.url) if item.channel == "favoritos": # "Quitar de favoritos" opciones.append(config.get_localized_string(30154)) if len(opciones) == 0: error = True return opciones, video_urls, seleccion, error
def get_dialogo_opciones(item, default_action, strm): logger.info() # logger.debug(item.tostring('\n')) from core import servertools opciones = [] error = False try: item.server = item.server.lower() except AttributeError: item.server = "" if item.server == "": item.server = "directo" # Si no es el modo normal, no muestra el diálogo porque cuelga XBMC muestra_dialogo = (config.get_setting("player_mode") == 0 and not strm) # Extrae las URL de los vídeos, y si no puedes verlo te dice el motivo # Permitir varias calidades para server "directo" if item.video_urls: video_urls, puedes, motivo = item.video_urls, True, "" else: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, muestra_dialogo) seleccion = 0 # 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: if item.isFavourite: # "Quitar de favoritos" opciones.append(config.get_localized_string(30154)) else: # "Añadir a favoritos" opciones.append(config.get_localized_string(30155)) if not strm and item.contentType == 'movie': # "Añadir a Biblioteca" opciones.append(config.get_localized_string(30161)) if default_action == "3": seleccion = len(opciones) - 1 # Busqueda de trailers en youtube if item.channel not in ["Trailer", "ecarteleratrailers"]: # "Buscar Trailer" opciones.append(config.get_localized_string(30162)) # Si no puedes ver el vídeo te informa else: if item.server != "": if "<br/>" in motivo: dialog_ok( "Non è possibile visualizzare questo video perché...", motivo.split("<br/>")[0], motivo.split("<br/>")[1], item.url) else: dialog_ok( "Non è possibile visualizzare questo video perché...", motivo, item.url) else: dialog_ok("Non è possibile visualizzare questo video perché...", "Il server che lo ospita non è", "ancora supportato da Stefanondemand", item.url) if item.channel == "favoritos": # "Quitar de favoritos" opciones.append(config.get_localized_string(30154)) if len(opciones) == 0: error = True return opciones, video_urls, seleccion, error
def downloadall(item): logger.info("[descargas.py] downloadall") # Lee la lista de ficheros if usingsamba: ficheros = samba.get_files(DOWNLOAD_LIST_PATH) else: ficheros = os.listdir(DOWNLOAD_LIST_PATH) logger.info("[descargas.py] numero de ficheros=%d" % len(ficheros)) # La ordena ficheros.sort() # Crea un listado con las entradas de favoritos for fichero in ficheros: # El primer video de la lista logger.info("[descargas.py] fichero="+fichero) if fichero != "error" and fichero != ".DS_Store": # Descarga el vídeo try: # Lee el bookmark canal, titulo, thumbnail, plot, server, url, fulltitle = \ favoritos.readbookmark(fichero, DOWNLOAD_LIST_PATH) logger.info("[descargas.py] url="+url) # Averigua la URL del vídeo video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing(server, url, "", False) # La última es la de mayor calidad, lo mejor para la descarga mediaurl = video_urls[len(video_urls)-1][1] logger.info("[descargas.py] mediaurl="+mediaurl) # Genera el NFO nfofilepath = downloadtools.getfilefromtitle("sample.nfo", fulltitle) outfile = open(nfofilepath, "w") outfile.write("<movie>\n") outfile.write("<title>("+fulltitle+")</title>\n") outfile.write("<originaltitle></originaltitle>\n") outfile.write("<rating>0.000000</rating>\n") outfile.write("<year>2009</year>\n") outfile.write("<top250>0</top250>\n") outfile.write("<votes>0</votes>\n") outfile.write("<outline></outline>\n") outfile.write("<plot>"+plot+"</plot>\n") outfile.write("<tagline></tagline>\n") outfile.write("<runtime></runtime>\n") outfile.write("<thumb></thumb>\n") outfile.write("<mpaa>Not available</mpaa>\n") outfile.write("<playcount>0</playcount>\n") outfile.write("<watched>false</watched>\n") outfile.write("<id>tt0432337</id>\n") outfile.write("<filenameandpath></filenameandpath>\n") outfile.write("<trailer></trailer>\n") outfile.write("<genre></genre>\n") outfile.write("<credits></credits>\n") outfile.write("<director></director>\n") outfile.write("<actor>\n") outfile.write("<name></name>\n") outfile.write("<role></role>\n") outfile.write("</actor>\n") outfile.write("</movie>") outfile.flush() outfile.close() logger.info("[descargas.py] Creado fichero NFO") # Descarga el thumbnail if thumbnail != "": logger.info("[descargas.py] thumbnail="+thumbnail) thumbnailfile = downloadtools.getfilefromtitle(thumbnail, fulltitle) thumbnailfile = thumbnailfile[:-4] + ".tbn" logger.info("[descargas.py] thumbnailfile="+thumbnailfile) try: downloadtools.downloadfile(thumbnail, thumbnailfile) logger.info("[descargas.py] Thumbnail descargado") except: logger.info("[descargas.py] error al descargar thumbnail") for line in sys.exc_info(): logger.error("%s" % line) # Descarga el video dev = downloadtools.downloadbest(video_urls, fulltitle) if dev == -1: # El usuario ha cancelado la descarga logger.info("[descargas.py] Descarga cancelada") return elif dev == -2: # Error en la descarga, lo mueve a ERROR y continua con el siguiente logger.info("[descargas.py] ERROR EN DESCARGA DE "+fichero) if not usingsamba: origen = os.path.join(DOWNLOAD_LIST_PATH, fichero) destino = os.path.join(ERROR_PATH, fichero) import shutil shutil.move(origen, destino) else: favoritos.savebookmark(canal, titulo, url, thumbnail, server, plot, fulltitle, ERROR_PATH) favoritos.deletebookmark(fichero, DOWNLOAD_LIST_PATH) else: logger.info("[descargas.py] Video descargado") # Borra el bookmark e itera para obtener el siguiente video filepath = os.path.join(DOWNLOAD_LIST_PATH, fichero) if usingsamba: os.remove(filepath) else: favoritos.deletebookmark(fichero, DOWNLOAD_LIST_PATH) logger.info("[descargas.py] "+fichero+" borrado") except: logger.info("[descargas.py] ERROR EN DESCARGA DE "+fichero) import sys for line in sys.exc_info(): logger.error("%s" % line) if not usingsamba: origen = os.path.join(DOWNLOAD_LIST_PATH, fichero) destino = os.path.join(ERROR_PATH, fichero) import shutil shutil.move(origen, destino) else: favoritos.savebookmark(canal, titulo, url, thumbnail, server, plot, fulltitle, ERROR_PATH) favoritos.deletebookmark(fichero, DOWNLOAD_LIST_PATH)
def get_dialogo_opciones(item, default_action, strm): logger.info("platformtools get_dialogo_opciones") #logger.debug(item.tostring('\n')) from core import servertools opciones = [] error = False try: item.server = item.server.lower() except AttributeError: item.server = "" if item.server == "": item.server = "directo" # Si no es el modo normal, no muestra el diálogo porque cuelga XBMC muestra_dialogo = (config.get_setting("player_mode") == "0" and not strm) # Extrae las URL de los vídeos, y si no puedes verlo te dice el motivo #Permitir varias calidades para server "directo" if item.video_urls: video_urls, puedes, motivo = item.video_urls, True, "" else: video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, item.password, muestra_dialogo) seleccion = 0 # 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 item.channel!="descargas": opciones.append(config.get_localized_string(30157)) 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": # "Enviar a JDownloader" opciones.append(config.get_localized_string(30158)) if default_action == "3": seleccion = len(opciones) - 1 # Si no puedes ver el vídeo te informa else: if item.server != "": if "<br/>" in motivo: dialog_ok("No puedes ver ese vídeo porque...", motivo.split("<br/>")[0], motivo.split("<br/>")[1], item.url) else: dialog_ok("No puedes ver ese vídeo porque...", motivo, item.url) else: dialog_ok("No puedes ver ese vídeo porque...", "El servidor donde está alojado no está", "soportado en pelisalacarta todavía", item.url) if item.channel=="favoritos": opciones.append(config.get_localized_string(30154)) # "Quitar de favoritos" if len(opciones) == 0: error = True return opciones, video_urls, seleccion, error