From 27c07d86bc80ebd59fcd96e66c9b5fa46d21b6ff Mon Sep 17 00:00:00 2001 From: Naga <94557604+NagaYZ@users.noreply.github.com> Date: Thu, 12 Sep 2024 01:20:34 +0200 Subject: [PATCH] fix tags --- .../kotatsu/parsers/site/heancms/HeanCms.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/heancms/HeanCms.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/heancms/HeanCms.kt index 7e1ab24ab..7dec6b31b 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/heancms/HeanCms.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/heancms/HeanCms.kt @@ -182,10 +182,16 @@ internal abstract class HeanCms( override suspend fun getAvailableTags(): Set { val doc = webClient.httpGet("https://$domain/comics").parseHtml() - val regex = Regex("\"tags\\\\.*?(\\[.+?])") - val tags = doc.select("script").firstNotNullOf { script -> - regex.find(script.html())?.groupValues?.getOrNull(1) - }.unescapeJson() + val regex = Regex("\"tags\\\\?\":\\s*\\[(.+?)]\\s*[},]") + val tags = doc.select("script").joinToString("") { it.html() } + .let { fullHtml -> + regex.find(fullHtml)?.groupValues?.getOrNull(1) + } + ?.unescapeJson() + ?.replace(Regex(""""]\)\s*self\.__next_f\.push\(\[\d+,""""), "") + ?.let { "[$it]" } + ?: return emptySet() + return JSONArray(tags).mapJSON { MangaTag( key = it.getInt("id").toString(), @@ -194,4 +200,5 @@ internal abstract class HeanCms( ) }.toSet() } + }