Mangas Chan: Fix Cloudflare block (#637)

* Mangas Chan: Fix Cloudflare block

* Add an interceptor to remove X-Requested-With

* use CharArray instead of List

Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>

---------

Co-authored-by: stevenyomi <95685115+stevenyomi@users.noreply.github.com>
This commit is contained in:
beerpsi 2024-01-26 01:39:09 +07:00 committed by Draff
parent d63bd90ef9
commit 01e27823f6
2 changed files with 17 additions and 1 deletions

View File

@ -15,12 +15,28 @@ class MangasChan : MangaThemesia(
) {
override val client: OkHttpClient = super.client.newBuilder()
.addInterceptor { chain ->
val request = chain.request()
val headers = request.headers.newBuilder()
.removeAll("X-Requested-With")
.build()
chain.proceed(request.newBuilder().headers(headers).build())
}
.rateLimit(1, 2, TimeUnit.SECONDS)
.build()
override fun headersBuilder() = super.headersBuilder()
.set("X-Requested-With", randomString((10..20).random()))
override val altNamePrefix = "Nomes alternativos: "
override val seriesArtistSelector = ".tsinfo .imptdt:contains(Artista) > i"
override val seriesAuthorSelector = ".tsinfo .imptdt:contains(Autor) > i"
override val seriesTypeSelector = ".tsinfo .imptdt:contains(Tipo) > a"
private fun randomString(length: Int): String {
val charPool = ('a'..'z') + ('A'..'Z')
return CharArray(length) { charPool.random() }.concatToString()
}
}

View File

@ -91,7 +91,7 @@ class MangaThemesiaGenerator : ThemeSourceGenerator {
SingleLang("MangaTale", "https://mangatale.co", "id", overrideVersionCode = 2),
SingleLang("MangaWT", "https://mangawt.com", "tr", overrideVersionCode = 5),
SingleLang("Mangayaro", "https://www.mangayaro.id", "id", overrideVersionCode = 1),
SingleLang("Mangás Chan", "https://mangaschan.net", "pt-BR", className = "MangasChan", overrideVersionCode = 2),
SingleLang("Mangás Chan", "https://mangaschan.net", "pt-BR", className = "MangasChan", overrideVersionCode = 3),
SingleLang("Mangás Online", "https://mangasonline.cc", "pt-BR", className = "MangasOnline"),
SingleLang("Manhwa Freak", "https://manhwa-freak.com", "en", overrideVersionCode = 3),
SingleLang("Manhwa Lover", "https://manhwalover.com", "en", isNsfw = true, overrideVersionCode = 1),