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' extClass = '.LuaScans'
themePkg = 'mangathemesia' themePkg = 'mangathemesia'
baseUrl = 'https://luascans.com' baseUrl = 'https://luascans.com'
overrideVersionCode = 2 overrideVersionCode = 3
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

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