[MangaFire] Fix search

master
Koitharu 1 year ago
parent 23271c4623
commit 5a4f9d8914
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -172,7 +172,7 @@ internal class HitomiLaParser(context: MangaLoaderContext) : MangaParser(context
.trim()
.replace(Regex("""^\?"""), "")
.lowercase()
.split(Regex("\\s+"))
.splitByWhitespace()
.map {
it.replace('_', ' ')
}

@ -38,6 +38,7 @@ internal abstract class MangaFireParser(
SortOrder.RATING,
SortOrder.NEWEST,
SortOrder.ALPHABETICAL,
SortOrder.RELEVANCE,
)
override fun onCreateConfig(keys: MutableCollection<ConfigKey<*>>) {
@ -91,7 +92,10 @@ internal abstract class MangaFireParser(
when {
!filter.query.isNullOrEmpty() -> {
addQueryParameter("keyword", filter.query.space2plus())
val encodedQuery = filter.query.splitByWhitespace().joinToString(separator = "+") { part ->
part.urlEncoded()
}
addEncodedQueryParameter("keyword", encodedQuery)
addQueryParameter(
name = "sort",
value = when (order) {
@ -100,6 +104,7 @@ internal abstract class MangaFireParser(
SortOrder.RATING -> "scores"
SortOrder.NEWEST -> "release_date"
SortOrder.ALPHABETICAL -> "title_az"
SortOrder.RELEVANCE -> "most_relevance"
else -> ""
},
)
@ -135,6 +140,7 @@ internal abstract class MangaFireParser(
SortOrder.RATING -> "scores"
SortOrder.NEWEST -> "release_date"
SortOrder.ALPHABETICAL -> "title_az"
SortOrder.RELEVANCE -> "most_relevance"
else -> ""
},
)

@ -105,7 +105,7 @@ public fun String.urlDecode(): String = URLDecoder.decode(this, Charsets.UTF_8.n
public fun String.nl2br(): String = replace("\n", "<br>")
public fun String.space2plus(): String = trim().replace(REGEX_WHITESPACE, "+")
public fun String.splitByWhitespace(): List<String> = trim().split(REGEX_WHITESPACE)
public fun ByteArray.byte2HexFormatted(): String {
val str = StringBuilder(size * 2)

@ -4,6 +4,7 @@ import okhttp3.Cookie
import okhttp3.CookieJar
import okhttp3.HttpUrl
import org.koitharu.kotatsu.parsers.util.insertCookie
import org.koitharu.kotatsu.parsers.util.splitByWhitespace
import org.koitharu.kotatsu.test_util.component6
import org.koitharu.kotatsu.test_util.component7
import java.io.InputStream
@ -32,7 +33,7 @@ class InMemoryCookieJar : CookieJar {
if (line.isBlank() || line.startsWith("# ")) {
continue
}
val (host, _, path, secure, expire, name, value) = line.split(Regex("\\s+"))
val (host, _, path, secure, expire, name, value) = line.splitByWhitespace()
val domain = host.removePrefix("#HttpOnly_").trimStart('.')
val httpOnly = host.startsWith("#HttpOnly_")
val cookie = Cookie.Builder()

Loading…
Cancel
Save