From e11aafbd0fb4c9f14492702100c6cb1bc8d35032 Mon Sep 17 00:00:00 2001 From: Cuong-Tran Date: Sun, 8 Dec 2024 20:14:17 +0700 Subject: [PATCH] snowmtl: fix image intercept (#6529) --- src/en/snowmtl/build.gradle | 2 +- .../extension/en/snowmtl/ComposedImageInterceptor.kt | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/en/snowmtl/build.gradle b/src/en/snowmtl/build.gradle index 31905f7a7..c8ec77737 100644 --- a/src/en/snowmtl/build.gradle +++ b/src/en/snowmtl/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Snow Machine Translations' extClass = '.Snowmtl' - extVersionCode = 2 + extVersionCode = 3 isNsfw = true } diff --git a/src/en/snowmtl/src/eu/kanade/tachiyomi/extension/en/snowmtl/ComposedImageInterceptor.kt b/src/en/snowmtl/src/eu/kanade/tachiyomi/extension/en/snowmtl/ComposedImageInterceptor.kt index 76ae000cf..31d7b5556 100644 --- a/src/en/snowmtl/src/eu/kanade/tachiyomi/extension/en/snowmtl/ComposedImageInterceptor.kt +++ b/src/en/snowmtl/src/eu/kanade/tachiyomi/extension/en/snowmtl/ComposedImageInterceptor.kt @@ -32,7 +32,7 @@ import kotlin.math.sqrt // The Interceptor joins the captions and pages of the manga. @RequiresApi(Build.VERSION_CODES.O) class ComposedImageInterceptor( - private val baseUrl: String, + baseUrl: String, private val client: OkHttpClient, ) : Interceptor { @@ -44,11 +44,16 @@ class ComposedImageInterceptor( "normal" to Pair("$baseUrl/images/normal.ttf", null), ) + private val imageRegex = Regex( + "$baseUrl.*?\\.(webp|png|jpg|jpeg)#\\[.*?]", + RegexOption.IGNORE_CASE, + ) + override fun intercept(chain: Interceptor.Chain): Response { val request = chain.request() val url = request.url.toString() - val isPageImageUrl = url.contains("${baseUrl.substringAfterLast("/")}/storage/", true) + val isPageImageUrl = imageRegex.containsMatchIn(url) if (isPageImageUrl.not()) { return chain.proceed(request) }