Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HeanCms #1059

Merged
merged 5 commits into from
Sep 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal abstract class HeanCms(
val url = buildString {
append("https://")
append(apiPath)
append("/query?query_string=")
append("/query?query_string=&series_type=Comic&perPage=$pageSize")
when (filter) {
is MangaListFilter.Search -> {
append(filter.query.urlEncoded())
Expand Down Expand Up @@ -86,16 +86,12 @@ internal abstract class HeanCms(
SortOrder.ALPHABETICAL_DESC -> append("title&order=desc")
else -> append("latest&order=desc")
}

append("&series_type=Comic&perPage=20")
append("&tags_ids=")
append("[".urlEncoded())
append(filter.tags.joinToString(",") { it.key })
append("]".urlEncoded())

}

null -> append("&status=All&orderBy=$paramsUpdated&order=desc&series_type=Comic&perPage=20")
null -> append("&status=All&orderBy=$paramsUpdated&order=desc")
}
append("&page=")
append(page.toString())
Expand Down Expand Up @@ -186,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 @@ -198,4 +200,5 @@ internal abstract class HeanCms(
)
}.toSet()
}

}
Loading