From 1ff32938977d22ccf44d39c4a357ad5387c4f358 Mon Sep 17 00:00:00 2001 From: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:29:20 +0500 Subject: [PATCH] very cool (#16811) * very cool fix * more resilient probably --- src/en/reaperscans/build.gradle | 2 +- .../extension/en/reaperscans/ReaperScans.kt | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/en/reaperscans/build.gradle b/src/en/reaperscans/build.gradle index c1b893ba5..566bcdfd2 100644 --- a/src/en/reaperscans/build.gradle +++ b/src/en/reaperscans/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Reaper Scans' pkgNameSuffix = 'en.reaperscans' extClass = '.ReaperScans' - extVersionCode = 45 + extVersionCode = 46 } apply from: "$rootDir/common.gradle" diff --git a/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScans.kt b/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScans.kt index c5803073a..fce0d3b88 100644 --- a/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScans.kt +++ b/src/en/reaperscans/src/eu/kanade/tachiyomi/extension/en/reaperscans/ReaperScans.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.extension.en.reaperscans import android.util.Base64 +import android.util.Log import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.interceptor.rateLimit @@ -18,7 +19,6 @@ import kotlinx.serialization.json.add import kotlinx.serialization.json.addJsonObject import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.contentOrNull -import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive import kotlinx.serialization.json.put import kotlinx.serialization.json.putJsonArray @@ -290,7 +290,8 @@ class ReaperScans : ParsedHttpSource() { val routeName = livewareData.fingerprint["name"]?.jsonPrimitive?.contentOrNull ?: error("Couldn't find routeName") - val tunstileName = livewareData.serverMemo["data"]?.jsonObject?.keys?.firstOrNull { it != "chapter" } + val tunstileName = document.selectFirst("script:containsData(captchacallback)")?.html() + ?.let { tunstile.find(it)?.groupValues?.get(1) } ?: error("Couldn't fine Tunstile Name") // Javascript: (Math.random() + 1).toString(36).substring(8) @@ -322,7 +323,12 @@ class ReaperScans : ParsedHttpSource() { val liveWireResponse = client.newCall(liveWireRequest).execute() - val html = liveWireResponse.parseJson().effects.html + val html = runCatching { liveWireResponse.parseJson().effects.html } + .getOrElse { + Log.e(name, it.stackTraceToString()) + error("Fuck you Reaper Scans") + } + return Jsoup.parse(html, baseUrl).select("img").mapIndexed { idx, element -> Page(idx, imageUrl = element.imgAttr()) } @@ -400,5 +406,6 @@ class ReaperScans : ParsedHttpSource() { companion object { private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaType() const val PREFIX_ID_SEARCH = "id:" + private val tunstile by lazy { Regex("""set\s*\(\s*\"([^"]*)""") } } }