PeachScan: Update image urls selector (#3048)

Regex better
This commit is contained in:
bapeey 2024-05-16 11:48:17 -05:00 committed by GitHub
parent 300729019b
commit d0bd99abf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -2,7 +2,7 @@ plugins {
id("lib-multisrc")
}
baseVersionCode = 5
baseVersionCode = 6
dependencies {
compileOnly("com.github.tachiyomiorg:image-decoder:e08e9be535")

View File

@ -153,13 +153,16 @@ abstract class PeachScan(
}.getOrDefault(0L)
}
private val urlsRegex = """const\s+urls\s*=\s*\[(.*?)]\s*;""".toRegex()
override fun pageListParse(document: Document): List<Page> {
val scriptElement = document.selectFirst("script:containsData(const urls =[)")
val scriptElement = document.selectFirst("script:containsData(const urls)")
?: return document.select("#imageContainer img").mapIndexed { i, it ->
Page(i, document.location(), it.attr("abs:src"))
}
val urls = scriptElement.html().substringAfter("const urls =[").substringBefore("];")
val urls = urlsRegex.find(scriptElement.data())?.groupValues?.get(1)
?: throw Exception("Could not find image URLs")
return urls.split(",").mapIndexed { i, it ->
Page(i, document.location(), baseUrl + it.trim().removeSurrounding("'") + "#page")