From df765c453aa22045469dbb08a60f72c42531a0d1 Mon Sep 17 00:00:00 2001 From: Mike <51273546+SnakeDoc83@users.noreply.github.com> Date: Sat, 20 Jun 2020 03:55:10 -0400 Subject: [PATCH] MangaMx - fix pages (#3580) --- src/es/mangamx/build.gradle | 4 ++-- .../tachiyomi/extension/es/mangamx/MangaMx.kt | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/es/mangamx/build.gradle b/src/es/mangamx/build.gradle index a7cbbddc9..184cc9c25 100644 --- a/src/es/mangamx/build.gradle +++ b/src/es/mangamx/build.gradle @@ -2,10 +2,10 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' ext { - appName = 'Tachiyomi: MangaMx & Doujin-Yang' + appName = 'Tachiyomi: MangaMx' pkgNameSuffix = 'es.mangamx' extClass = '.MangaMx' - extVersionCode = 7 + extVersionCode = 8 libVersion = '1.2' } diff --git a/src/es/mangamx/src/eu/kanade/tachiyomi/extension/es/mangamx/MangaMx.kt b/src/es/mangamx/src/eu/kanade/tachiyomi/extension/es/mangamx/MangaMx.kt index 2eb363513..c6cc15481 100644 --- a/src/es/mangamx/src/eu/kanade/tachiyomi/extension/es/mangamx/MangaMx.kt +++ b/src/es/mangamx/src/eu/kanade/tachiyomi/extension/es/mangamx/MangaMx.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.extension.es.mangamx import android.net.Uri +import android.util.Base64 import com.github.salomonbrys.kotson.get import com.github.salomonbrys.kotson.string import com.google.gson.JsonElement @@ -15,6 +16,7 @@ import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.util.asJsoup +import java.nio.charset.Charset import java.text.SimpleDateFormat import java.util.Locale import okhttp3.FormBody @@ -176,6 +178,7 @@ open class MangaMx : ParsedHttpSource() { // Chapters override fun chapterListSelector(): String = "div#c_list a" + override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply { name = element.text().trim() setUrlWithoutDomain(element.attr("href")) @@ -189,13 +192,16 @@ open class MangaMx : ParsedHttpSource() { // Pages - override fun pageListParse(document: Document): List = mutableListOf().apply { - val script = document.select("script:containsData(hojas)").html() - val dir = script.substringAfter("var dir = '").substringBefore("';") - val imgList = - script.substringAfter("var hojas = [\"").substringBefore("\"];").split("\",\"") - imgList.forEach { - add(Page(size, "", dir + it)) + override fun pageListParse(document: Document): List { + val encoded = document.select("script:containsData(unicap)").firstOrNull() + ?.data()?.substringAfter("'")?.substringBefore("'")?.reversed() + ?: throw Exception("unicap not found") + + val drop = encoded.length % 4 + val decoded = Base64.decode(encoded.dropLast(drop), Base64.DEFAULT).toString(Charset.defaultCharset()) + val path = decoded.substringBefore("||") + return decoded.substringAfter("[").substringBefore("]").split(",").mapIndexed { i, file -> + Page(i, "", path + file.removeSurrounding("\"")) } }