diff --git a/src/ru/mangahub/build.gradle b/src/ru/mangahub/build.gradle index 0eaab1434..4fb721197 100644 --- a/src/ru/mangahub/build.gradle +++ b/src/ru/mangahub/build.gradle @@ -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" diff --git a/src/ru/mangahub/src/eu/kanade/tachiyomi/extension/ru/mangahub/Mangahub.kt b/src/ru/mangahub/src/eu/kanade/tachiyomi/extension/ru/mangahub/Mangahub.kt index 7d803d702..00e599e36 100644 --- a/src/ru/mangahub/src/eu/kanade/tachiyomi/extension/ru/mangahub/Mangahub.kt +++ b/src/ru/mangahub/src/eu/kanade/tachiyomi/extension/ru/mangahub/Mangahub.kt @@ -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()