From b3f22ebf80ba371d5fcdbe1b25a25fe7aad2c00d Mon Sep 17 00:00:00 2001 From: AlphaBoom <30779939+AlphaBoom@users.noreply.github.com> Date: Wed, 11 Dec 2024 21:26:09 +0800 Subject: [PATCH] Baimangu: Fix page parsing (#6570) --- src/zh/baimangu/build.gradle | 2 +- .../extension/zh/baimangu/Baimangu.kt | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/zh/baimangu/build.gradle b/src/zh/baimangu/build.gradle index d8be016d6..9a734a1be 100644 --- a/src/zh/baimangu/build.gradle +++ b/src/zh/baimangu/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Baimangu (Darpou)' extClass = '.Baimangu' - extVersionCode = 3 + extVersionCode = 4 } apply from: "$rootDir/common.gradle" diff --git a/src/zh/baimangu/src/eu/kanade/tachiyomi/extension/zh/baimangu/Baimangu.kt b/src/zh/baimangu/src/eu/kanade/tachiyomi/extension/zh/baimangu/Baimangu.kt index 7c18d04cd..c34b02b07 100644 --- a/src/zh/baimangu/src/eu/kanade/tachiyomi/extension/zh/baimangu/Baimangu.kt +++ b/src/zh/baimangu/src/eu/kanade/tachiyomi/extension/zh/baimangu/Baimangu.kt @@ -22,7 +22,6 @@ import org.jsoup.nodes.Element import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.util.concurrent.TimeUnit -import java.util.regex.Pattern class Baimangu : ConfigurableSource, ParsedHttpSource() { override val lang = "zh" @@ -71,7 +70,13 @@ class Baimangu : ConfigurableSource, ParsedHttpSource() { } // Popular Manga - override fun popularMangaRequest(page: Int) = GET("$baseUrl/vodshow/4--hits------$page---.html", headers) + override fun popularMangaRequest(page: Int): Request { + return if (page <= 1) { + GET("$baseUrl/fenlei/4.html", headers) + } else { + GET("$baseUrl/fenlei/4-$page.html", headers) + } + } override fun popularMangaNextPageSelector() = commonNextPageSelector override fun popularMangaSelector() = commonSelector override fun popularMangaFromElement(element: Element) = commonMangaFromElement(element) @@ -205,14 +210,12 @@ class Baimangu : ConfigurableSource, ParsedHttpSource() { val theScriptData = document.selectFirst("script:containsData(oScript.src)")?.data() ?: throw Exception("Unable to find OScript") - val pattern = Pattern.compile("src(\\s*)=(\\s*)\"(.+)\";") - val matcher = pattern.matcher(theScriptData) - - if (matcher.find()) { - return matcher.group(3) ?: throw Exception("Unable to extract OScript") + val scriptUrl = theScriptData.substringAfter("txt_url=\"").substringBefore("\"") + if (scriptUrl.isEmpty()) { + throw Error("Unable to match for OScript") } - - throw Error("Unable to match for OScript") + return scriptUrl.replace("img.manga8.xyz", "img3.manga8.xyz") + .replace("img2.manga8.xyz", "img4.manga8.xyz") } private fun extractPagesFromOScript(content: String): List {