Comicpunch - fix search (#3593)

This commit is contained in:
Mike 2020-06-22 15:49:43 -04:00 committed by GitHub
parent b1c7da697e
commit 38a9cd8808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 18 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Comicpunch' appName = 'Tachiyomi: Comicpunch'
pkgNameSuffix = 'en.comicpunch' pkgNameSuffix = 'en.comicpunch'
extClass = '.Comicpunch' extClass = '.Comicpunch'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.extension.en.comicpunch package eu.kanade.tachiyomi.extension.en.comicpunch
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
@ -13,6 +14,7 @@ import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import rx.Observable
class Comicpunch : ParsedHttpSource() { class Comicpunch : ParsedHttpSource() {
@ -63,32 +65,31 @@ class Comicpunch : ParsedHttpSource() {
// Search // Search
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
return client.newCall(searchMangaRequest(page, query, filters))
.asObservableSuccess()
.map { response ->
searchMangaParse(response, query)
}
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
return GET("$baseUrl/search/node/$query?page=${page - 1}", headers) return GET("$baseUrl/comics-list", headers)
} }
override fun searchMangaParse(response: Response): MangasPage { private fun searchMangaParse(response: Response, query: String): MangasPage {
val mangas = mutableListOf<SManga>() val mangas = response.asJsoup().select(searchMangaSelector())
val document = response.asJsoup() .filter { it.text().contains(query, ignoreCase = true) }
.map { searchMangaFromElement(it) }
document.select(searchMangaSelector()) return MangasPage(mangas, false)
.asSequence()
.filterNot { it.attr("href").contains("/comic/") }
.filterNot { it.attr("href").contains("/asiancomics/") }
.filterNot { it.attr("href").contains("/latest-issues") }
.filterNot { it.attr("href").contains("$baseUrl/latest-issues") }
.filterNot { it.attr("href").contains("$baseUrl/newest-issues") }
.map { mangas.add(searchMangaFromElement(it)) }
.toList()
return MangasPage(mangas, document.select(searchMangaNextPageSelector()).isNotEmpty())
} }
override fun searchMangaSelector() = "li.search-result h3 a" override fun searchMangaSelector() = "table.cols-2 td a"
override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element) override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element)
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() override fun searchMangaNextPageSelector() = throw UnsupportedOperationException("Not used")
// Details // Details