Koharu | Fix Text Filters (#4614)

Fix Text Filters
This commit is contained in:
KenjieDec 2024-08-14 18:17:17 +07:00 committed by Draff
parent 81811577a6
commit 0735c39dad
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 5 additions and 14 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Koharu'
extClass = '.Koharu'
extVersionCode = 6
extVersionCode = 7
isNsfw = true
}

View File

@ -139,7 +139,7 @@ class Koharu : HttpSource(), ConfigurableSource {
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val url = apiBooksUrl.toHttpUrl().newBuilder().apply {
val terms = mutableListOf(query.trim())
val terms: MutableList<String> = mutableListOf()
filters.forEach { filter ->
when (filter) {
@ -154,18 +154,9 @@ class Koharu : HttpSource(), ConfigurableSource {
is TextFilter -> {
if (filter.state.isNotEmpty()) {
terms += filter.state.split(",").filter(String::isNotBlank).map { tag ->
val trimmed = tag.trim()
buildString {
if (trimmed.startsWith('-')) {
append("-")
}
append(filter.type)
append("!:")
append("\"")
append(trimmed.lowercase().removePrefix("-"))
append("\"")
}
val tags = filter.state.split(",").filter(String::isNotBlank).joinToString(",")
if (tags.isNotBlank()) {
terms += "${filter.type}!:" + '"' + tags + '"'
}
}
}