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'
|
extName = 'Kumanga'
|
||||||
pkgNameSuffix = 'es.kumanga'
|
pkgNameSuffix = 'es.kumanga'
|
||||||
extClass = '.Kumanga'
|
extClass = '.Kumanga'
|
||||||
extVersionCode = 5
|
extVersionCode = 6
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.extension.es.kumanga
|
package eu.kanade.tachiyomi.extension.es.kumanga
|
||||||
|
|
||||||
|
import android.util.Base64
|
||||||
import com.github.salomonbrys.kotson.array
|
import com.github.salomonbrys.kotson.array
|
||||||
import com.github.salomonbrys.kotson.get
|
import com.github.salomonbrys.kotson.get
|
||||||
import com.github.salomonbrys.kotson.int
|
import com.github.salomonbrys.kotson.int
|
||||||
|
@ -22,7 +23,6 @@ import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import java.io.IOException
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
@ -61,14 +61,21 @@ class Kumanga : HttpSource() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private var kumangaToken = ""
|
private var kumangaToken = ""
|
||||||
private val tokenRegex = Regex(""""([^"\s]{100,})"""")
|
|
||||||
|
|
||||||
private fun getKumangaToken() {
|
private fun encodeAndReverse(dtValue: String): String {
|
||||||
kumangaToken = client.newCall(GET("$baseUrl/mangalist?&page=1", headers)).execute().asJsoup()
|
return Base64.encodeToString(dtValue.toByteArray(), Base64.DEFAULT).reversed().trim()
|
||||||
.select("div.input-group [type=hidden]")
|
}
|
||||||
.firstOrNull()
|
|
||||||
?.let { tokenRegex.find(it.outerHtml())?.groupValues?.get(1) }
|
private fun decodeBase64(encodedString: String): String {
|
||||||
?: throw IOException("No fue posible obtener la lista de mangas")
|
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"
|
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 {
|
override fun pageListParse(response: Response): List<Page> = mutableListOf<Page>().apply {
|
||||||
val document = response.asJsoup()
|
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=")
|
?.substringAfter("var pUrl=")
|
||||||
?.substringBefore(";")
|
?.substringBefore(";")
|
||||||
?: throw Exception("imagesJsonListStr null")
|
?: throw Exception("imagesJsonListStr null")
|
||||||
|
imagesJsonListStr = decodeBase64(decodeBase64(imagesJsonListStr).reversed().dropLast(10).drop(10))
|
||||||
val imagesJsonList = parseJson(imagesJsonListStr).array
|
val imagesJsonList = parseJson(imagesJsonListStr).array
|
||||||
|
|
||||||
imagesJsonList.forEach {
|
imagesJsonList.forEach {
|
||||||
|
|
Loading…
Reference in New Issue