Manwa: Fix page list (#5072)

This commit is contained in:
anenasa 2024-09-16 18:18:22 +08:00 committed by Draff
parent e0bb39f99a
commit 0e08a7c946
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 15 additions and 17 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Manwa' extName = 'Manwa'
extClass = '.Manwa' extClass = '.Manwa'
extVersionCode = 5 extVersionCode = 6
isNsfw = true isNsfw = true
} }

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension.zh.manwa
import android.app.Application import android.app.Application
import android.content.SharedPreferences import android.content.SharedPreferences
import android.net.Uri import android.net.Uri
import android.util.Base64
import androidx.preference.CheckBoxPreference import androidx.preference.CheckBoxPreference
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
@ -159,22 +160,19 @@ class Manwa : ParsedHttpSource(), ConfigurableSource {
return GET("$baseUrl${chapter.url}?img_host=${preferences.getString(IMAGE_HOST_KEY, IMAGE_HOST_ENTRY_VALUES[0])}", headers) return GET("$baseUrl${chapter.url}?img_host=${preferences.getString(IMAGE_HOST_KEY, IMAGE_HOST_ENTRY_VALUES[0])}", headers)
} }
override fun pageListParse(document: Document): List<Page> = mutableListOf<Page>().apply { override fun pageListParse(document: Document): List<Page> {
val cssQuery = "#cp_img > div.img-content > img[data-r-src]" val script = document.selectFirst("script:containsData(encryptedPhotos)")!!.data()
val elements = document.select(cssQuery) // key changes every hour
if (elements.size == 3) { val key = script.substringBefore("','enc'").substringAfterLast("'").toByteArray()
val darkReader = document.selectFirst("#cp_img p") val encrypted = script.substringAfter("encryptedPhotos = '").substringBefore("'")
if (darkReader != null) { val decoded = Base64.decode(encrypted, Base64.DEFAULT)
if (preferences.getBoolean(AUTO_CLEAR_COOKIE_KEY, false)) { val aesKey = SecretKeySpec(key, "AES")
clearCookies() val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
} cipher.init(Cipher.DECRYPT_MODE, aesKey, IvParameterSpec(key))
val decrypted = String(cipher.doFinal(decoded))
throw Exception(darkReader.text()) val jsonArray = json.parseToJsonElement(decrypted).jsonArray
} return jsonArray.mapIndexed { index, it ->
} Page(index, imageUrl = "${it.jsonObject["img_url"]!!.jsonPrimitive.content}?v=20220724")
elements.forEachIndexed { index, it ->
add(Page(index, "", it.attr("data-r-src")))
} }
} }