MangaCrab: Fix no chapters found (#15589)

This commit is contained in:
seew3l 2023-03-05 16:43:22 -05:00 committed by GitHub
parent fc736e83d8
commit d4d81ad7cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,3 @@
dependencies {
implementation(project(':lib-cryptoaes'))
}

View File

@ -0,0 +1,62 @@
package eu.kanade.tachiyomi.extension.es.mangacrab
import android.util.Base64
import eu.kanade.tachiyomi.lib.cryptoaes.CryptoAES
import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.source.model.Page
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import org.jsoup.nodes.Document
import java.text.SimpleDateFormat
import java.util.Locale
class MangaCrab : Madara(
"Manga Crab",
"https://mangacrab.com",
"es",
SimpleDateFormat("dd/MM/yyyy", Locale("es")),
) {
override fun chapterListSelector() = "li.capitulos"
override val mangaDetailsSelectorDescription = "div.c-page__content div.contenedor"
override fun pageListParse(document: Document): List<Page> {
val chapterProtector = document.getElementById("chapter-protector-data")?.html()
?: return super.pageListParse(document)
val password = chapterProtector
.substringAfter("wpmangaprotectornonce='")
.substringBefore("';")
val chapterData = json.parseToJsonElement(
chapterProtector
.substringAfter("chapter_data='")
.substringBefore("';")
.replace("\\/", "/"),
).jsonObject
val unsaltedCiphertext = Base64.decode(chapterData["ct"]!!.jsonPrimitive.content, Base64.DEFAULT)
val salt = chapterData["s"]!!.jsonPrimitive.content.decodeHex()
val ciphertext = SALTED + salt + unsaltedCiphertext
val rawImgArray = CryptoAES.decrypt(Base64.encodeToString(ciphertext, Base64.DEFAULT), password)
val imgArrayString = json.parseToJsonElement(rawImgArray).jsonPrimitive.content
val imgArray = json.parseToJsonElement(imgArrayString).jsonArray
return imgArray.mapIndexed { idx, it ->
Page(idx, document.location(), it.jsonPrimitive.content)
}
}
// https://stackoverflow.com/a/66614516
private fun String.decodeHex(): ByteArray {
check(length % 2 == 0) { "Must have an even length" }
return chunked(2)
.map { it.toInt(16).toByte() }
.toByteArray()
}
companion object {
val SALTED = "Salted__".toByteArray(Charsets.UTF_8)
}
}

View File

@ -182,7 +182,7 @@ class MadaraGenerator : ThemeSourceGenerator {
SingleLang("Manga Bilgini", "https://mangabilgini.com", "tr"),
SingleLang("Manga Bin", "https://mangabin.com", "en", overrideVersionCode = 1),
SingleLang("Manga Chill", "https://mangachill.io", "en", overrideVersionCode = 6),
SingleLang("Manga Crab", "https://mangacrab.com", "es", overrideVersionCode = 1),
SingleLang("Manga Crab", "https://mangacrab.com", "es", overrideVersionCode = 2),
SingleLang("Manga District", "https://mangadistrict.com", "en", isNsfw = true, overrideVersionCode = 1),
SingleLang("Manga Diyari", "https://manga-diyari.com", "tr", overrideVersionCode = 2),
SingleLang("Manga Fenix", "https://manga-fenix.com", "es", overrideVersionCode = 2),