def download_all_episodes(item,channel=None,first_episode="", silent=False): logger.info("[launcher.py] download_all_episodes, show="+item.show+" item="+item.tostring()) item.show = item.show.replace("[COLOR yellow]","") item.show = item.show.replace("[/COLOR]","") from servers import servertools from core import downloadtools from core import scrapertools show_title = downloadtools.limpia_nombre_caracteres_especiales(item.show) # Obtiene el listado desde el que se llamó action = item.action if channel is None: exec "import channels."+item.channel+" as channel" exec "episode_itemlist = channel."+action+"(item)" best_server = "streamcloud" worst_server = "moevideos" # Para cada episodio if first_episode=="": empezar = True else: empezar = False for episode_item in episode_itemlist: # Si XBMC se está cerrando, cancela try: if xbmc.abortRequested: logger.error( "[launcher.py] download_all_episodes XBMC Abort requested" ) return -1 except: pass # Si es la opción de descargar, la de "Opciones de la serie" o la de paginación, las ignora if episode_item.action.startswith("download_all_episodes") or episode_item.action.startswith("serie_options") or episode_item.action.startswith(action): continue logger.info("[launcher.py] download_all_episodes, episode="+episode_item.title) try: episode_title = scrapertools.get_match(episode_item.title,"(\d+x\d+)") except: episode_title = episode_item.title if item.channel=="rtve": import re episode_title = re.compile("\(.*?\)",re.DOTALL).sub("",episode_title).strip() logger.info("[launcher.py] download_all_episodes, episode="+episode_title) if first_episode!="" and episode_title==first_episode: empezar = True if not empezar: continue try: # Extrae los mirrors mirrors_itemlist = [episode_item] #channel.findvideos(episode_item) 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 "(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("[launcher.py] download_all_episodes, mirror="+mirror_item.title) if "(Español)" in mirror_item.title: idioma=" (Español)" elif "(VOS)" in mirror_item.title: idioma=" (VOS)" elif "(VO)" in mirror_item.title: idioma=" (VO)" else: idioma="" logger.info("[launcher.py] download_all_episodes, downloading mirror") if hasattr(channel, 'play'): video_items = channel.play(mirror_item) else: video_items = [mirror_item] if len(video_items)>0 and not downloadtools.is_in_download_history(video_items[0].url): 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("[launcher.py] download_all_episodes, downloading mirror started...") # El vídeo de más calidad es el primero mediaurl = video_urls[0][1] if video_item.server=="descargavideos": from servers import descargavideos filetitle = show_title+" "+episode_title+idioma+" ["+descargavideos.get_real_server_name(video_item.url)+"]" elif video_item.server!="directo": filetitle = show_title+" "+episode_title+idioma+" ["+video_item.server+"]" else: filetitle = show_title+" "+episode_title+idioma+" ["+item.channel+"]" # Descarga el vídeo show_folder = os.path.join( config.get_setting("downloadpath") , show_title) if not os.path.exists(show_folder): os.mkdir(show_folder) # Genera el NFO try: nfofilepath = downloadtools.getfilefromtitle("sample.nfo",filetitle,folder=show_title) outfile = open(nfofilepath,"w") outfile.write("<movie>\n") outfile.write("<title>("+filetitle+")</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>"+episode_item.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("core.descargas Creado fichero NFO") except: logger.info("core.descargas Error al crear NFO") for line in sys.exc_info(): logger.error( "%s" % line ) # Descarga el thumbnail if episode_item.thumbnail != "": logger.info("core.descargas thumbnail="+episode_item.thumbnail) thumbnailfile = downloadtools.getfilefromtitle(episode_item.thumbnail,filetitle,folder=show_title) thumbnailfile = thumbnailfile[:-4] + ".tbn" logger.info("core.descargas thumbnailfile="+thumbnailfile) try: downloadtools.downloadfile(episode_item.thumbnail,thumbnailfile) logger.info("core.descargas Thumbnail descargado") except: logger.info("core.descargas error al descargar thumbnail") for line in sys.exc_info(): logger.error( "%s" % line ) devuelve = downloadtools.downloadbest(video_urls,filetitle,continuar=True,silent=silent,folder=show_title) if devuelve==0: logger.info("[launcher.py] download_all_episodes, download ok") descargado = True downloadtools.add_to_download_history(video_item.url,filetitle) break elif devuelve==-1: try: import xbmcgui advertencia = xbmcgui.Dialog() resultado = advertencia.ok("plugin" , "Descarga abortada") except: pass return else: logger.info("[launcher.py] download_all_episodes, download error, try another mirror") break else: logger.info("[launcher.py] download_all_episodes, downloading mirror not available... trying next") if not descargado: logger.info("[launcher.py] download_all_episodes, EPISODIO NO DESCARGADO "+episode_title) except: logger.info("core.descargas error no controlado al descargar episodio") for line in sys.exc_info(): logger.error( "%s" % line )
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 downloadall(item): logger.info("core.descargas downloadall") # Lee la lista de ficheros if usingsamba: ficheros = samba.get_files(DOWNLOAD_LIST_PATH) else: ficheros = os.listdir(DOWNLOAD_LIST_PATH) logger.info("core.descargas 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("core.descargas 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("core.descargas url="+url) # Averigua la URL del vídeo exec "from servers import "+server+" as server_connector" video_urls = server_connector.get_video_url( page_url=url , premium=(config.get_setting("megavideopremium")=="true") , user=config.get_setting("megavideouser") , password=config.get_setting("megavideopassword") ) # La primera es la de mayor calidad, lo mejor para la descarga mediaurl = video_urls[0][1] logger.info("core.descargas 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("core.descargas Creado fichero NFO") # Descarga el thumbnail if thumbnail != "": logger.info("core.descargas thumbnail="+thumbnail) thumbnailfile = downloadtools.getfilefromtitle(thumbnail,fulltitle) thumbnailfile = thumbnailfile[:-4] + ".tbn" logger.info("core.descargas thumbnailfile="+thumbnailfile) try: downloadtools.downloadfile(thumbnail,thumbnailfile) logger.info("core.descargas Thumbnail descargado") except: logger.info("core.descargas error al descargar thumbnail") for line in sys.exc_info(): logger.error( "%s" % line ) # Descarga el video dev = downloadtools.downloadtitle(mediaurl,fulltitle) if dev == -1: # El usuario ha cancelado la descarga logger.info("core.descargas Descarga cancelada") return elif dev == -2: # Error en la descarga, lo mueve a ERROR y continua con el siguiente logger.info("core.descargas 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("core.descargas 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("core.descargas "+fichero+" borrado") except: logger.info("core.descargas 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) if config.is_xbmc(): import xbmc xbmc.executebuiltin("XBMC.Container.Refresh()");
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.downloadtitle(mediaurl,fulltitle) 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 download_all_episodes(item, channel, first_episode="", silent=False): logger.info("[launcher.py] download_all_episodes, show=" + item.show + " item=" + item.tostring()) show_title = item.show # Obtiene el listado desde el que se llamó action = item.action exec "episode_itemlist = channel." + action + "(item)" from servers import servertools from core import downloadtools from core import scrapertools best_server = "streamcloud" worst_server = "moevideos" # Para cada episodio if first_episode == "": empezar = True else: empezar = False for episode_item in episode_itemlist: # Si XBMC se está cerrando, cancela try: if xbmc.abortRequested: logger.error( "[launcher.py] download_all_episodes XBMC Abort requested") return -1 except: pass # Si es la opción de descargar, la de "Opciones de la serie" o la de paginación, las ignora if episode_item.action.startswith( "download_all_episodes") or episode_item.action.startswith( "serie_options") or episode_item.action.startswith(action): continue logger.info("[launcher.py] download_all_episodes, episode=" + episode_item.title) try: episode_title = scrapertools.get_match(episode_item.title, "(\d+x\d+)") except: episode_title = episode_item.title if item.channel == "rtve": episode_title = re.compile("\(.*?\)", re.DOTALL).sub("", episode_title).strip() logger.info("[launcher.py] download_all_episodes, episode=" + episode_title) if first_episode != "" and episode_title == first_episode: empezar = True if not empezar: continue # Extrae los mirrors mirrors_itemlist = [episode_item] #channel.findvideos(episode_item) 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 "(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("[launcher.py] download_all_episodes, mirror=" + mirror_item.title) if "(Español)" in mirror_item.title: idioma = " (Español)" elif "(VOS)" in mirror_item.title: idioma = " (VOS)" elif "(VO)" in mirror_item.title: idioma = " (VO)" else: idioma = "" logger.info( "[launcher.py] download_all_episodes, downloading mirror") 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( "[launcher.py] download_all_episodes, downloading mirror started..." ) # El vídeo de más calidad es el último mediaurl = video_urls[len(video_urls) - 1][1] if video_item.server != "directo": filetitle = show_title + " " + episode_title + idioma + " [" + video_item.server + "]" else: filetitle = show_title + " " + episode_title + idioma + " [" + item.channel + "]" # Genera el NFO nfofilepath = downloadtools.getfilefromtitle( "sample.nfo", filetitle) outfile = open(nfofilepath, "w") outfile.write("<movie>\n") outfile.write("<title>(" + filetitle + ")</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>" + episode_item.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("core.descargas Creado fichero NFO") # Descarga el thumbnail if episode_item.thumbnail != "": logger.info("core.descargas thumbnail=" + episode_item.thumbnail) thumbnailfile = downloadtools.getfilefromtitle( episode_item.thumbnail, filetitle) thumbnailfile = thumbnailfile[:-4] + ".tbn" logger.info("core.descargas thumbnailfile=" + thumbnailfile) try: downloadtools.downloadfile(episode_item.thumbnail, thumbnailfile) logger.info("core.descargas Thumbnail descargado") except: logger.info( "core.descargas error al descargar thumbnail") for line in sys.exc_info(): logger.error("%s" % line) # Descarga el vídeo devuelve = downloadtools.downloadbest(video_urls, filetitle, continuar=False, silent=silent) if devuelve == 0: logger.info( "[launcher.py] download_all_episodes, download ok") descargado = True break elif devuelve == -1: try: import xbmcgui advertencia = xbmcgui.Dialog() resultado = advertencia.ok("plugin", "Descarga abortada") except: pass return else: logger.info( "[launcher.py] download_all_episodes, download error, try another mirror" ) break else: logger.info( "[launcher.py] download_all_episodes, downloading mirror not available... trying next" ) if not descargado: logger.info( "[launcher.py] download_all_episodes, EPISODIO NO DESCARGADO " + episode_title)
def downloadall(item): logger.info("[descargas.py] downloadall") if usingsamba(DOWNLOAD_LIST_PATH): ficheros = samba.get_files(DOWNLOAD_LIST_PATH) else: ficheros = os.listdir(DOWNLOAD_LIST_PATH) ficheros.sort() for fichero in ficheros: if fichero.endswith('.txt'): try: item = LeerDescarga(fichero, DOWNLOAD_LIST_PATH) video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( item.server, item.url, "", False) # La última es la de mayor calidad, lo mejor para la descarga mediaurl = video_urls[len(video_urls) - 1][1] # Genera el NFO nfofilepath = downloadtools.getfilefromtitle( "sample.nfo", item.title) outfile = open(nfofilepath, "w") outfile.write("<movie>\n") outfile.write("<title>(" + item.title + ")</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>" + item.plot + "</plot>\n") outfile.write("<tagline></tagline>\n") outfile.write("<runtime></runtime>\n") outfile.write("<thumb>" + item.thumbnail + "</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() # Descarga el thumbnail if item.thumbnail != "": thumbnailfile = downloadtools.getfilefromtitle( item.thumbnail, item.title) thumbnailfile = thumbnailfile[:-4] + ".tbn" try: downloadtools.downloadfile(item.thumbnail, thumbnailfile) except: logger.info( "[descargas.py] error al descargar thumbnail") for line in sys.exc_info(): logger.error("%s" % line) dev = downloadtools.downloadbest(video_urls, item.title) if dev == -1: logger.info("[descargas.py] Descarga cancelada") break elif dev == -2: logger.info("[descargas.py] ERROR EN DESCARGA DE " + fichero) BorrarDescarga(item, DOWNLOAD_LIST_PATH) GuardarDescarga(item, ERROR_PATH) else: BorrarDescarga(item, DOWNLOAD_LIST_PATH) except: logger.info("[descargas.py] ERROR EN DESCARGA DE " + fichero) import sys for line in sys.exc_info(): logger.error("%s" % line) GuardarDescarga(item, ERROR_PATH) BorrarDescarga(item, DOWNLOAD_LIST_PATH) return ""
def downloadall(item): logger.info("core.descargas downloadall") # Lee la lista de ficheros if usingsamba: ficheros = samba.get_files(DOWNLOAD_LIST_PATH) else: ficheros = os.listdir(DOWNLOAD_LIST_PATH) logger.info("core.descargas 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("core.descargas 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("core.descargas url=" + url) # Averigua la URL del vídeo exec "from servers import " + server + " as server_connector" video_urls = server_connector.get_video_url( page_url=url, premium=(config.get_setting("megavideopremium") == "true"), user=config.get_setting("megavideouser"), password=config.get_setting("megavideopassword")) # La primera es la de mayor calidad, lo mejor para la descarga mediaurl = video_urls[0][1] logger.info("core.descargas 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("core.descargas Creado fichero NFO") # Descarga el thumbnail if thumbnail != "": logger.info("core.descargas thumbnail=" + thumbnail) thumbnailfile = downloadtools.getfilefromtitle( thumbnail, fulltitle) thumbnailfile = thumbnailfile[:-4] + ".tbn" logger.info("core.descargas thumbnailfile=" + thumbnailfile) try: downloadtools.downloadfile(thumbnail, thumbnailfile) logger.info("core.descargas Thumbnail descargado") except: logger.info( "core.descargas error al descargar thumbnail") for line in sys.exc_info(): logger.error("%s" % line) # Descarga el video dev = downloadtools.downloadtitle(mediaurl, fulltitle) if dev == -1: # El usuario ha cancelado la descarga logger.info("core.descargas Descarga cancelada") return elif dev == -2: # Error en la descarga, lo mueve a ERROR y continua con el siguiente logger.info("core.descargas 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("core.descargas 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("core.descargas " + fichero + " borrado") except: logger.info("core.descargas 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) if config.is_xbmc(): import xbmc xbmc.executebuiltin("XBMC.Container.Refresh()")