From b747b55681a94b6748cb86d860921c9742cee0de Mon Sep 17 00:00:00 2001 From: Hualiang <78242797+hualiong@users.noreply.github.com> Date: Fri, 11 Jul 2025 13:21:11 +0800 Subject: [PATCH] Bilimanga: fixed some chapter page response encoding parsing errors (#9609) * fixed some chapter page response encoding parsing errors * modify --- src/zh/bilimanga/build.gradle | 2 +- .../extension/zh/bilimanga/BiliManga.kt | 32 +++++++++++-------- .../zh/bilimanga/MangaInterceptor.kt | 9 ++---- .../extension/zh/bilimanga/Preferences.kt | 20 ++++++------ 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/zh/bilimanga/build.gradle b/src/zh/bilimanga/build.gradle index edc296fcc..fa7825cf6 100644 --- a/src/zh/bilimanga/build.gradle +++ b/src/zh/bilimanga/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'BiliManga' extClass = '.BiliManga' - extVersionCode = 1 + extVersionCode = 2 isNsfw = true } diff --git a/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/BiliManga.kt b/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/BiliManga.kt index f29ddbf81..5260101b9 100644 --- a/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/BiliManga.kt +++ b/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/BiliManga.kt @@ -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 -> diff --git a/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/MangaInterceptor.kt b/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/MangaInterceptor.kt index 978cbc1c0..3e25a9dc7 100644 --- a/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/MangaInterceptor.kt +++ b/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/MangaInterceptor.kt @@ -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() } diff --git a/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/Preferences.kt b/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/Preferences.kt index e763ba215..d4c5af1a2 100644 --- a/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/Preferences.kt +++ b/src/zh/bilimanga/src/eu/kanade/tachiyomi/extension/zh/bilimanga/Preferences.kt @@ -11,17 +11,17 @@ fun preferencesInternal(context: Context) = arrayOf( title = "熱門漫畫顯示内容" summary = "%s" entries = arrayOf( - "月点击榜", - "周点击榜", - "月推荐榜", - "周推荐榜", - "月鲜花榜", - "周鲜花榜", - "月鸡蛋榜", - "周鸡蛋榜", - "最新入库", + "月點擊榜", + "周點擊榜", + "月推薦榜", + "周推薦榜", + "月鮮花榜", + "周鮮花榜", + "月雞蛋榜", + "周雞蛋榜", + "最新入庫", "收藏榜", - "新书榜", + "新書榜", ) entryValues = arrayOf( "/top/monthvisit/%d.html",