snowmtl: fix image intercept (#6529)
This commit is contained in:
parent
7abb7e3c16
commit
e11aafbd0f
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Snow Machine Translations'
|
extName = 'Snow Machine Translations'
|
||||||
extClass = '.Snowmtl'
|
extClass = '.Snowmtl'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import kotlin.math.sqrt
|
||||||
// The Interceptor joins the captions and pages of the manga.
|
// The Interceptor joins the captions and pages of the manga.
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
class ComposedImageInterceptor(
|
class ComposedImageInterceptor(
|
||||||
private val baseUrl: String,
|
baseUrl: String,
|
||||||
private val client: OkHttpClient,
|
private val client: OkHttpClient,
|
||||||
) : Interceptor {
|
) : Interceptor {
|
||||||
|
|
||||||
|
@ -44,11 +44,16 @@ class ComposedImageInterceptor(
|
||||||
"normal" to Pair<String, Typeface?>("$baseUrl/images/normal.ttf", null),
|
"normal" to Pair<String, Typeface?>("$baseUrl/images/normal.ttf", null),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val imageRegex = Regex(
|
||||||
|
"$baseUrl.*?\\.(webp|png|jpg|jpeg)#\\[.*?]",
|
||||||
|
RegexOption.IGNORE_CASE,
|
||||||
|
)
|
||||||
|
|
||||||
override fun intercept(chain: Interceptor.Chain): Response {
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
val request = chain.request()
|
val request = chain.request()
|
||||||
val url = request.url.toString()
|
val url = request.url.toString()
|
||||||
|
|
||||||
val isPageImageUrl = url.contains("${baseUrl.substringAfterLast("/")}/storage/", true)
|
val isPageImageUrl = imageRegex.containsMatchIn(url)
|
||||||
if (isPageImageUrl.not()) {
|
if (isPageImageUrl.not()) {
|
||||||
return chain.proceed(request)
|
return chain.proceed(request)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue