From b99fc8af0d9df6e8a6af0e6671add68c86a0d8e3 Mon Sep 17 00:00:00 2001 From: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:29:53 +0500 Subject: [PATCH] MangaPro: deproxify images (#4533) * MangaPro: deproxify images * remove log --- src/ar/mangapro/build.gradle | 2 +- .../extension/ar/mangapro/MangaPro.kt | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/ar/mangapro/build.gradle b/src/ar/mangapro/build.gradle index f1dca75d0..6d8604ea4 100644 --- a/src/ar/mangapro/build.gradle +++ b/src/ar/mangapro/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.MangaPro' themePkg = 'mangathemesia' baseUrl = 'https://promanga.pro' - overrideVersionCode = 2 + overrideVersionCode = 3 } apply from: "$rootDir/common.gradle" diff --git a/src/ar/mangapro/src/eu/kanade/tachiyomi/extension/ar/mangapro/MangaPro.kt b/src/ar/mangapro/src/eu/kanade/tachiyomi/extension/ar/mangapro/MangaPro.kt index 770597b18..dc85e6a4d 100644 --- a/src/ar/mangapro/src/eu/kanade/tachiyomi/extension/ar/mangapro/MangaPro.kt +++ b/src/ar/mangapro/src/eu/kanade/tachiyomi/extension/ar/mangapro/MangaPro.kt @@ -1,6 +1,9 @@ package eu.kanade.tachiyomi.extension.ar.mangapro import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia +import eu.kanade.tachiyomi.source.model.Page +import okhttp3.HttpUrl.Companion.toHttpUrl +import org.jsoup.nodes.Document import java.text.SimpleDateFormat import java.util.Locale @@ -11,4 +14,30 @@ class MangaPro : MangaThemesia( dateFormat = SimpleDateFormat("MMMM dd, yyyy", Locale("ar")), ) { override val versionId = 3 + + override fun pageListParse(document: Document): List { + return super.pageListParse(document).onEach { + val httpUrl = it.imageUrl!!.toHttpUrl() + + if (wpImgRegex.containsMatchIn(httpUrl.host)) { + it.imageUrl = StringBuilder().apply { + val ssl = httpUrl.queryParameter("ssl") + when (ssl) { + null -> append(httpUrl.scheme) + "0" -> append("http") + else -> append("https") + } + append("://") + append(httpUrl.pathSegments.joinToString("/")) + val search = httpUrl.queryParameter("q") + if (search != null) { + append("?q=") + append(search) + } + }.toString() + } + } + } } + +private val wpImgRegex = Regex("""i\d+\.wp\.com""")