From a909a307fd0be7d5e86470de3c60967ef9fcd3a5 Mon Sep 17 00:00:00 2001 From: stevenyomi <95685115+stevenyomi@users.noreply.github.com> Date: Tue, 8 Aug 2023 03:32:31 +0800 Subject: [PATCH] Baozi Manhua: fix page list and images parsing (#17434) --- src/zh/baozimanhua/CHANGELOG.md | 10 ++++++ src/zh/baozimanhua/build.gradle | 2 +- .../extension/zh/baozimanhua/Baozi.kt | 32 +++++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/zh/baozimanhua/CHANGELOG.md b/src/zh/baozimanhua/CHANGELOG.md index 7d0a406ca..1b852a841 100644 --- a/src/zh/baozimanhua/CHANGELOG.md +++ b/src/zh/baozimanhua/CHANGELOG.md @@ -1,3 +1,13 @@ +## 1.3.21 (2023-08-08) + +- 设置里新增一些镜像网址 +- 修复部分情况下无法解析章节的问题 +- 修复所有图片无法加载的问题 + +## 1.3.20 (2023-07-29) + +- 修复需要验证时图片无法加载的问题 + ## 1.3.19 (2023-04-03) - 设置章节日期时不再错误地检查应用版本 diff --git a/src/zh/baozimanhua/build.gradle b/src/zh/baozimanhua/build.gradle index 6cb0fa785..7fa80b063 100644 --- a/src/zh/baozimanhua/build.gradle +++ b/src/zh/baozimanhua/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Baozi Manhua' pkgNameSuffix = 'zh.baozimanhua' extClass = '.Baozi' - extVersionCode = 20 + extVersionCode = 21 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/baozimanhua/src/eu/kanade/tachiyomi/extension/zh/baozimanhua/Baozi.kt b/src/zh/baozimanhua/src/eu/kanade/tachiyomi/extension/zh/baozimanhua/Baozi.kt index 56bd08ee5..36ace6828 100644 --- a/src/zh/baozimanhua/src/eu/kanade/tachiyomi/extension/zh/baozimanhua/Baozi.kt +++ b/src/zh/baozimanhua/src/eu/kanade/tachiyomi/extension/zh/baozimanhua/Baozi.kt @@ -135,16 +135,14 @@ class Baozi : ParsedHttpSource(), ConfigurableSource { } override fun fetchPageList(chapter: SChapter): Observable> = Observable.fromCallable { - val pageNumberSelector = Evaluator.Class("comic-text__amp") - val pageList = ArrayList(0) + val pathToUrl = LinkedHashMap() var url = baseUrl + chapter.url - var i = 0 while (true) { val document = client.newCall(GET(url, headers)).execute().asJsoup() - document.select(".comic-contain amp-img").dropWhile { element -> - element.selectFirst(pageNumberSelector)!!.text().substringBefore('/').toInt() <= i - }.mapTo(pageList) { element -> - Page(i++, imageUrl = element.attr("data-src")) + for (element in document.select(".comic-contain amp-img")) { + val imageUrl = element.attr("data-src") + val path = imageUrl.substring(imageUrl.indexOf('/', startIndex = 8)) // Skip "https://" + pathToUrl[path] = imageUrl } url = document.selectFirst(Evaluator.Id("next-chapter")) ?.takeIf { @@ -154,7 +152,12 @@ class Baozi : ParsedHttpSource(), ConfigurableSource { ?.attr("href") ?: break } - pageList + pathToUrl.values.mapIndexed { index, imageUrl -> Page(index, imageUrl = imageUrl) } + } + + override fun imageRequest(page: Page): Request { + val url = page.imageUrl!!.replace(".baozicdn.com", ".baozimh.com") + return GET(url, headers) } override fun pageListParse(document: Document) = throw UnsupportedOperationException("Not used.") @@ -189,7 +192,6 @@ class Baozi : ParsedHttpSource(), ConfigurableSource { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { // impossible to search a manga and use the filters return if (query.isNotEmpty()) { - val baseUrl = baseUrl.replace("webmota.com", "baozimh.com") val url = baseUrl.toHttpUrl().newBuilder() .addEncodedPathSegment("search") .addQueryParameter("q", query) @@ -227,8 +229,7 @@ class Baozi : ParsedHttpSource(), ConfigurableSource { entries = MIRRORS entryValues = MIRRORS summary = "已选择:%s\n" + - "重启生效,切换简繁体后需要迁移才能刷新漫画标题。\n" + - "搜索漫画时自动使用 baozimh.com 域名以避免出错。" + "重启生效,切换简繁体后需要迁移才能刷新漫画标题。" setDefaultValue(MIRRORS[0]) }.let { screen.addPreference(it) } @@ -251,8 +252,7 @@ class Baozi : ParsedHttpSource(), ConfigurableSource { summary = "已选择:%s\n" + "部分作品的章节顺序错误,最新章节总是显示为一个旧章节,导致检查更新时新章节被错标为已读。" + "开启后,将会正确判断新章节和已读情况,但是错误的章节顺序不会改变。" + - "如果作品有章节标号重复,开启或关闭后第一次刷新会导致它们的阅读状态同步。" + - "开启或关闭强力模式后第一次刷新会将所有未标号的章节标记为未读。" + "警告:修改此设置后第一次刷新可能会导致已读状态出现错乱,请谨慎使用。" entries = arrayOf("关闭", "开启 (对有标号的章节有效)", "强力模式 (对所有章节有效)") entryValues = arrayOf(CHAPTER_ORDER_DISABLED, CHAPTER_ORDER_ENABLED, CHAPTER_ORDER_AGGRESSIVE) setDefaultValue(CHAPTER_ORDER_DISABLED) @@ -270,6 +270,12 @@ class Baozi : ParsedHttpSource(), ConfigurableSource { "tw.webmota.com", "www.baozimh.com", "www.webmota.com", + "cn.kukuc.co", + "tw.kukuc.co", + "www.kukuc.co", + "cn.czmanga.com", + "tw.czmanga.com", + "www.czmanga.com", ) private const val DEFAULT_LEVEL = BaoziBanner.NORMAL.toString()