Magus Manga: domain & theme change (#4766)

This commit is contained in:
AwkwardPeak7 2024-08-26 16:26:09 +05:00 committed by Draff
parent 2d16d1896b
commit 5a6c302a6d
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
9 changed files with 72 additions and 40 deletions

View File

@ -2,4 +2,4 @@ plugins {
id("lib-multisrc")
}
baseVersionCode = 4
baseVersionCode = 5

View File

@ -197,7 +197,18 @@ abstract class Keyoapp(
status = document.selectFirst("div[alt=Status]").parseStatus()
author = document.selectFirst("div[alt=Author]")?.text()
artist = document.selectFirst("div[alt=Artist]")?.text()
genre = document.select("div.grid:has(>h1) > div > a").joinToString { it.text() }
genre = buildList {
document.selectFirst("div[alt='Series Type']")?.text()?.replaceFirstChar {
if (it.isLowerCase()) {
it.titlecase(
Locale.getDefault(),
)
} else {
it.toString()
}
}.let(::add)
document.select("div.grid:has(>h1) > div > a").forEach { add(it.text()) }
}.joinToString()
}
private fun Element?.parseStatus(): Int = when (this?.text()?.lowercase()) {
@ -247,7 +258,7 @@ abstract class Keyoapp(
return url
}
private fun Element.getImageUrl(selector: String): String? {
protected open fun Element.getImageUrl(selector: String): String? {
return this.selectFirst(selector)?.let { element ->
element.attr("style")
.substringAfter(":url(", "")

View File

@ -1,9 +1,9 @@
ext {
extName = 'Magus Manga'
extClass = '.MagusManga'
themePkg = 'mangathemesia'
baseUrl = 'https://recipeslik.online'
overrideVersionCode = 8
themePkg = 'keyoapp'
baseUrl = 'https://magustoon.com'
overrideVersionCode = 34
}
apply from: "$rootDir/common.gradle"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -1,57 +1,78 @@
package eu.kanade.tachiyomi.extension.en.magusmanga
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesiaAlt
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import okhttp3.Cookie
import eu.kanade.tachiyomi.multisrc.keyoapp.Keyoapp
import eu.kanade.tachiyomi.network.interceptor.rateLimitHost
import eu.kanade.tachiyomi.source.model.Page
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
import okio.IOException
import org.jsoup.Jsoup
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.concurrent.TimeUnit
import org.jsoup.nodes.Document
class MagusManga : MangaThemesiaAlt(
class MagusManga : Keyoapp(
"Magus Manga",
"https://recipeslik.online",
"https://magustoon.com",
"en",
mangaUrlDirectory = "/series",
dateFormat = SimpleDateFormat("MMMMM dd, yyyy", Locale("en")),
) {
override val id = 7792477462646075400
private val cdnUrl = "https://cdn.magustoon.com"
override val client: OkHttpClient = super.client.newBuilder()
.addInterceptor(::wafffCookieInterceptor)
.rateLimit(1, 1, TimeUnit.SECONDS)
override val versionId = 2
override val client = network.cloudflareClient.newBuilder()
.addInterceptor(::captchaInterceptor)
.addInterceptor(::fallbackCdnInterceptor)
.rateLimitHost(baseUrl.toHttpUrl(), 1)
.rateLimitHost(cdnUrl.toHttpUrl(), 1)
.build()
private fun wafffCookieInterceptor(chain: Interceptor.Chain): Response {
private fun captchaInterceptor(chain: Interceptor.Chain): Response {
val request = chain.request()
val response = chain.proceed(request)
if (response.code == 401) {
val document = Jsoup.parse(
response.peekBody(Long.MAX_VALUE).string(),
response.request.url.toString(),
)
return if (document.selectFirst("script:containsData(wafff)") != null) {
val script = document.selectFirst("script:containsData(wafff)")!!.data()
val cookie = waffRegex.find(script)?.groups?.get("waff")?.value
?.let { Cookie.parse(request.url, it) }
client.cookieJar.saveFromResponse(
request.url,
listOfNotNull(cookie),
)
if (document.selectFirst(".g-recaptcha") != null) {
response.close()
throw IOException("Solve Captcha in WebView")
}
}
chain.proceed(request)
return response
}
override fun chapterListSelector(): String {
return "${super.chapterListSelector()}:not(:has(img[src*=coin]))"
}
override fun pageListParse(document: Document): List<Page> {
return document.select("#pages > img").mapIndexed { idx, img ->
val uid = img.attr("uid")
Page(idx, imageUrl = "$cdnUrl/x/$uid")
}
}
private fun fallbackCdnInterceptor(chain: Interceptor.Chain): Response {
val request = chain.request()
val url = request.url.toString()
val response = chain.proceed(request)
return if (url.startsWith(cdnUrl) && !response.isSuccessful) {
response.close()
val newRequest = request.newBuilder()
.url(
url.replace("/x/", "/v/"),
)
.build()
chain.proceed(newRequest)
} else {
response
}
}
private val waffRegex = Regex("""document\.cookie\s*=\s*['"](?<waff>.*)['"]""")
}