[RU]LibGroup fix search (#12145)

This commit is contained in:
Ejan 2022-06-10 03:21:33 +05:00 committed by GitHub
parent a07efca470
commit 3cf9affb8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 35 deletions

View File

@ -9,7 +9,7 @@ class LibGenerator: ThemeSourceGenerator {
override val themeClass = "LibGroup"
override val baseVersionCode: Int = 1
override val baseVersionCode: Int = 2
override val sources = listOf(
SingleLang("MangaLib", "https://mangalib.me", "ru", overrideVersionCode = 74),

View File

@ -532,40 +532,7 @@ abstract class LibGroup(
return POST(url.toString(), catalogHeaders())
}
// Hack search method to add some results from search popup
override fun searchMangaParse(response: Response): MangasPage {
val searchRequest = response.request.url.queryParameter("name")
val mangas = mutableListOf<SManga>()
if (!searchRequest.isNullOrEmpty()) {
val popupSearchHeaders = headers
.newBuilder()
.add("Accept", "application/json, text/plain, */*")
.add("X-Requested-With", "XMLHttpRequest")
.build()
// +200ms
val popup = client.newCall(
GET("$baseUrl/search?query=$searchRequest", popupSearchHeaders)
)
.execute().body!!.string()
val jsonList = json.decodeFromString<JsonArray>(popup)
jsonList.forEach {
mangas.add(popularMangaFromElement(it))
}
}
val searchedMangas = popularMangaParse(response)
// Filtered out what find in popup search
mangas.addAll(
searchedMangas.mangas.filter { search ->
mangas.find { search.title == it.title } == null
}
)
return MangasPage(mangas, searchedMangas.hasNextPage)
}
override fun searchMangaParse(response: Response): MangasPage = popularMangaParse(response)
// Filters
private class SearchFilter(name: String, val id: String) : Filter.TriState(name)