update Manhuadui (#1213)

update Manhuadui
This commit is contained in:
fei long 2019-06-21 08:18:59 +08:00 committed by Eugene
parent 291c54e2d4
commit 910ef94cfd
2 changed files with 42 additions and 10 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Manhuadui' appName = 'Tachiyomi: Manhuadui'
pkgNameSuffix = 'zh.manhuadui' pkgNameSuffix = 'zh.manhuadui'
extClass = '.Manhuadui' extClass = '.Manhuadui'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -1,16 +1,21 @@
package eu.kanade.tachiyomi.extension.zh.manhuadui package eu.kanade.tachiyomi.extension.zh.manhuadui
//import android.util.Base64.NO_WRAP
//import java.util.*
import android.util.Base64
import com.squareup.duktape.Duktape
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.HttpUrl import okhttp3.HttpUrl
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.lang.UnsupportedOperationException import javax.crypto.Cipher
import com.squareup.duktape.Duktape import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
//import android.util.Base64 //import android.util.Base64
//import android.util.Log //import android.util.Log
@ -92,13 +97,40 @@ class Manhuadui : ParsedHttpSource() {
return super.chapterListParse(response).asReversed() return super.chapterListParse(response).asReversed()
} }
// ref: https://jueyue.iteye.com/blog/1830792
fun decryptAES(value: String, key: String, iv: String): String? {
try {
val secretKey = SecretKeySpec(key.toByteArray(), "AES")
val iv = IvParameterSpec(iv.toByteArray())
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv)
val code = Base64.decode(value, Base64.NO_WRAP)
return String(cipher.doFinal(code))
} catch (e: Exception) {
e.printStackTrace()
}
return null
}
fun decrypt(code : String):String?{
val key = "123456781234567G"
val iv = "ABCDEF1G34123412"
return decryptAES(code, key, iv)
}
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
val html = document.html() val html = document.html()
val re = Regex("var chapterImages =(.*?);") val re = Regex("""var chapterImages =\s*"(.*?)";""")
val imgCode = re.find(html)?.groups?.get(1)?.value val imgCodeStr = re.find(html)?.groups?.get(1)?.value
val imgCode = decrypt(imgCodeStr!!)
val imgPath = Regex("""var chapterPath =\s*"(.*?)";""").find(html)?.groups?.get(1)?.value val imgPath = Regex("""var chapterPath =\s*"(.*?)";""").find(html)?.groups?.get(1)?.value
val imgArrStr = Duktape.create().use { val imgArrStr = Duktape.create().use {
it.evaluate(imgCode + """.join('|')""") as String it.evaluate(imgCode!! + """.join('|')""") as String
} }
return imgArrStr.split('|').mapIndexed { i, imgStr -> return imgArrStr.split('|').mapIndexed { i, imgStr ->
//Log.i("test", "img => ${imageServer[0]}/$imgPath$imgStr") //Log.i("test", "img => ${imageServer[0]}/$imgPath$imgStr")