[RU]Newbie cloudflareClient (fix 403) (#14161)

This commit is contained in:
Eshlender 2022-11-07 23:00:10 +05:00 committed by GitHub
parent a3b612a940
commit 5e6a152da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'NewManga(Newbie)'
pkgNameSuffix = 'ru.newbie'
extClass = '.Newbie'
extVersionCode = 15
extVersionCode = 16
}
dependencies {

View File

@ -48,6 +48,8 @@ import java.text.DecimalFormat
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import kotlin.math.absoluteValue
import kotlin.random.Random
class Newbie : ConfigurableSource, HttpSource() {
override val name = "NewManga(Newbie)"
@ -66,8 +68,10 @@ class Newbie : ConfigurableSource, HttpSource() {
private var branches = mutableMapOf<String, List<BranchesDto>>()
private val userAgentRandomizer = "${Random.nextInt().absoluteValue}"
override fun headersBuilder(): Headers.Builder = Headers.Builder()
.add("User-Agent", "Tachiyomi " + System.getProperty("http.agent"))
.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.$userAgentRandomizer")
.add("Referer", baseUrl)
private fun imageContentTypeIntercept(chain: Interceptor.Chain): Response {
@ -81,7 +85,7 @@ class Newbie : ConfigurableSource, HttpSource() {
}
override val client: OkHttpClient =
network.client.newBuilder()
network.cloudflareClient.newBuilder()
.addInterceptor { imageContentTypeIntercept(it) }
.build()