Vortex Scans: Fix no pages found (#6948)

* fix images

* replace substring with regexp

* change approach

* use kotlinx.seriaze intead of replace for json

* update comment
This commit is contained in:
dngonz 2025-01-04 00:53:45 +01:00 committed by Draff
parent f72e042cce
commit 3e2f37043b
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 31 additions and 2 deletions

View File

@ -2,7 +2,7 @@ ext {
extName = 'Vortex Scans'
extClass = '.VortexScans'
themePkg = 'iken'
overrideVersionCode = 35
overrideVersionCode = 36
isNsfw = false
}

View File

@ -1,9 +1,38 @@
package eu.kanade.tachiyomi.extension.en.arvenscans
import eu.kanade.tachiyomi.multisrc.iken.Iken
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.util.asJsoup
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import okhttp3.Response
import uy.kohesive.injekt.injectLazy
class VortexScans : Iken(
"Vortex Scans",
"en",
"https://vortexscans.org",
)
) {
private val json by injectLazy<Json>()
private val regexImages = """\\"images\\":(.*?)\\"next""".toRegex()
override fun pageListParse(response: Response): List<Page> {
val document = response.asJsoup()
val images = document.selectFirst("script:containsData(images)")
?.data()
?.let { regexImages.find(it)!!.groupValues[1].trim(',') }
?.let { json.decodeFromString<String>("\"$it\"") }
?.let { json.parseToJsonElement(it).jsonArray }
?: throw Exception("Unable to parse images")
return images.mapIndexed { idx, img ->
Page(idx, imageUrl = img.jsonObject["url"]!!.jsonPrimitive.content)
}
}
}