MangaKawaii: fix loading of chapterList on some manga (#6461)

This commit is contained in:
Julien Papasian 2021-04-07 17:10:23 +01:00 committed by GitHub
parent 36af40db57
commit 3975047cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 16 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Mangakawaii'
pkgNameSuffix = 'fr.mangakawaii'
extClass = '.MangaKawaii'
extVersionCode = 26
extVersionCode = 27
libVersion = '1.2'
}

View File

@ -100,15 +100,25 @@ class MangaKawaii : ParsedHttpSource() {
}
// Chapter list
//override fun chapterListRequest(manga: SManga): Request = GET("$baseUrl${manga.widgetPageUrl}", headers)
override fun chapterListSelector() = "tr[class*=volume-]:has(td)"
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
url = element.select("td.table__chapter").select("a").attr("href")
name = element.select("td.table__chapter").select("span").text().trim()
chapter_number = element.select("td.table__chapter").select("span").text().substringAfter("Chapitre").replace(Regex("""[,-]"""), ".").trim().toFloatOrNull()
?: -1F
date_upload = element.select("td.table__date").firstOrNull()?.text()?.let { parseDate(it) }
?: 0
override fun chapterListSelector() = throw Exception("Not used")
override fun chapterFromElement(element: Element): SChapter = throw Exception("Not used")
override fun chapterListParse(response: Response): List<SChapter> {
var document = response.asJsoup()
val widgetPageListUrl = Regex("""['"](/arrilot/load-widget.*?)['"]""").find(document.toString())?.groupValues?.get(1)
if (widgetPageListUrl != null) {
document = client.newCall(GET("$baseUrl$widgetPageListUrl", headers)).execute().asJsoup()
}
return document.select("tr[class*=volume-]:has(td)").map {
SChapter.create().apply {
url = it.select("td.table__chapter").select("a").attr("href")
name = it.select("td.table__chapter").select("span").text().trim()
chapter_number = it.select("td.table__chapter").select("span").text().substringAfter("Chapitre").replace(Regex("""[,-]"""), ".").trim().toFloatOrNull()
?: -1F
date_upload = it.select("td.table__date").firstOrNull()?.text()?.let { parseDate(it) }
?: 0
}
}
}
private fun parseDate(date: String): Long {
@ -116,9 +126,7 @@ class MangaKawaii : ParsedHttpSource() {
}
// Pages
override fun pageListParse(response: Response): List<Page> {
val body = response.asJsoup()
override fun pageListParse(document: Document): List<Page> {
val selectorEncoded1 = "Wkdim" + "gsai" + "mgWQyV2lkMm" + "xrS2img" + "ppZDFoY" + "kd4ZElHaW" +
"RsdimgFp6cHVi" + "M1FvVzNOeVl5" + "bimgzlpZG" + "lkWjJsbVhT" + "a3imgNJQzVq" + "YjI1MFlpZFd" +
"saWR1WlhJdFi" + "mgpteDFhV1FnTGi" + "mg5KdmlkZHlC" + "a2FYWimgTZiaW" + "imgRtOTBL" + "QzV0ZUMxaim" +
@ -126,14 +134,19 @@ class MangaKawaii : ParsedHttpSource() {
"mgGdHpp" + "ZGNtTXFQimg" + "V2RwWml" + "kbDBw"
val selectorEncoded2 = String(Base64.decode(selectorEncoded1.replace("img", ""), Base64.DEFAULT))
val selectorDecoded = String(Base64.decode(selectorEncoded2.replace("id", ""), Base64.DEFAULT))
var elements = body.select(selectorDecoded)
val elements = document.select(selectorDecoded)
val pages = mutableListOf<Page>()
for (i in 0 until elements.count()) {
pages.add(Page(i, "", elements[i].attr("src").trim()))
pages.add(Page(i, document.location(), elements[i].attr("src").trim()))
}
return pages
}
override fun pageListParse(document: Document): List<Page> = throw Exception("Not used")
override fun imageUrlParse(document: Document): String = throw Exception("Not used")
override fun imageRequest(page: Page): Request {
val imgHeaders = headersBuilder().apply {
add("Referer", page.url)
}.build()
return GET(page.imageUrl!!, imgHeaders)
}
}