Exemple #1
0
def infoManga(manga = Manga):
    log.info("[Info Manga] %s"%manga.code)
    fileInfo = "%s%s/%s"%(config.CONST_PATH, manga.uCode, config.CONST_INFO_FILE)

    #open the file template
    filein = open( '%s/tpl/info.tpl'%config.CONST_PATH_SRC )
    info = VolumenScan.getURLScann(manga)
    info = str(info).decode('utf-8')
    lstVol, status = VolumenScan.listaVolumenes(manga)
    listVol = []
    countVol = int(0)
    countCap = int(0)
    for vol in lstVol:                
        for cap in vol.capitulos:
            capStr = str("  > %s"%cap.name).decode('utf-8')
            listVol.append(capStr)
            countCap = countCap + 1
        listVol.append("------------------------------")
        listVol.append(vol.name)
        listVol.append("------------------------------")
        countVol = countVol + 1
    listVol = listVol[::-1]
    status, volinfo = VolumenScan.getMangaInfo(manga)
    #read it
    src = Template( str(filein.read()).decode('utf-8') )
    #document data
    title = str(manga.code).decode('utf-8')
    cover = str(manga.cover).decode('utf-8')
    d={ 'title':title, 'list':'\n'.join(listVol) , 'cover' : cover, 'info' : info, 'countCap' : countCap, 'countVol' : countVol, 'status' : status, 'volinfo': volinfo}
    #do the substitution
    result = src.substitute(d)
    result = result.encode('utf-8')
    log.debug(result)
    file_ = open(fileInfo, 'w')
    file_.write(result)
    file_.close()
Exemple #2
0
def organizarVolumenes(manga = Manga):
    lstFolder = MangaFile.listarArchivosCarpeta(manga)       
    if(len(lstFolder) > 0):
        totPre = len(lstFolder[0]) - 1
        lstVol, status = VolumenScan.listaVolumenes(manga)        
        for volumen in lstVol:
            lstFolderInVol = []
            capIni = volumen.capitulos[-1].name.split(" ")[-1]
            capFin = volumen.capitulos[0].name.split(" ")[-1]
            capIni = funciones.eliminarChrToEnd(capIni, ".")
            capFin = funciones.eliminarChrToEnd(capFin, ".")
            capIni = "C%s"%funciones.prefijo(str(capIni), totPre)
            capFin = "C%s"%funciones.prefijo(str(capFin), totPre)
            log.info( "%s ):: %s -> %s"%(volumen.name, capIni, capFin))
            for folder in lstFolder:
                downloadDir =  MangaFile.getMangaDownloadFolder(manga.uCode, folder)
                if capIni <= folder and folder <= capFin:
                    lstFolderInVol.append(downloadDir)
            if(lstFolderInVol.__len__()> 0):                
                volumenName = volumen.name.split(" ")[-1]
                volumenName = "%s-%s-%s-%s"%(funciones.prefijo(str(volumenName), 2), str(manga.uCode).title(), capIni, capFin)
                volumensDir = "%s%s/volumenes/%s"%(config.CONST_PATH, manga.uCode, volumenName)
                volumensDir = volumensDir.replace(' ', '')
                log.debug("[mkdir] =>%s"%volumensDir)
                MangaFile.makeDir(volumensDir)
                for folder in lstFolderInVol:
                    folderName = folder.split("/")[-1]
                    destFolder = "%s/%s"%(volumensDir, folderName)
                    MangaFile.move(folder, destFolder)         
    else:
        log.error("No se han encontrado capítulos en la carpeta download")               
    volumensDir = "%s%s/volumenes/"  %(config.CONST_PATH, manga.uCode)
    coverDir = "%s%s/covers/"  %(config.CONST_PATH, manga.uCode)
    lstVolumen = MangaFile.listaArchivosPath(volumensDir)
    lstCovers = MangaFile.listaArchivosPath(coverDir)
    log.info("Poniendo las carátulas en los volúmenes")
    if(len(lstVolumen) > 0) and (len(lstCovers) > 0):
        for volumen in lstVolumen:
            volFolder = "%s%s"%(volumensDir, volumen)
            log.debug(volFolder)
            numVol = volumen.split("-")[0]
            frontFile = "%s_v%s_front.jpg"%(manga.id, numVol)
            fullFile = "%s_v%s_full.jpg"%(manga.id, numVol)
            tocFile = "%s_v%s_toc.jpg"%(manga.id, numVol)
            backFile = "%s_v%s_back.jpg"%(manga.id, numVol)
            if (frontFile in lstCovers):
                origen = "%s%s"%(coverDir,frontFile)
                destino = "%s/001_front.jpg"%(volFolder)                
                MangaFile.copy(origen, destino)
            if (fullFile in lstCovers):
                origen = "%s%s"%(coverDir,fullFile)
                destino = "%s/002_full.jpg"%(volFolder)                
                MangaFile.copy(origen, destino)
            if (tocFile in lstCovers):
                origen = "%s%s"%(coverDir,tocFile)
                destino = "%s/003_toc.jpg"%(volFolder)                
                MangaFile.copy(origen, destino)
            if (backFile in lstCovers):
                origen = "%s%s"%(coverDir,backFile)
                destino = "%s/z004_back.jpg"%(volFolder)                
                MangaFile.copy(origen, destino)
Exemple #3
0
def parserTest():
    manga = mangas['wolf_guy']   
    volumenes, status = VolumenScan.listaVolumenes(manga)
    for volumen in volumenes:
        print volumen
Exemple #4
0
def scannVolumenTest():
    manga = mangas['liar_game']
    lstVol, status = VolumenScan.listaVolumenes(manga)        
    for volumen in lstVol:
        print volumen