def savebookmark(canal=CHANNELNAME,titulo="",url="",thumbnail="",server="",plot="",fulltitle="",savepath=BOOKMARK_PATH): logger.info("tvalacarta.core.favoritos savebookmark(path="+savepath+")") # Crea el directorio de favoritos si no existe if not usingsamba(savepath): try: os.mkdir(savepath) except: pass # Lee todos los ficheros if usingsamba(savepath): ficheros = samba.get_files(savepath) else: ficheros = os.listdir(savepath) ficheros.sort() # Averigua el ?ltimo n?mero if len(ficheros)>0: # XRJ: Linea problem?ica, sustituida por el bucle siguiente #filenumber = int( ficheros[len(ficheros)-1][0:-4] )+1 filenumber = 1 for fichero in ficheros: logger.info("tvalacarta.core.favoritos fichero="+fichero) try: tmpfilenumber = int( fichero[0:8] )+1 if tmpfilenumber > filenumber: filenumber = tmpfilenumber except: pass else: filenumber=1 # Genera el contenido filecontent = "" filecontent = filecontent + urllib.quote_plus(downloadtools.limpia_nombre_excepto_1(titulo))+'\n' filecontent = filecontent + urllib.quote_plus(url)+'\n' filecontent = filecontent + urllib.quote_plus(thumbnail)+'\n' filecontent = filecontent + urllib.quote_plus(server)+'\n' filecontent = filecontent + urllib.quote_plus(downloadtools.limpia_nombre_excepto_1(plot))+'\n' filecontent = filecontent + urllib.quote_plus(fulltitle)+'\n' filecontent = filecontent + urllib.quote_plus(canal)+'\n' # Genera el nombre de fichero from core import scrapertools filename = '%08d-%s.txt' % (filenumber,scrapertools.slugify(fulltitle)) logger.info("tvalacarta.core.favoritos savebookmark filename="+filename) # Graba el fichero if not usingsamba(savepath): fullfilename = os.path.join(savepath,filename) bookmarkfile = open(fullfilename,"w") bookmarkfile.write(filecontent) bookmarkfile.flush(); bookmarkfile.close() else: samba.write_file(filename, filecontent, savepath)
def GuardarDescarga(item, Ruta=DOWNLOAD_LIST_PATH): logger.info("[descargas.py] GuardarDescarga") if usingsamba(Ruta): ficheros = samba.get_files(Ruta) else: ficheros = os.listdir(Ruta) ficheros.sort() # Averigua el último número if len(ficheros) > 0: # XRJ: Linea problemática, sustituida por el bucle siguiente #filenumber = int( ficheros[len(ficheros)-1][0:-4] )+1 filenumber = 1 for fichero in ficheros: logger.info("[favoritos.py] fichero=" + fichero) try: tmpfilenumber = int(fichero[0:8]) + 1 if tmpfilenumber > filenumber: filenumber = tmpfilenumber except: pass else: filenumber = 1 # Genera el nombre de fichero from core import scrapertools filename = '%08d-%s.txt' % (filenumber, scrapertools.slugify(item.title)) fullfilename = os.path.join(Ruta, filename) logger.info("[descargas.py] GuardarDescarga filename=" + fullfilename) # Genera el contenido if Ruta == DOWNLOAD_LIST_PATH: item.category = "pendientes" if Ruta == ERROR_PATH: item.category = "errores" item.channel = "descargas" item.extra = fullfilename item.folder = False filecontent = item.serialize() # Graba el fichero if not usingsamba(Ruta): bookmarkfile = open(fullfilename.decode("utf-8"), "w") bookmarkfile.write(filecontent) bookmarkfile.flush() bookmarkfile.close() else: samba.write_file(filename, filecontent, Ruta)
def GuardarDescarga(item, Ruta=DOWNLOAD_LIST_PATH): logger.info("[descargas.py] GuardarDescarga") if usingsamba(Ruta): ficheros = samba.get_files(Ruta) else: ficheros = os.listdir(Ruta) ficheros.sort() # Averigua el último número if len(ficheros)>0: # XRJ: Linea problemática, sustituida por el bucle siguiente #filenumber = int( ficheros[len(ficheros)-1][0:-4] )+1 filenumber = 1 for fichero in ficheros: logger.info("[favoritos.py] fichero="+fichero) try: tmpfilenumber = int( fichero[0:8] )+1 if tmpfilenumber > filenumber: filenumber = tmpfilenumber except: pass else: filenumber=1 # Genera el nombre de fichero from core import scrapertools filename = '%08d-%s.txt' % (filenumber,scrapertools.slugify(item.title)) fullfilename = os.path.join(Ruta,filename) logger.info("[descargas.py] GuardarDescarga filename="+fullfilename) # Genera el contenido if Ruta==DOWNLOAD_LIST_PATH: item.category="pendientes" if Ruta==ERROR_PATH: item.category="errores" item.channel="descargas" item.file=fullfilename item.folder=False filecontent = item.serialize() # Graba el fichero if not usingsamba(Ruta): bookmarkfile = open(fullfilename.decode("utf-8"),"w") bookmarkfile.write(filecontent) bookmarkfile.flush(); bookmarkfile.close() else: samba.write_file(filename, filecontent, Ruta)
def savebookmark(canal=CHANNELNAME, titulo="", url="", thumbnail="", server="", plot="", fulltitle="", savepath=BOOKMARK_PATH): logger.info("tvalacarta.core.favoritos savebookmark(path=" + savepath + ")") # Crea el directorio de favoritos si no existe if not usingsamba(savepath): try: os.mkdir(savepath) except: pass # Lee todos los ficheros if usingsamba(savepath): ficheros = samba.get_files(savepath) else: ficheros = os.listdir(savepath) ficheros.sort() # Averigua el ?ltimo n?mero if len(ficheros) > 0: # XRJ: Linea problem?ica, sustituida por el bucle siguiente #filenumber = int( ficheros[len(ficheros)-1][0:-4] )+1 filenumber = 1 for fichero in ficheros: logger.info("tvalacarta.core.favoritos fichero=" + fichero) try: tmpfilenumber = int(fichero[0:8]) + 1 if tmpfilenumber > filenumber: filenumber = tmpfilenumber except: pass else: filenumber = 1 # Genera el contenido filecontent = "" filecontent = filecontent + urllib.quote_plus( downloadtools.limpia_nombre_excepto_1(titulo)) + '\n' filecontent = filecontent + urllib.quote_plus(url) + '\n' filecontent = filecontent + urllib.quote_plus(thumbnail) + '\n' filecontent = filecontent + urllib.quote_plus(server) + '\n' filecontent = filecontent + urllib.quote_plus( downloadtools.limpia_nombre_excepto_1(plot)) + '\n' filecontent = filecontent + urllib.quote_plus(fulltitle) + '\n' filecontent = filecontent + urllib.quote_plus(canal) + '\n' # Genera el nombre de fichero from core import scrapertools filename = '%08d-%s.txt' % (filenumber, scrapertools.slugify(fulltitle)) logger.info("tvalacarta.core.favoritos savebookmark filename=" + filename) # Graba el fichero if not usingsamba(savepath): fullfilename = os.path.join(savepath, filename) bookmarkfile = open(fullfilename, "w") bookmarkfile.write(filecontent) bookmarkfile.flush() bookmarkfile.close() else: samba.write_file(filename, filecontent, savepath)