fix mangakawaii page & add rate limiter (#5747)

This commit is contained in:
Riztard Lanthorn 2021-02-11 02:02:08 +07:00 committed by GitHub
parent 5aa044e426
commit 6573aa9361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -5,8 +5,12 @@ ext {
extName = 'Mangakawaii'
pkgNameSuffix = 'fr.mangakawaii'
extClass = '.MangaKawaii'
extVersionCode = 18
extVersionCode = 19
libVersion = '1.2'
}
dependencies {
implementation project(':lib-ratelimit')
}
apply from: "$rootDir/common.gradle"

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.extension.fr.mangakawaii
import android.net.Uri
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
@ -16,6 +17,7 @@ import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.concurrent.TimeUnit
class MangaKawaii : ParsedHttpSource() {
@ -23,7 +25,13 @@ class MangaKawaii : ParsedHttpSource() {
override val baseUrl = "https://www.mangakawaii.com"
override val lang = "fr"
override val supportsLatest = true
override val client: OkHttpClient = network.cloudflareClient
private val rateLimitInterceptor = RateLimitInterceptor(1) // 1 request per second
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.addNetworkInterceptor(rateLimitInterceptor)
.build()
override fun headersBuilder(): Headers.Builder {
return Headers.Builder().add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0")
}
@ -100,7 +108,7 @@ class MangaKawaii : ParsedHttpSource() {
override fun pageListParse(response: Response): List<Page> {
val body = response.asJsoup()
var div = body.select("div.text-center div:has(img[data-src*=/serv-manga/][alt*=page])")
var div = body.select("div.text-center div[id*='']:has(img[data-src*=/serv-manga/][alt*=page])")
var elements = div.select("img")
val pages = mutableListOf<Page>()