Fix Kumanga (ES) mangas list and pages list not loading (#5422)
* fixing kumanga * JSON parse formula * Fix Kumanga issues caused by obfuscation. * Removed unused Regex
This commit is contained in:
parent
e906749837
commit
eaa10925a9
|
@ -5,7 +5,7 @@ ext {
|
|||
extName = 'Kumanga'
|
||||
pkgNameSuffix = 'es.kumanga'
|
||||
extClass = '.Kumanga'
|
||||
extVersionCode = 5
|
||||
extVersionCode = 6
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.tachiyomi.extension.es.kumanga
|
||||
|
||||
import android.util.Base64
|
||||
import com.github.salomonbrys.kotson.array
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.github.salomonbrys.kotson.int
|
||||
|
@ -22,7 +23,6 @@ import okhttp3.OkHttpClient
|
|||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Element
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import kotlin.math.roundToInt
|
||||
|
@ -61,14 +61,21 @@ class Kumanga : HttpSource() {
|
|||
.build()
|
||||
|
||||
private var kumangaToken = ""
|
||||
private val tokenRegex = Regex(""""([^"\s]{100,})"""")
|
||||
|
||||
private fun getKumangaToken() {
|
||||
kumangaToken = client.newCall(GET("$baseUrl/mangalist?&page=1", headers)).execute().asJsoup()
|
||||
.select("div.input-group [type=hidden]")
|
||||
.firstOrNull()
|
||||
?.let { tokenRegex.find(it.outerHtml())?.groupValues?.get(1) }
|
||||
?: throw IOException("No fue posible obtener la lista de mangas")
|
||||
private fun encodeAndReverse(dtValue: String): String {
|
||||
return Base64.encodeToString(dtValue.toByteArray(), Base64.DEFAULT).reversed().trim()
|
||||
}
|
||||
|
||||
private fun decodeBase64(encodedString: String): String {
|
||||
return Base64.decode(encodedString, Base64.DEFAULT).toString(charset("UTF-8"))
|
||||
}
|
||||
|
||||
private fun getKumangaToken(): String {
|
||||
val body = client.newCall(GET("$baseUrl/mangalist?&page=1", headers)).execute().asJsoup()
|
||||
var dt = body.select("#searchinput").attr("dt").toString()
|
||||
var kumangaTokenKey = encodeAndReverse(encodeAndReverse(dt)).replace("=", "k").toLowerCase()
|
||||
kumangaToken = body.select("div.input-group [type=hidden]").attr(kumangaTokenKey)
|
||||
return kumangaToken
|
||||
}
|
||||
|
||||
private fun getMangaCover(mangaId: String) = "https://static.kumanga.com/manga_covers/$mangaId.jpg?w=201"
|
||||
|
@ -169,10 +176,11 @@ class Kumanga : HttpSource() {
|
|||
|
||||
override fun pageListParse(response: Response): List<Page> = mutableListOf<Page>().apply {
|
||||
val document = response.asJsoup()
|
||||
val imagesJsonListStr = document.select("script:containsData(var pUrl=)").firstOrNull()?.data()
|
||||
var imagesJsonListStr = document.select("script:containsData(var pUrl=)").firstOrNull()?.data()
|
||||
?.substringAfter("var pUrl=")
|
||||
?.substringBefore(";")
|
||||
?: throw Exception("imagesJsonListStr null")
|
||||
imagesJsonListStr = decodeBase64(decodeBase64(imagesJsonListStr).reversed().dropLast(10).drop(10))
|
||||
val imagesJsonList = parseJson(imagesJsonListStr).array
|
||||
|
||||
imagesJsonList.forEach {
|
||||
|
|
Loading…
Reference in New Issue