Esempio n. 1
0
def GuardarFavorito(item, Ruta=BOOKMARK_PATH):
    logger.info("[favoritos.py] GuardarFavorito")
    import time
    # Lee todos los ficheros
    if usingsamba(Ruta):
        ficheros = samba.get_files(Ruta)
    else:
        ficheros = os.listdir(Ruta)

    filename = str(int(time.time())) + ".json"
    fullfilename = os.path.join(Ruta,filename)
    logger.info("[favoritos.py] savebookmark filename="+filename)
    
    # Genera el contenido
    if item.refered_action: item.action = item.refered_action
    item.context =""
    item.file = fullfilename
    filecontent = item.tojson()

    # Graba el fichero
    import json
    if not usingsamba(Ruta):
        open(fullfilename.decode("utf-8"),"w").write(filecontent)
    else:
        samba.write_file(filename, filecontent, Ruta)
Esempio n. 2
0
def savebookmark(
    canal=CHANNELNAME, titulo="", url="", thumbnail="", server="", plot="", fulltitle="", savepath=BOOKMARK_PATH
):
    logger.info("[favoritos.py] 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á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 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("[favoritos.py] 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)
Esempio n. 3
0
def GuardarFavorito(item, Ruta=BOOKMARK_PATH):
    logger.info("[favoritos.py] GuardarFavorito")
    import time
    # Lee todos los ficheros
    if usingsamba(Ruta):
        ficheros = samba.get_files(Ruta)
    else:
        ficheros = os.listdir(Ruta)

    filename = str(int(time.time())) + ".json"
    fullfilename = os.path.join(Ruta, filename)
    logger.info("[favoritos.py] savebookmark filename=" + filename)

    # Genera el contenido
    if item.refered_action: item.action = item.refered_action
    item.context = ""
    item.file = fullfilename
    filecontent = item.tojson()

    # Graba el fichero
    import json
    if not usingsamba(Ruta):
        open(fullfilename.decode("utf-8"), "w").write(filecontent)
    else:
        samba.write_file(filename, filecontent, Ruta)
Esempio n. 4
0
def savebookmark(canal=CHANNELNAME,titulo="",url="",thumbnail="",server="",plot="",fulltitle="",savepath=BOOKMARK_PATH):
    logger.info("[favoritos.py] 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á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 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("[favoritos.py] 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)
Esempio n. 5
0
def savebookmark(titulo,url,thumbnail,server,plot):
    logger.info("[favoritos.py] savebookmark")

    # No va bien más que en Windows
    #bookmarkfiledescriptor,bookmarkfilepath = tempfile.mkstemp(suffix=".txt",prefix="",dir=BOOKMARK_PATH)

    # Crea el directorio de favoritos si no existe
    if not usingsamba:
        try:
            os.mkdir(BOOKMARK_PATH)
        except:
            pass

    # Lee todos los ficheros
    if usingsamba:
        ficheros = samba.get_files(BOOKMARK_PATH)
    else:
        ficheros = os.listdir(BOOKMARK_PATH)
    ficheros.sort()
    #print ficheros
    #Filtra solo los ficheros
    ficheros2 = [f for f in ficheros
                if os.path.isfile(os.path.join(BOOKMARK_PATH, f)) and os.path.join(BOOKMARK_PATH, f).endswith(".txt")]

    # Averigua el último número
    if len(ficheros)>0:
        filenumber = int( ficheros[len(ficheros)-1][0:-4] )+1
    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'

    # Genera el nombre de fichero    
    filename = '%08d.txt' % filenumber
    logger.info("[favoritos.py] savebookmark filename="+filename)

    # Graba el fichero
    if not usingsamba:
        fullfilename = os.path.join(BOOKMARK_PATH,filename)
        bookmarkfile = open(fullfilename,"w")
        bookmarkfile.write(filecontent)
        bookmarkfile.flush();
        bookmarkfile.close()
    else:
        samba.write_file(filename, filecontent, BOOKMARK_PATH)
def GuardarFavorito(item, Ruta=BOOKMARK_PATH):
    logger.info("[favoritos.py] GuardarFavorito")

    # Lee todos los ficheros
    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("[favoritos.py] savebookmark filename="+filename)
    
    # Genera el contenido
    item.channel = "favoritos"
    item.extra = fullfilename
    filecontent = item.serialize()
    item.folder = False

    # 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)
Esempio n. 7
0
def GuardarFavorito(item, Ruta=BOOKMARK_PATH):
    logger.info("[favoritos.py] GuardarFavorito")

    # Lee todos los ficheros
    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("[favoritos.py] savebookmark filename=" + filename)

    # Genera el contenido
    item.channel = "favoritos"
    item.extra = fullfilename
    filecontent = item.serialize()
    item.folder = False

    # 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)