Skip to content

Commit

Permalink
Baimangu: Fix page parsing (#6570)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaBoom authored Dec 11, 2024
1 parent 8285ca0 commit e90eb91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/zh/baimangu/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Baimangu (Darpou)'
extClass = '.Baimangu'
extVersionCode = 3
extVersionCode = 4
}

apply from: "$rootDir/common.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<Page> {
Expand Down

0 comments on commit e90eb91

Please sign in to comment.