From 23a4a22ad1feae934c534a09e58ba135d48b7341 Mon Sep 17 00:00:00 2001 From: Cuong-Tran Date: Fri, 6 Dec 2024 03:48:08 +0700 Subject: [PATCH] snowmtl: fix image intercept (#6474) * fix image intercept * bump version --- src/en/snowmtl/build.gradle | 2 +- .../extension/en/snowmtl/ComposedImageInterceptor.kt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/en/snowmtl/build.gradle b/src/en/snowmtl/build.gradle index 9cebf299c..31905f7a7 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 = 1 + extVersionCode = 2 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 b5113c27c..76ae000cf 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 @@ -48,7 +48,7 @@ class ComposedImageInterceptor( val request = chain.request() val url = request.url.toString() - val isPageImageUrl = url.contains("storage.${baseUrl.substringAfterLast("/")}", true) + val isPageImageUrl = url.contains("${baseUrl.substringAfterLast("/")}/storage/", true) if (isPageImageUrl.not()) { return chain.proceed(request) } @@ -84,7 +84,10 @@ class ComposedImageInterceptor( val output = ByteArrayOutputStream() - val format = when (url.substringAfterLast(".").lowercase()) { + val ext = url.substringBefore("#") + .substringAfterLast(".") + .lowercase() + val format = when (ext) { "png" -> Bitmap.CompressFormat.PNG "jpeg", "jpg" -> Bitmap.CompressFormat.JPEG else -> Bitmap.CompressFormat.WEBP