From 522e3af41d462c2586b0e4b5b11d0b39b0345327 Mon Sep 17 00:00:00 2001 From: Draken <131387159+dragonx943@users.noreply.github.com> Date: Sun, 25 May 2025 14:06:52 +0700 Subject: [PATCH] [Koharu] Fixes (#1811) * [Koharu] Debug attempt 1 * [Koharu] Debug attempt 2 * [Koharu] Debug attempt 3 * [Koharu] Fix chapter url --------- Co-authored-by: Draken --- .../kotatsu/parsers/site/all/Koharu.kt | 27 +++---------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/Koharu.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/Koharu.kt index bc3b64a0..cbec405d 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/Koharu.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/Koharu.kt @@ -321,30 +321,11 @@ internal class Koharu(context: MangaLoaderContext) : val id = parts[0] 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 - - 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 currentToken = WebViewHelper(context).getLocalStorageValue(chapUrl, "clearance") + ?: throw IllegalStateException("Cant get auth token") val dataUrl = "https://$apiSuffix/books/detail/$id/$key?crt=$currentToken" val dataResponse = webClient.httpPost(