Sixmanhua: Fix page parsing (#4989)

This commit is contained in:
AlphaBoom 2024-09-11 13:15:43 +08:00 committed by Draff
parent c0e41cb54c
commit 1883e7a889
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
4 changed files with 40 additions and 2 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = '.SixMH'
themePkg = 'mccms'
baseUrl = 'https://www.liumanhua.com'
overrideVersionCode = 4
overrideVersionCode = 5
}
apply from: "$rootDir/common.gradle"

View File

@ -0,0 +1,18 @@
package eu.kanade.tachiyomi.extension.zh.sixmh
import android.util.Base64
import kotlin.experimental.xor
private val keys = arrayOf("Ni1iWGQ5aU4=", "Ni1SWHlqcnk=", "Ni1vWXZ3Vnk=", "Ni00Wlk1N1U=", "Ni1tYkpwVTc=", "Ni02TU0yRWk=", "Ni01NFRpUXI=", "Ni1QaDV4eDk=", "Ni1iWWdlUFI=", "Ni1aOUEzYlc=")
internal fun decodeData(encodedData: String, cid: Int): String {
val key = Base64.decode(keys[cid % keys.size], Base64.DEFAULT)
val keyLength = key.size
val decodedData = Base64.decode(encodedData, Base64.DEFAULT)
val decryptedData = StringBuilder()
for (i in decodedData.indices) {
val decryptedCharCode = decodedData[i] xor key[i % keyLength]
decryptedData.appendCodePoint(decryptedCharCode.toInt())
}
return Base64.decode(decryptedData.toString(), Base64.DEFAULT).decodeToString()
}

View File

@ -0,0 +1,6 @@
package eu.kanade.tachiyomi.extension.zh.sixmh
import kotlinx.serialization.Serializable
@Serializable
data class Image(val id: String, val url: String)

View File

@ -3,13 +3,19 @@ package eu.kanade.tachiyomi.extension.zh.sixmh
import android.app.Application
import android.os.Build
import eu.kanade.tachiyomi.multisrc.mccms.MCCMS
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import okhttp3.Response
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
class SixMH : MCCMS("六漫画", "https://www.liumanhua.com") {
private val dataRegex = Regex("var DATA = '([A-Za-z0-9+/=]+)'")
private val json by injectLazy<Json>()
override val versionId get() = 2
init {
@ -21,4 +27,12 @@ class SixMH : MCCMS("六漫画", "https://www.liumanhua.com") {
override fun getMangaUrl(manga: SManga) = "https://m.liumanhua.com" + manga.url
override fun getChapterUrl(chapter: SChapter) = "https://m.liumanhua.com" + chapter.url
override fun pageListParse(response: Response): List<Page> {
val encodedData = dataRegex.find(response.body.string())?.groupValues?.get(1) ?: ""
val cid = response.request.url.pathSegments.last().removeSuffix(".html").toIntOrNull() ?: 0
val decodedData = decodeData(encodedData, cid)
val images = json.decodeFromString<List<Image>>(decodedData)
return images.mapIndexed { index, image -> Page(index, imageUrl = image.url) }
}
}