Manhastro: fix chapter images (#1363)

* Manhastro: fix chapter images

* Update src/pt/manhastro/src/eu/kanade/tachiyomi/extension/pt/manhastro/Manhastro.kt

Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>

---------

Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>
This commit is contained in:
Vetle Ledaal 2024-02-18 15:25:01 +00:00 committed by Draff
parent 30b13498b0
commit 0ed4e4147f
2 changed files with 18 additions and 1 deletions

View File

@ -3,7 +3,8 @@ ext {
extClass = '.Manhastro' extClass = '.Manhastro'
themePkg = 'madara' themePkg = 'madara'
baseUrl = 'https://manhastro.com' baseUrl = 'https://manhastro.com'
overrideVersionCode = 0 overrideVersionCode = 1
isNsfw = true
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -1,8 +1,12 @@
package eu.kanade.tachiyomi.extension.pt.manhastro package eu.kanade.tachiyomi.extension.pt.manhastro
import android.util.Base64
import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.model.Page
import kotlinx.serialization.decodeFromString
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import org.jsoup.nodes.Document
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -19,4 +23,16 @@ class Manhastro : Madara(
.build() .build()
override val useNewChapterEndpoint = true override val useNewChapterEndpoint = true
override fun pageListParse(document: Document): List<Page> {
return document.selectFirst("script:containsData(imageLinks)")?.data()
?.let { imageLinksPattern.find(it)?.groups?.get(1)?.value }
?.let { json.decodeFromString<List<String>>(it) }
?.mapIndexed { i, imageUrlEncoded ->
val imageUrl = String(Base64.decode(imageUrlEncoded, Base64.DEFAULT))
Page(i, document.location(), imageUrl)
} ?: emptyList()
}
private val imageLinksPattern = """var\s+?imageLinks\s*?=\s*?(\[.*]);""".toRegex()
} }