Attempt to bypass Cloudflare at NS. (#7252)

This commit is contained in:
Alessandro Jean 2021-05-27 13:47:03 -03:00 committed by GitHub
parent bee381f0e6
commit a603e15b50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 5 deletions

View File

@ -2,12 +2,15 @@ package eu.kanade.tachiyomi.extension.pt.neoxscanlator
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservable
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SManga
import okhttp3.Headers
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import rx.Observable
import java.lang.Exception
@ -21,15 +24,17 @@ class NeoxScanlator : Madara(
"pt-BR",
SimpleDateFormat("dd/MM/yyyy", Locale("pt", "BR"))
) {
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.addInterceptor(RateLimitInterceptor(1, 1, TimeUnit.SECONDS))
.addInterceptor(RateLimitInterceptor(1, 2, TimeUnit.SECONDS))
.build()
override fun headersBuilder(): Headers.Builder = Headers.Builder()
.add("Referer", baseUrl)
.add("Origin", baseUrl)
override fun headersBuilder(): Headers.Builder = super.headersBuilder()
.add("Accept", ACCEPT)
.add("Accept-Language", ACCEPT_LANGUAGE)
.add("Referer", REFERER)
// Filter the novels in pure text format.
override fun popularMangaSelector() = "div.page-item-detail.manga"
@ -59,8 +64,18 @@ class NeoxScanlator : Madara(
}
override val altNameSelector = ".post-content_item:contains(Alternativo) .summary-content"
override val altName = "Nome alternativo: "
override fun imageRequest(page: Page): Request {
val newHeaders = headersBuilder()
.set("Accept", ACCEPT_IMAGE)
.set("Referer", page.url)
.build()
return GET(page.imageUrl!!, newHeaders)
}
// Only status and order by filter work.
override fun getFilterList(): FilterList = FilterList(super.getFilterList().slice(3..4))
@ -68,6 +83,12 @@ class NeoxScanlator : Madara(
private const val MIGRATION_MESSAGE = "O URL deste mangá mudou. " +
"Faça a migração do Neox para o Neox para atualizar a URL."
private const val ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9," +
"image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
private const val ACCEPT_IMAGE = "image/webp,image/apng,image/*,*/*;q=0.8"
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 REFERER = "https://google.com/"
private val NOVEL_REGEX = "novel|livro".toRegex(RegexOption.IGNORE_CASE)
}
}

View File

@ -186,7 +186,7 @@ class MadaraGenerator : ThemeSourceGenerator {
SingleLang("Nazarick Scans", "https://nazarickscans.com", "en"),
SingleLang("NeatManga", "https://neatmanga.com", "en"),
SingleLang("NekoScan", "https://nekoscan.com", "en", overrideVersionCode = 1),
SingleLang("Neox Scanlator", "https://neoxscans.net", "pt-BR", overrideVersionCode = 3),
SingleLang("Neox Scanlator", "https://neoxscans.net", "pt-BR", overrideVersionCode = 4),
SingleLang("Night Comic", "https://www.nightcomic.com", "en"),
SingleLang("Niji Translations", "https://niji-translations.com", "ar"),
SingleLang("Ninjavi", "https://ninjavi.com", "ar", overrideVersionCode = 1),