LS: use regex for cookie extraction (#3441)

* LuaScan: use regex for cookie extraction

* retry anyway
This commit is contained in:
AwkwardPeak7 2024-06-09 17:36:16 +05:00 committed by Draff
parent 681bde548b
commit 1f4c56a57c
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 6 additions and 4 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.LuaScans'
themePkg = 'mangathemesia'
baseUrl = 'https://luascans.com'
overrideVersionCode = 2
overrideVersionCode = 3
}
apply from: "$rootDir/common.gradle"

View File

@ -30,12 +30,12 @@ class LuaScans : MangaThemesia(
return if (document.selectFirst("script:containsData(wafff)") != null) {
val script = document.selectFirst("script:containsData(wafff)")!!.data()
val cookie = script.substringAfter("document.cookie=\"")
.substringBefore("\"")
val cookie = waffRegex.find(script)?.groups?.get("waff")?.value
?.let { Cookie.parse(request.url, it) }
client.cookieJar.saveFromResponse(
request.url,
listOfNotNull(Cookie.parse(request.url, cookie)),
listOfNotNull(cookie),
)
response.close()
@ -45,4 +45,6 @@ class LuaScans : MangaThemesia(
response
}
}
private val waffRegex = Regex("""document\.cookie\s*=\s*['"](?<waff>.*)['"]""")
}