Baimangu: Fix page parsing (#6570)

This commit is contained in:
AlphaBoom 2024-12-11 21:26:09 +08:00 committed by Draff
parent 3ecfb8529c
commit b3f22ebf80
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 13 additions and 10 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Baimangu (Darpou)' extName = 'Baimangu (Darpou)'
extClass = '.Baimangu' extClass = '.Baimangu'
extVersionCode = 3 extVersionCode = 4
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -22,7 +22,6 @@ import org.jsoup.nodes.Element
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
class Baimangu : ConfigurableSource, ParsedHttpSource() { class Baimangu : ConfigurableSource, ParsedHttpSource() {
override val lang = "zh" override val lang = "zh"
@ -71,7 +70,13 @@ class Baimangu : ConfigurableSource, ParsedHttpSource() {
} }
// Popular Manga // 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 popularMangaNextPageSelector() = commonNextPageSelector
override fun popularMangaSelector() = commonSelector override fun popularMangaSelector() = commonSelector
override fun popularMangaFromElement(element: Element) = commonMangaFromElement(element) override fun popularMangaFromElement(element: Element) = commonMangaFromElement(element)
@ -205,15 +210,13 @@ class Baimangu : ConfigurableSource, ParsedHttpSource() {
val theScriptData = document.selectFirst("script:containsData(oScript.src)")?.data() val theScriptData = document.selectFirst("script:containsData(oScript.src)")?.data()
?: throw Exception("Unable to find OScript") ?: throw Exception("Unable to find OScript")
val pattern = Pattern.compile("src(\\s*)=(\\s*)\"(.+)\";") val scriptUrl = theScriptData.substringAfter("txt_url=\"").substringBefore("\"")
val matcher = pattern.matcher(theScriptData) if (scriptUrl.isEmpty()) {
if (matcher.find()) {
return matcher.group(3) ?: throw Exception("Unable to extract OScript")
}
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<Page> { private fun extractPagesFromOScript(content: String): List<Page> {
if (content.isEmpty()) { if (content.isEmpty()) {