From 6a390b749c274f35244e13630684f03723d8f7ca Mon Sep 17 00:00:00 2001 From: seew3l <90949336+seew3l@users.noreply.github.com> Date: Fri, 28 Apr 2023 20:52:20 -0500 Subject: [PATCH] LeerCapitulo: Fix index out of bound (#16211) * Fix index * Deobfuscating this was hard --- src/es/leercapitulo/build.gradle | 2 +- .../extension/es/leercapitulo/LeerCapitulo.kt | 21 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/es/leercapitulo/build.gradle b/src/es/leercapitulo/build.gradle index c678292da..5c9dcfd43 100644 --- a/src/es/leercapitulo/build.gradle +++ b/src/es/leercapitulo/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'LeerCapitulo / OlympusScan.top' pkgNameSuffix = 'es.leercapitulo' extClass = '.LeerCapitulo' - extVersionCode = 3 + extVersionCode = 4 } apply from: "$rootDir/common.gradle" \ No newline at end of file diff --git a/src/es/leercapitulo/src/eu/kanade/tachiyomi/extension/es/leercapitulo/LeerCapitulo.kt b/src/es/leercapitulo/src/eu/kanade/tachiyomi/extension/es/leercapitulo/LeerCapitulo.kt index 255977244..6d68896b3 100644 --- a/src/es/leercapitulo/src/eu/kanade/tachiyomi/extension/es/leercapitulo/LeerCapitulo.kt +++ b/src/es/leercapitulo/src/eu/kanade/tachiyomi/extension/es/leercapitulo/LeerCapitulo.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.extension.es.leercapitulo import android.app.Application +import android.util.Base64 import androidx.preference.ListPreference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.extension.es.leercapitulo.dto.MangaDto @@ -22,6 +23,7 @@ import org.jsoup.nodes.Element import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy +import java.nio.charset.Charset import kotlin.random.Random class LeerCapitulo : ParsedHttpSource(), ConfigurableSource { @@ -147,14 +149,23 @@ class LeerCapitulo : ParsedHttpSource(), ConfigurableSource { // Pages override fun pageListParse(document: Document): List { - val order = document.selectFirst("meta[property=ad:check]")?.attr("content") + val orderList = document.selectFirst("meta[property=ad:check]")?.attr("content") ?.replace("[^\\d]+".toRegex(), "-") ?.split("-") - val urls = document.selectFirst("#arraydata")!!.text().split(',') - val sortedUrl = order?.map { urls[it.toInt()] } ?: urls - return sortedUrl.mapIndexed { i, image_url -> - Page(i, imageUrl = image_url.replace("https://cdn.statically.io/img/", "https://")) // just redirects + val arrayData = document.selectFirst("#arraydata")!!.text() + + val encodedUrls = arrayData.replace(Regex("[A-Z0-9]", RegexOption.IGNORE_CASE)) { + val index = "BoevQJylkhcAxZVb4sXTgfaHu3zr7tP61L9qGNUmCpYKREdijD28OSwWInF5M0".indexOf(it.value) + "GQiMUkPrKIgpzVcu87AY4LnvO2a0oBy9JFbRhSx6qdfme5wZsEWlT1CN3XjDHt"[index].toString() + } + + val urlList = String(Base64.decode(encodedUrls, Base64.DEFAULT), Charset.forName("UTF-8")).split(",") + + val sortedUrls = orderList?.map { urlList[it.reversed().toInt()] }?.reversed() ?: urlList + + return sortedUrls.mapIndexed { i, image_url -> + Page(i, imageUrl = image_url) } }