Skip to content

Commit

Permalink
fix tags
Browse files Browse the repository at this point in the history
  • Loading branch information
NagaYZ authored and Koitharu committed Sep 14, 2024
1 parent e916f2a commit 27c07d8
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,16 @@ internal abstract class HeanCms(

override suspend fun getAvailableTags(): Set<MangaTag> {
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(),
Expand All @@ -194,4 +200,5 @@ internal abstract class HeanCms(
)
}.toSet()
}

}

0 comments on commit 27c07d8

Please sign in to comment.