From 24e5d03a62f75575e1fb29db84abebf48bb0a0b8 Mon Sep 17 00:00:00 2001 From: beerpsi <92439990+beerpiss@users.noreply.github.com> Date: Sat, 28 Jan 2023 19:36:58 +0700 Subject: [PATCH] [ImmortalUpdates] Update descrambling logic (#15157) * [ImmortalUpdates] Update descrambling logic * Bump version --- .../immortalupdates/src/ImmortalUpdates.kt | 33 ++++++++++--------- .../multisrc/madara/MadaraGenerator.kt | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/multisrc/overrides/madara/immortalupdates/src/ImmortalUpdates.kt b/multisrc/overrides/madara/immortalupdates/src/ImmortalUpdates.kt index 278813c8e..a354faa8b 100644 --- a/multisrc/overrides/madara/immortalupdates/src/ImmortalUpdates.kt +++ b/multisrc/overrides/madara/immortalupdates/src/ImmortalUpdates.kt @@ -11,6 +11,7 @@ import android.graphics.Rect import app.cash.quickjs.QuickJs import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.source.model.Page import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType.Companion.toMediaTypeOrNull @@ -23,21 +24,23 @@ class ImmortalUpdates : Madara("Immortal Updates", "https://immortalupdates.com" override val useNewChapterEndpoint: Boolean = true - override val client = super.client.newBuilder().addInterceptor { chain -> - val response = chain.proceed(chain.request()) + override val client = super.client.newBuilder() + .rateLimit(1, 2) + .addInterceptor { chain -> + val response = chain.proceed(chain.request()) - if (response.request.url.fragment?.contains(DESCRAMBLE) != true) { - return@addInterceptor response - } - val fragment = response.request.url.fragment!! - val args = fragment.substringAfter("$DESCRAMBLE=").split(",") + if (response.request.url.fragment?.contains(DESCRAMBLE) != true) { + return@addInterceptor response + } + val fragment = response.request.url.fragment!! + val args = fragment.substringAfter("$DESCRAMBLE=").split(",") - val image = unscrambleImage(response.body!!.byteStream(), args) - val body = image.toResponseBody("image/jpeg".toMediaTypeOrNull()) - return@addInterceptor response.newBuilder() - .body(body) - .build() - }.build() + val image = unscrambleImage(response.body!!.byteStream(), args) + val body = image.toResponseBody("image/jpeg".toMediaTypeOrNull()) + return@addInterceptor response.newBuilder() + .body(body) + .build() + }.build() override fun pageListParse(document: Document): List { val pageList = super.pageListParse(document).toMutableList() @@ -51,11 +54,11 @@ class ImmortalUpdates : Madara("Immortal Updates", "https://immortalupdates.com" unscramblingCalls.replace("\r", "").split("\n").forEach { val args = unfuckJs(it) - .substringAfter("(") + .substringAfter("get_img(") .substringBefore(")") val filenameFragment = args.split(",")[0].removeSurrounding("'") - val page = pageList.firstOrNull { it.imageUrl!!.contains(filenameFragment, ignoreCase = true) } + val page = pageList.firstOrNull { page -> page.imageUrl!!.contains(filenameFragment, ignoreCase = true) } ?: return@forEach val newPageUrl = page.imageUrl!!.toHttpUrl().newBuilder() .fragment("$DESCRAMBLE=$args") diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt index 78f778393..cf21d7587 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt @@ -146,7 +146,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("Ichirin No Hana Yuri", "https://ichirinnohanayuriscan.com", "pt-BR", isNsfw = true, overrideVersionCode = 4), SingleLang("Ikifeng", "https://ikifeng.com", "es", isNsfw = true), SingleLang("Illusion Scan", "https://illusionscan.com", "pt-BR", isNsfw = true), - SingleLang("Immortal Updates", "https://immortalupdates.com", "en", overrideVersionCode = 4), + SingleLang("Immortal Updates", "https://immortalupdates.com", "en", overrideVersionCode = 5), SingleLang("Império Scans", "https://imperioscans.com.br", "pt-BR", className = "ImperioScans", overrideVersionCode = 1), SingleLang("Inazu Manga", "https://inazumanga.com", "id", isNsfw = true), SingleLang("InfraFandub", "https://infrafandub.xyz", "es"),