def obtenerCapitulos(manga = Manga, urlCapitulos = '', parametros = ParamDescarga): http = httplib2.Http() codCapituloIni = parametros.codCapitulo headers, body = http.request(urlCapitulos) content = body log.file(body) #print content soup = BeautifulSoup(content, 'html.parser') lst=[] listCapsRet = [] lstCaps = [] soupTable = soup.find("table", {"id" : "caps-list"}) rows = soupTable.find_all('tr') for row in rows: cells = row.find_all("td") tituloCap = cells[1].get_text().encode('utf-8') urlCap= "%s/es"%(cells[1].a.get("href")) capitulo = Capitulo(urlCap, tituloCap) capitulo.code = cells[0].get_text().encode('utf-8') lstCaps.append(capitulo) if(codCapituloIni is not None): for cap in lstCaps: if(parametros.tipo == TYPE.UNIQUE and int(cap.code) == int(codCapituloIni)): lst.append(cap) break if(parametros.tipo != TYPE.UNIQUE and int(cap.code) >= int(codCapituloIni)): lst.append(cap) else: lst = lstCaps return lst, manga
def obtenerCapitulos(manga = Manga, urlCapitulos = '', parametros = ParamDescarga): codCapituloIni = parametros.codCapitulo pat = re.compile('<td class="s">(.+?)</td>') http = httplib2.Http() lstCaps = [] listCapsRet=[] lst=[] log.info("http.request[lstCapitulos] ==> %s"%urlCapitulos) headers, body = http.request(urlCapitulos) log.file(body) li = pat.findall("%s"%body) log.file(li) for elem in li: strOption = str(elem) strOption = strOption.replace('<strong>', '') strOption = strOption.replace('</strong>', '') pat2 = re.compile('<a href="(.+?)">(.+?)</a>') cap = pat2.findall("%s"%strOption) lstCaps.append(cap) total = len(lstCaps) manga.length = total totPre = len(str(total)) # print lstCaps # exit(0) if(total > 1): lstCaps = sorted(lstCaps, key=splittedname) if(codCapituloIni is not None): for cap in lstCaps: codCap = cap[0][0].split("/")[-2] codCap = funciones.prefijo(codCap, totPre) capIni = funciones.prefijo(str(codCapituloIni), totPre) #codCap = funciones.decode(codCap) if(parametros.tipo == TYPE.UNIQUE and codCap == capIni): listCapsRet.append(cap) break if (codCap >= capIni and parametros.tipo != TYPE.UNIQUE): listCapsRet.append(cap) else: listCapsRet = lstCaps for cap in listCapsRet: capitulo = Capitulo(cap[0][0], cap[0][1]) #capitulo.url = "%s%s/"%(manga.url, capitulo.code) capitulo.code = capitulo.url.split("/")[-2] auxUri = capitulo.url.split("/")[-3] capitulo.url = capitulo.url.replace("%s/%s"%(auxUri, capitulo.code), "c") lst.append(capitulo) return lst, manga
def capituloLiar_game2(): capitulo = Capitulo() capitulo.code = "1" capitulo.url = "http://es.mangahere.co/manga/liar_game/c1/" capitulo.title = "Liar Game 1" capitulo.length = 0 capitulo.folder = "/media/Shampoo/Manga/liar_game/download/C01" return capitulo
def capituloSprite(): capitulo = Capitulo() capitulo.code = "1" capitulo.url = "http://esmanga.com/manga/sprite/c1" capitulo.title = "Sprite 1" capitulo.length = 0 capitulo.folder = "/media/Shampoo/Manga/sprite/download/C01" return capitulo
def capituloZetaman2(): capitulo = Capitulo() capitulo.code = "14" capitulo.url = "http://submanga.com/c/35471" capitulo.title = "Zetman 14" capitulo.length = 0 capitulo.folder = "/media/Shampoo/Manga/zetman/download/C014" return capitulo
def capituloZunKenRock(): capitulo = Capitulo() capitulo.code = "6" capitulo.url = "http://submanga.org/sun-ken-rock/capitulo/6" capitulo.title = "Zun Ken Rock 6" capitulo.length = 0 capitulo.folder = "/Manga/sun_ken_rock/download/C06" return capitulo
def obtenerCapitulos(manga = Manga, urlCapitulos = '', parametros = ParamDescarga): codCapituloIni = parametros.codCapitulo pat = re.compile('<select class="cbo_wpm_chp" onchange="[^"]+">(.+?)</select>') http = httplib2.Http() headers, body = http.request(urlCapitulos) li = pat.findall("%s"%body) listCapsRet = [] lst=[] strOption = str(li[0]) strOption = strOption.replace('selected="selected"', '') pat2 = re.compile('<option value="(.+?)" >(.+?)</option>') lstCaps = pat2.findall("%s"%strOption) total = len(lstCaps) totPre = len(str(total)) manga.length = total # print lstCaps # exit(0) if(total > 1): lstCaps = sorted(lstCaps, key=funciones.splittedname) if(codCapituloIni is not None): for cap in lstCaps: codCap = funciones.prefijo(cap[0], totPre) capIni = funciones.prefijo(str(codCapituloIni), totPre) codCap = funciones.decode(codCap) if(parametros.tipo == TYPE.UNIQUE and codCap == capIni): listCapsRet.append(cap) break if (codCap >= capIni and parametros.tipo != TYPE.UNIQUE): listCapsRet.append(cap) else: listCapsRet = lstCaps for cap in listCapsRet: capitulo = Capitulo(None, cap[1]) capitulo.code = str(cap[0]) capitulo.url = "%s%s/"%(manga.url, capitulo.code) lst.append(capitulo) return lst, manga