[NHentai] Fix search with exact tag (#4644)

* [NHentai] Fix language filter

* Update build.gradle

* Fix filter with exact search

* Fix code style

* Update build.gradle

* Update build.gradle
This commit is contained in:
子斗子 2024-08-17 12:55:09 +08:00 committed by Draff
parent cb8cac580f
commit 9758bd897f
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
1 changed files with 9 additions and 18 deletions

View File

@ -166,27 +166,18 @@ open class NHentai(
}
}
private fun combineQuery(filters: FilterList): String {
val stringBuilder = StringBuilder()
val advSearch = filters.filterIsInstance<AdvSearchEntryFilter>().flatMap { filter ->
val splitState = filter.state.split(",").map(String::trim).filterNot(String::isBlank)
splitState.map {
AdvSearchEntry(filter.name, it.removePrefix("-"), it.startsWith("-"))
private fun combineQuery(filters: FilterList): String = buildString {
filters.filterIsInstance<AdvSearchEntryFilter>().forEach { filter ->
filter.state.split(",")
.map(String::trim)
.filterNot(String::isBlank)
.forEach { tag ->
if (tag.startsWith("-")) append("-")
append(filter.name, "\"", tag.removePrefix("-"), "\" ")
}
}
advSearch.forEach { entry ->
if (entry.exclude) stringBuilder.append("-")
stringBuilder.append("${entry.name}:")
stringBuilder.append(entry.text)
stringBuilder.append(" ")
}
return stringBuilder.toString()
}
data class AdvSearchEntry(val name: String, val text: String, val exclude: Boolean)
private fun searchMangaByIdRequest(id: String) = GET("$baseUrl/g/$id", headers)
private fun searchMangaByIdParse(response: Response, id: String): MangasPage {