Fix mangahub.ru search (#1859)

Fix mangahub.ru search
This commit is contained in:
Pavka 2019-12-07 17:28:49 +03:00 committed by arkon
parent 8a84c691e4
commit e87d741c07
2 changed files with 22 additions and 4 deletions

View File

@ -5,8 +5,12 @@ ext {
appName = 'Tachiyomi: Mangahub'
pkgNameSuffix = 'ru.mangahub'
extClass = '.Mangahub'
extVersionCode = 4
extVersionCode = 5
libVersion = '1.2'
}
dependencies {
implementation project(':lib-ratelimit')
}
apply from: "$rootDir/common.gradle"

View File

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.extension.ru.mangahub
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page
@ -7,6 +8,7 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.Headers
import okhttp3.OkHttpClient
import okhttp3.Request
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
@ -23,6 +25,12 @@ open class Mangahub : ParsedHttpSource() {
override val supportsLatest = true
private val rateLimitInterceptor = RateLimitInterceptor(2)
override val client: OkHttpClient = network.client.newBuilder()
.addNetworkInterceptor(rateLimitInterceptor).build()
override fun popularMangaRequest(page: Int): Request =
GET("$baseUrl/explore?filter[sort]=rating&filter[dateStart][left_number]=1900&filter[dateStart][right_number]=2099&page=$page", headers)
@ -49,12 +57,18 @@ open class Mangahub : ParsedHttpSource() {
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
return GET("$baseUrl/search/manga?query=$query&sort=score&page=$page")
return GET("$baseUrl/search/manga?query=$query&sort=rating_short&page=$page")
}
override fun searchMangaSelector() = popularMangaSelector()
override fun searchMangaSelector() = "div.px-4"
override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element)
override fun searchMangaFromElement(element: Element): SManga {
val manga = SManga.create()
manga.thumbnail_url = element.select("div.fast-view-layer-scale").attr("data-background-image")
manga.title = element.select("a.h4").text()
manga.setUrlWithoutDomain(element.select("a.h4").attr("href"))
return manga
}
override fun searchMangaNextPageSelector(): String? = popularMangaNextPageSelector()