Bilimanga: fixed some chapter page response encoding parsing errors (#9609)

* fixed some chapter page response encoding parsing errors

* modify
This commit is contained in:
Hualiang 2025-07-11 13:21:11 +08:00 committed by Draff
parent aedd777371
commit b747b55681
Signed by: Draff
GPG Key ID: E8A89F3211677653
4 changed files with 32 additions and 31 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'BiliManga'
extClass = '.BiliManga'
extVersionCode = 1
extVersionCode = 2
isNsfw = true
}

View File

@ -86,8 +86,7 @@ class BiliManga : HttpSource(), ConfigurableSource {
// Latest Page
override fun latestUpdatesRequest(page: Int) =
GET("$baseUrl/top/lastupdate/$page.html", headers)
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/top/lastupdate/$page.html", headers)
override fun latestUpdatesParse(response: Response) = popularMangaParse(response)
@ -119,11 +118,13 @@ class BiliManga : HttpSource(), ConfigurableSource {
val doc = response.asJsoup()
val meta = doc.selectFirst(".book-meta")!!.text().split("|")
val extra = meta.filterNot(META_REGEX::containsMatchIn)
val backupname = doc.selectFirst(".backupname")?.let { "漫畫別名:${it.text()}\n\n" }
val backupname = doc.selectFirst(".backupname")?.let {
"\n\n漫畫別名:\n${it.text().split("、").joinToString("\n• ")}"
}
url = doc.location()
title = doc.selectFirst(".book-title")!!.text()
thumbnail_url = doc.selectFirst(".book-cover")!!.attr("src")
description = backupname + doc.selectFirst("#bookSummary")?.text()
description = doc.selectFirst("#bookSummary")?.text() + backupname
artist = doc.selectFirst(".authorname")?.text()
author = doc.selectFirst(".illname")?.text() ?: artist
status = when (meta.firstOrNull()) {
@ -137,19 +138,22 @@ class BiliManga : HttpSource(), ConfigurableSource {
// Catalog Page
override fun chapterListRequest(manga: SManga) =
GET("$baseUrl/read/${manga.id}/catalog", headers)
override fun chapterListRequest(manga: SManga) = GET("$baseUrl/read/${manga.id}/catalog", headers)
override fun chapterListParse(response: Response) = response.asJsoup().let {
val info = it.selectFirst(".chapter-sub-title")!!.text()
val date = DATE_FORMAT.tryParse(DATE_REGEX.find(info)?.value)
val elements = it.select(".chapter-li-a")
elements.mapIndexed { i, e ->
val url = e.absUrl("href").takeUnless("javascript:cid(1)"::equals)
SChapter.create().apply {
name = e.text().toHalfWidthDigits()
date_upload = date
setUrlWithoutDomain(url ?: getChapterUrlByContext(i, elements))
it.select(".catalog-volume").flatMap { v ->
val chapterBar = v.selectFirst(".chapter-bar")!!.text().toHalfWidthDigits()
val chapters = v.select(".chapter-li-a")
chapters.mapIndexed { i, e ->
val url = e.absUrl("href").takeUnless("javascript:cid(1)"::equals)
SChapter.create().apply {
name = e.text().toHalfWidthDigits()
date_upload = date
scanlator = chapterBar
setUrlWithoutDomain(url ?: getChapterUrlByContext(i, chapters))
}
}
}.reversed()
}
@ -160,7 +164,7 @@ class BiliManga : HttpSource(), ConfigurableSource {
val images = it.select(".imagecontent")
check(images.size > 0) {
it.selectFirst("#acontentz")?.let { e ->
if ("電腦端" in e.text()) "章節不支持桌面電腦端瀏覽器顯示" else "漫畫可能已下架或需要登錄查看"
if ("電腦端" in e.text()) "不支持電腦端查看請在高級設置中更換移動端UA標識" else "漫畫可能已下架或需要登錄查看"
} ?: "章节鏈接错误"
}
images.mapIndexed { i, image ->

View File

@ -3,8 +3,6 @@ package eu.kanade.tachiyomi.extension.zh.bilimanga
import okhttp3.HttpUrl
import okhttp3.Interceptor
import okhttp3.Response
import okio.GzipSource
import okio.buffer
class MangaInterceptor : Interceptor {
@ -30,14 +28,13 @@ class MangaInterceptor : Interceptor {
"/read/${groups?.get(1)?.value}/${groups?.get(2)?.value?.toInt()?.minus(1)}.html"
}
else -> "/read/0/0.html"
} + "?predict"
}
override fun intercept(chain: Interceptor.Chain): Response {
val origin = chain.request()
regexOf(origin.url.fragment)?.let {
val response = chain.proceed(origin)
val html = GzipSource(response.body.source()).buffer().readUtf8()
val url = it.find(html)?.groups?.get(1)?.value?.plus("?match")
val response = chain.proceed(origin.newBuilder().removeHeader("Accept-Encoding").build())
val url = it.find(response.body.string())?.groups?.get(1)?.value
return response.newBuilder().code(302)
.header("Location", url ?: predictUrlByContext(origin.url)).build()
}

View File

@ -11,17 +11,17 @@ fun preferencesInternal(context: Context) = arrayOf(
title = "熱門漫畫顯示内容"
summary = "%s"
entries = arrayOf(
"点击",
"点击",
"月推",
"周推",
"花榜",
"花榜",
"蛋榜",
"蛋榜",
"最新入",
"點擊",
"點擊",
"月推",
"周推",
"花榜",
"花榜",
"蛋榜",
"蛋榜",
"最新入",
"收藏榜",
"",
"",
)
entryValues = arrayOf(
"/top/monthvisit/%d.html",