[RU]LibGroup fix search (#12145)
This commit is contained in:
parent
a07efca470
commit
3cf9affb8f
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue