From 885d951788d1c1ce05e63fdc8a3d34718e7dffdc Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:43:16 -0500 Subject: [PATCH] MNS: Change chapters action (#2326) Fix --- src/es/mangasnosekai/build.gradle | 2 +- .../extension/es/mangasnosekai/MangasNoSekai.kt | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/es/mangasnosekai/build.gradle b/src/es/mangasnosekai/build.gradle index dad357f05..0b746e324 100644 --- a/src/es/mangasnosekai/build.gradle +++ b/src/es/mangasnosekai/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.MangasNoSekai' themePkg = 'madara' baseUrl = 'https://mangasnosekai.com' - overrideVersionCode = 8 + overrideVersionCode = 9 } apply from: "$rootDir/common.gradle" diff --git a/src/es/mangasnosekai/src/eu/kanade/tachiyomi/extension/es/mangasnosekai/MangasNoSekai.kt b/src/es/mangasnosekai/src/eu/kanade/tachiyomi/extension/es/mangasnosekai/MangasNoSekai.kt index 6ff2ab505..3a2e0083a 100644 --- a/src/es/mangasnosekai/src/eu/kanade/tachiyomi/extension/es/mangasnosekai/MangasNoSekai.kt +++ b/src/es/mangasnosekai/src/eu/kanade/tachiyomi/extension/es/mangasnosekai/MangasNoSekai.kt @@ -178,9 +178,9 @@ class MangasNoSekai : Madara( intl["order_by_filter_new"] to "new-manga", ) - private fun altChapterRequest(mangaId: String, page: Int): Request { + private fun altChapterRequest(mangaId: String, page: Int, action: String): Request { val form = FormBody.Builder() - .add("action", "load_chapters") + .add("action", action) .add("mangaid", mangaId) .add("page", page.toString()) .build() @@ -194,6 +194,12 @@ class MangasNoSekai : Madara( val document = response.asJsoup() launchIO { countViews(document) } + val coreScript = document.selectFirst("script#wp-manga-js")!!.attr("abs:src") + val coreScriptBody = client.newCall(GET(coreScript, headers)).execute().body.string() + + val action = ACTION_REGEX.find(coreScriptBody)?.groupValues?.get(1) + ?: throw Exception("No se pudo obtener la acción de carga de capítulos") + val mangaId = document.selectFirst("script#wp-manga-js-extra")?.data() ?.let { MANGA_ID_REGEX.find(it)?.groupValues?.get(1) } ?: throw Exception("No se pudo obtener el id del manga") @@ -201,7 +207,7 @@ class MangasNoSekai : Madara( val chapterElements = mutableListOf() var page = 1 do { - val xhrRequest = altChapterRequest(mangaId, page) + val xhrRequest = altChapterRequest(mangaId, page, action) val xhrResponse = client.newCall(xhrRequest).execute() val xhrDocument = xhrResponse.asJsoup() chapterElements.addAll(xhrDocument.select(altChapterListSelector)) @@ -220,6 +226,7 @@ class MangasNoSekai : Madara( } companion object { + val ACTION_REGEX = """function\s+loadMoreChapters[\s\S]*?\$.ajax[\s\S]*?data[\s\S]*?action:\s*(?:["'](.*?)["'])""".toRegex() val MANGA_ID_REGEX = """\"manga_id"\s*:\s*"(.*)\"""".toRegex() } }