[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'
pkgNameSuffix = 'all.mangadex'
extClass = '.MangaDexFactory'
extVersionCode = 102
extVersionCode = 103
libVersion = '1.2'
containsNsfw = true
}

View File

@ -71,7 +71,7 @@ abstract class MangaDex(
MangadexDescription(internalLang)
}
private val rateLimitInterceptor = RateLimitInterceptor(1)
private val rateLimitInterceptor = MdRateLimitInterceptor()
override val client: OkHttpClient = network.client.newBuilder()
.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(
private val client: OkHttpClient,
private val headers: Headers