Madara: Add Doodmanga (#16334)

This commit is contained in:
Slowlife 2023-05-06 21:17:48 +07:00 committed by GitHub
parent 66f2736378
commit b506c12037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 106 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

View File

@ -0,0 +1,58 @@
package eu.kanade.tachiyomi.extension.th.doodmanga
import app.cash.quickjs.QuickJs
import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.source.model.Page
import okhttp3.OkHttpClient
import org.jsoup.nodes.Document
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.concurrent.TimeUnit
class Doodmanga : Madara("Doodmanga", "https://www.doodmanga.com", "th", SimpleDateFormat("dd MMMMM yyyy", Locale("th"))) {
override val filterNonMangaItems = false
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.addInterceptor(uaIntercept)
.addInterceptor(ScrambledImageInterceptor)
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build()
override val pageListParseSelector = "div.text-center > p > img, div.text-center > img, div.text-center > script"
override fun pageListParse(document: Document): List<Page> {
super.countViews(document)
return document.select(pageListParseSelector).mapIndexedNotNull { index, element ->
val src = when (element.tagName()) {
"img" -> element.attr("src")
"script" -> {
if (element.data().startsWith("eval(")) {
val quickJs = QuickJs.create()
val result = quickJs.evaluate(element.data().removePrefix("eval")) as String
quickJs.close()
val src = result.substringAfter("<img src='").substringBefore("'/>")
val sovleImage = result.substringAfter("var sovleImage=[[").substringBefore("]]").split("],[").map { values ->
values.replace("[", "").replace("]", "").split(",").map { it.removeSurrounding("\"") }
}
val segmentWidth = result.substringAfter("width:\"+").substringBefore("+\"px")
val segmentHeight = result.substringAfter("height: \"+").substringBefore("+\"px")
"$src?sovleImage=${sovleImage.joinToString("::") { (x, y, px, py) -> "$x,$y,$px,$py" }}&segmentWidth=$segmentWidth&segmentHeight=$segmentHeight"
} else {
null
}
}
else -> null
}
if (src == null) {
null
} else {
Page(index, document.location(), src)
}
}
}
}

View File

@ -0,0 +1,47 @@
package eu.kanade.tachiyomi.extension.th.doodmanga
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import okhttp3.Interceptor
import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
import java.io.ByteArrayOutputStream
object ScrambledImageInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
val response = chain.proceed(request)
val url = request.url
val rawSovleImage = url.queryParameter("sovleImage") ?: return response
val sovleImage = rawSovleImage.split("::").map { numbers ->
val (x, y, px, py) = numbers.split(",")
listOf(x, y, px, py)
}
val bitmap = BitmapFactory.decodeStream(response.body.byteStream())
val width = bitmap.width
val height = bitmap.height
val image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(image)
sovleImage.forEach { (x, y, px, py) ->
val segmentX = x.toFloat()
val segmentY = y.toFloat()
val positionX = px.substringBefore(".").toInt()
val positionY = py.substringBefore(".").toInt()
val subBitmap = Bitmap.createBitmap(bitmap, positionX, positionY, request.url.queryParameter("segmentWidth")!!.toInt(), request.url.queryParameter("segmentHeight")!!.toInt())
canvas.drawBitmap(subBitmap, segmentX, segmentY, null)
subBitmap.recycle()
}
val output = ByteArrayOutputStream()
image.compress(Bitmap.CompressFormat.JPEG, 90, output)
return response.newBuilder()
.body(output.toByteArray().toResponseBody(response.body.contentType()))
.build()
}
}

View File

@ -81,6 +81,7 @@ class MadaraGenerator : ThemeSourceGenerator {
SingleLang("DiamondFansub", "https://diamondfansub.com", "tr", overrideVersionCode = 1),
SingleLang("Disaster Scans", "https://disasterscans.com", "en", overrideVersionCode = 2),
SingleLang("DokkoManga", "https://dokkomanga.xyz", "es"),
SingleLang("Doodmanga", "https://www.doodmanga.com", "th"),
SingleLang("DoujinHentai", "https://doujinhentai.net", "es", isNsfw = true, overrideVersionCode = 1),
SingleLang("DragonTranslation.net", "https://dragontranslation.net", "es", isNsfw = true, className = "DragonTranslationNet"),
SingleLang("Drake Scans", "https://drakescans.com", "en", overrideVersionCode = 3),