[Koharu] Fixes (#1811)

* [Koharu] Debug attempt 1

* [Koharu] Debug attempt 2

* [Koharu] Debug attempt 3

* [Koharu] Fix chapter url

---------

Co-authored-by: Draken <dragonx943@users.noreply.github.com>
master
Draken 11 months ago committed by GitHub
parent 7b1a0b8d0d
commit 522e3af41d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -321,30 +321,11 @@ internal class Koharu(context: MangaLoaderContext) :
val id = parts[0] val id = parts[0]
val key = parts[1] val key = parts[1]
val detailResponse = webClient.httpGet("https://$apiSuffix/books/detail/$id/$key").parseJson() val chapUrl = "https://$domain/g/$mangaUrl/read/1" // request from first page
context.requestBrowserAction(this, chapUrl)
var currentToken = detailResponse.getStringOrNull("crt") ?: cachedToken val currentToken = WebViewHelper(context).getLocalStorageValue(chapUrl, "clearance")
?: throw IllegalStateException("Cant get auth token")
if (currentToken.isNullOrEmpty()) {
try {
val noTokenResponse = webClient.httpPost(
url = "https://$apiSuffix/books/detail/$id/$key".toHttpUrl(),
form = emptyMap(),
extraHeaders = getRequestHeaders(),
).parseJson()
currentToken = noTokenResponse.getStringOrNull("crt")
if (!currentToken.isNullOrEmpty()) {
cachedToken = currentToken
}
} catch (e: Exception) {
throw IllegalStateException("Cant get auth token", e)
}
}
if (currentToken.isNullOrEmpty()) {
throw IllegalStateException("Cant get auth token")
}
val dataUrl = "https://$apiSuffix/books/detail/$id/$key?crt=$currentToken" val dataUrl = "https://$apiSuffix/books/detail/$id/$key?crt=$currentToken"
val dataResponse = webClient.httpPost( val dataResponse = webClient.httpPost(

Loading…
Cancel
Save