Update MangáHost url. (#5952)

This commit is contained in:
Alessandro Jean 2021-02-21 15:02:00 -03:00 committed by GitHub
parent c95fa2be77
commit e72bb09d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -5,8 +5,12 @@ ext {
extName = 'MangaHost' extName = 'MangaHost'
pkgNameSuffix = 'pt.mangahost' pkgNameSuffix = 'pt.mangahost'
extClass = '.MangaHost' extClass = '.MangaHost'
extVersionCode = 16 extVersionCode = 17
libVersion = '1.2' libVersion = '1.2'
} }
dependencies {
implementation project(':lib-ratelimit')
}
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.extension.pt.mangahost package eu.kanade.tachiyomi.extension.pt.mangahost
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservable import eu.kanade.tachiyomi.network.asObservable
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
@ -20,6 +21,7 @@ import rx.Observable
import java.text.ParseException import java.text.ParseException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
import java.util.concurrent.TimeUnit
class MangaHost : ParsedHttpSource() { class MangaHost : ParsedHttpSource() {
@ -28,17 +30,21 @@ class MangaHost : ParsedHttpSource() {
override val name = "Mangá Host" override val name = "Mangá Host"
override val baseUrl = "https://mangahosted.com" override val baseUrl = "https://mangahostz.com"
override val lang = "pt-BR" override val lang = "pt-BR"
override val supportsLatest = true override val supportsLatest = true
override val client: OkHttpClient = network.cloudflareClient override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.addInterceptor(RateLimitInterceptor(3, 1, TimeUnit.SECONDS))
.build()
override fun headersBuilder(): Headers.Builder = Headers.Builder() override fun headersBuilder(): Headers.Builder = Headers.Builder()
.add("User-Agent", USER_AGENT) .add("Accept", ACCEPT)
.add("Accept-Language", ACCEPT_LANGUAGE)
.add("Referer", baseUrl) .add("Referer", baseUrl)
.add("User-Agent", USER_AGENT)
private fun genericMangaFromElement(element: Element): SManga = private fun genericMangaFromElement(element: Element): SManga =
SManga.create().apply { SManga.create().apply {
@ -212,8 +218,11 @@ class MangaHost : ParsedHttpSource() {
private fun Elements.textWithoutLabel(): String = text()!!.substringAfter(":").trim() private fun Elements.textWithoutLabel(): String = text()!!.substringAfter(":").trim()
companion object { companion object {
private const val ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9," +
"image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,es;q=0.6,gl;q=0.5"
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"
private val LANG_REGEX = "( )?\\((PT-)?BR\\)".toRegex() private val LANG_REGEX = "( )?\\((PT-)?BR\\)".toRegex()
private val IMAGE_REGEX = "_(small|medium|xmedium)\\.".toRegex() private val IMAGE_REGEX = "_(small|medium|xmedium)\\.".toRegex()