Explicit cloudflareClient if Cloudflare hosted (#6613)

* Explicit cloudflareClient if Cloudflare hosted

* avoid modifying multisrc sources
This commit is contained in:
Vetle Ledaal 2024-12-18 03:43:39 +01:00 committed by Draff
parent c432620356
commit 8b212ffdcd
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
22 changed files with 26 additions and 18 deletions

View File

@ -2,4 +2,4 @@ plugins {
id("lib-multisrc") id("lib-multisrc")
} }
baseVersionCode = 3 baseVersionCode = 4

View File

@ -37,6 +37,8 @@ abstract class BlogTruyen(
override val supportsLatest = true override val supportsLatest = true
override val client = network.cloudflareClient
override fun headersBuilder() = super.headersBuilder() override fun headersBuilder() = super.headersBuilder()
.add("Referer", "$baseUrl/") .add("Referer", "$baseUrl/")

View File

@ -2,7 +2,7 @@ plugins {
id("lib-multisrc") id("lib-multisrc")
} }
baseVersionCode = 28 baseVersionCode = 29
dependencies { dependencies {
api(project(":lib:randomua")) api(project(":lib:randomua"))

View File

@ -50,7 +50,7 @@ abstract class MangaHub(
private var baseApiUrl = "https://api.mghcdn.com" private var baseApiUrl = "https://api.mghcdn.com"
private var baseCdnUrl = "https://imgx.mghcdn.com" private var baseCdnUrl = "https://imgx.mghcdn.com"
override val client: OkHttpClient = super.client.newBuilder() override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.setRandomUserAgent( .setRandomUserAgent(
userAgentType = UserAgentType.DESKTOP, userAgentType = UserAgentType.DESKTOP,
filterInclude = listOf("chrome"), filterInclude = listOf("chrome"),

View File

@ -2,7 +2,7 @@ plugins {
id("lib-multisrc") id("lib-multisrc")
} }
baseVersionCode = 11 baseVersionCode = 12
dependencies { dependencies {
api(project(":lib:i18n")) api(project(":lib:i18n"))

View File

@ -67,6 +67,8 @@ constructor(
override val supportsLatest = true override val supportsLatest = true
override val client = network.cloudflareClient
override fun headersBuilder() = super.headersBuilder() override fun headersBuilder() = super.headersBuilder()
.add("Referer", "$baseUrl/") .add("Referer", "$baseUrl/")

View File

@ -2,4 +2,4 @@ plugins {
id("lib-multisrc") id("lib-multisrc")
} }
baseVersionCode = 2 baseVersionCode = 3

View File

@ -29,6 +29,8 @@ abstract class PizzaReader(
override val supportsLatest = true override val supportsLatest = true
override val client = network.cloudflareClient
open val apiUrl by lazy { "$baseUrl$apiPath" } open val apiUrl by lazy { "$baseUrl$apiPath" }
protected open val json: Json by injectLazy() protected open val json: Json by injectLazy()

View File

@ -2,4 +2,4 @@ plugins {
id("lib-multisrc") id("lib-multisrc")
} }
baseVersionCode = 9 baseVersionCode = 10

View File

@ -27,6 +27,8 @@ abstract class ZeistManga(
override val supportsLatest = true override val supportsLatest = true
override val client = network.cloudflareClient
protected val json: Json by injectLazy() protected val json: Json by injectLazy()
private val intl by lazy { ZeistMangaIntl(lang) } private val intl by lazy { ZeistMangaIntl(lang) }

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Cubari' extName = 'Cubari'
extClass = '.CubariFactory' extClass = '.CubariFactory'
extVersionCode = 24 extVersionCode = 25
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -38,7 +38,7 @@ open class Cubari(override val lang: String) : HttpSource() {
private val json: Json by injectLazy() private val json: Json by injectLazy()
override val client = super.client.newBuilder() override val client = network.cloudflareClient.newBuilder()
.addInterceptor { chain -> .addInterceptor { chain ->
val request = chain.request() val request = chain.request()
val headers = request.headers.newBuilder() val headers = request.headers.newBuilder()

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Flame Comics' extName = 'Flame Comics'
extClass = '.FlameComics' extClass = '.FlameComics'
extVersionCode = 37 extVersionCode = 38
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -36,7 +36,7 @@ class FlameComics : HttpSource() {
private val json: Json by injectLazy() private val json: Json by injectLazy()
override val client = super.client.newBuilder() override val client = network.cloudflareClient.newBuilder()
.rateLimit(2, 7) .rateLimit(2, 7)
.addInterceptor(::buildIdOutdatedInterceptor) .addInterceptor(::buildIdOutdatedInterceptor)
.addInterceptor(::composedImageIntercept) .addInterceptor(::composedImageIntercept)

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Olympus Scanlation' extName = 'Olympus Scanlation'
extClass = '.OlympusScanlation' extClass = '.OlympusScanlation'
extVersionCode = 11 extVersionCode = 12
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -32,7 +32,7 @@ class OlympusScanlation : HttpSource() {
override val supportsLatest: Boolean = true override val supportsLatest: Boolean = true
override val client = super.client.newBuilder() override val client = network.cloudflareClient.newBuilder()
.rateLimitHost(baseUrl.toHttpUrl(), 1, 2) .rateLimitHost(baseUrl.toHttpUrl(), 1, 2)
.rateLimitHost(apiBaseUrl.toHttpUrl(), 2, 1) .rateLimitHost(apiBaseUrl.toHttpUrl(), 2, 1)
.build() .build()

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'TMOHentai' extName = 'TMOHentai'
extClass = '.TMOHentai' extClass = '.TMOHentai'
extVersionCode = 8 extVersionCode = 9
isNsfw = true isNsfw = true
} }

View File

@ -34,7 +34,7 @@ class TMOHentai : ConfigurableSource, ParsedHttpSource() {
override val supportsLatest = true override val supportsLatest = true
override val client: OkHttpClient = super.client.newBuilder() override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.rateLimitHost(baseUrl.toHttpUrl(), 1, 2) .rateLimitHost(baseUrl.toHttpUrl(), 1, 2)
.build() .build()

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'HentaiArchive' extName = 'HentaiArchive'
extClass = '.HentaiArchive' extClass = '.HentaiArchive'
extVersionCode = 1 extVersionCode = 2
isNsfw = true isNsfw = true
} }

View File

@ -25,7 +25,7 @@ class HentaiArchive : ParsedHttpSource() {
.add("Referer", "$baseUrl/") .add("Referer", "$baseUrl/")
.build() .build()
override val client = super.client.newBuilder() override val client = network.cloudflareClient.newBuilder()
.addInterceptor { chain -> .addInterceptor { chain ->
val request = chain.request() val request = chain.request()
val url = request.url.toString() val url = request.url.toString()

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Sen Manga' extName = 'Sen Manga'
extClass = '.SenManga' extClass = '.SenManga'
extVersionCode = 6 extVersionCode = 7
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -24,7 +24,7 @@ class SenManga : ParsedHttpSource() {
override val baseUrl = "https://raw.senmanga.com" override val baseUrl = "https://raw.senmanga.com"
@SuppressLint("DefaultLocale") @SuppressLint("DefaultLocale")
override val client = super.client.newBuilder().addInterceptor { override val client = network.cloudflareClient.newBuilder().addInterceptor {
// Intercept any image requests and add a referer to them // Intercept any image requests and add a referer to them
// Enables bandwidth stealing feature // Enables bandwidth stealing feature
val request = if (it.request().url.pathSegments.firstOrNull()?.trim()?.lowercase() == "viewer") { val request = if (it.request().url.pathSegments.firstOrNull()?.trim()?.lowercase() == "viewer") {