[Mangadex] Exclude thumbnail downloads from rate limiting (#5542)

* Exclude thumbnails from mangadex rate limiting

* Remove development code

* Bump mangadex extVersionCode
This commit is contained in:
Unlocked 2021-01-24 10:44:45 -08:00 committed by GitHub
parent 04db6981aa
commit 0293fbc547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaDex' extName = 'MangaDex'
pkgNameSuffix = 'all.mangadex' pkgNameSuffix = 'all.mangadex'
extClass = '.MangaDexFactory' extClass = '.MangaDexFactory'
extVersionCode = 102 extVersionCode = 103
libVersion = '1.2' libVersion = '1.2'
containsNsfw = true containsNsfw = true
} }

View File

@ -71,7 +71,7 @@ abstract class MangaDex(
MangadexDescription(internalLang) MangadexDescription(internalLang)
} }
private val rateLimitInterceptor = RateLimitInterceptor(1) private val rateLimitInterceptor = MdRateLimitInterceptor()
override val client: OkHttpClient = network.client.newBuilder() override val client: OkHttpClient = network.client.newBuilder()
.addNetworkInterceptor(rateLimitInterceptor) .addNetworkInterceptor(rateLimitInterceptor)
@ -1082,6 +1082,17 @@ class CoverInterceptor : Interceptor {
} }
} }
class MdRateLimitInterceptor : Interceptor {
private val coverRegex = Regex("""/images/.*\.jpg""")
private val baseInterceptor = RateLimitInterceptor(1)
override fun intercept(chain: Interceptor.Chain): Response =
if (chain.request().url().toString().contains(coverRegex))
chain.proceed(chain.request())
else
baseInterceptor.intercept(chain)
}
class MdAtHomeReportInterceptor( class MdAtHomeReportInterceptor(
private val client: OkHttpClient, private val client: OkHttpClient,
private val headers: Headers private val headers: Headers