Mangago: Properly parse chapter titles (#17438)

This commit is contained in:
beerpsi 2023-08-10 00:55:36 +07:00 committed by GitHub
parent 562e7fa256
commit bb9f90efcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Mangago' extName = 'Mangago'
pkgNameSuffix = 'en.mangago' pkgNameSuffix = 'en.mangago'
extClass = '.Mangago' extClass = '.Mangago'
extVersionCode = 12 extVersionCode = 13
isNsfw = true isNsfw = true
} }
@ -13,4 +13,4 @@ apply from: "$rootDir/common.gradle"
dependencies { dependencies {
implementation(project(':lib-cryptoaes')) implementation(project(':lib-cryptoaes'))
} }

View File

@ -46,10 +46,11 @@ class Mangago : ParsedHttpSource() {
.addInterceptor { chain -> .addInterceptor { chain ->
val response = chain.proceed(chain.request()) val response = chain.proceed(chain.request())
val key = val fragment = response.request.url.fragment ?: return@addInterceptor response
response.request.url.queryParameter("desckey") ?: return@addInterceptor response
val cols = response.request.url.queryParameter("cols")?.toIntOrNull() // desckey=...&cols=...
?: return@addInterceptor response val key = fragment.substringAfter("desckey=").substringBefore("&")
val cols = fragment.substringAfter("&cols=").toIntOrNull() ?: return@addInterceptor response
val image = unscrambleImage(response.body.byteStream(), key, cols) val image = unscrambleImage(response.body.byteStream(), key, cols)
val body = image.toResponseBody("image/jpeg".toMediaTypeOrNull()) val body = image.toResponseBody("image/jpeg".toMediaTypeOrNull())
@ -172,13 +173,14 @@ class Mangago : ParsedHttpSource() {
override fun chapterListSelector() = "table#chapter_table > tbody > tr, table.uk-table > tbody > tr" override fun chapterListSelector() = "table#chapter_table > tbody > tr, table.uk-table > tbody > tr"
override fun chapterFromElement(element: Element) = SChapter.create().apply { override fun chapterFromElement(element: Element) = SChapter.create().apply {
val link = element.getElementsByTag("a") val link = element.select("a.chico")
setUrlWithoutDomain(link.attr("href")) setUrlWithoutDomain(link.attr("href"))
name = link.text().trim() name = link.text().trim()
date_upload = runCatching { date_upload = runCatching {
dateFormat.parse(element.select("td:last-child").text().trim())?.time dateFormat.parse(element.select("td:last-child").text().trim())?.time
}.getOrNull() ?: 0L }.getOrNull() ?: 0L
scanlator = element.selectFirst("td.no a, td.uk-table-shrink a")?.text()?.trim()
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
@ -231,7 +233,7 @@ class Mangago : ParsedHttpSource() {
.split(",") .split(",")
.mapIndexed { idx, it -> .mapIndexed { idx, it ->
val url = if (it.contains("cspiclink")) { val url = if (it.contains("cspiclink")) {
"$it?desckey=${getDescramblingKey(deobfChapterJs, it)}&cols=$cols" "$it#desckey=${getDescramblingKey(deobfChapterJs, it)}&cols=$cols"
} else { } else {
it it
} }