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") id("lib-multisrc")
} }
baseVersionCode = 4 baseVersionCode = 5

View File

@ -197,7 +197,18 @@ abstract class Keyoapp(
status = document.selectFirst("div[alt=Status]").parseStatus() status = document.selectFirst("div[alt=Status]").parseStatus()
author = document.selectFirst("div[alt=Author]")?.text() author = document.selectFirst("div[alt=Author]")?.text()
artist = document.selectFirst("div[alt=Artist]")?.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()) { private fun Element?.parseStatus(): Int = when (this?.text()?.lowercase()) {
@ -247,7 +258,7 @@ abstract class Keyoapp(
return url return url
} }
private fun Element.getImageUrl(selector: String): String? { protected open fun Element.getImageUrl(selector: String): String? {
return this.selectFirst(selector)?.let { element -> return this.selectFirst(selector)?.let { element ->
element.attr("style") element.attr("style")
.substringAfter(":url(", "") .substringAfter(":url(", "")

View File

@ -1,9 +1,9 @@
ext { ext {
extName = 'Magus Manga' extName = 'Magus Manga'
extClass = '.MagusManga' extClass = '.MagusManga'
themePkg = 'mangathemesia' themePkg = 'keyoapp'
baseUrl = 'https://recipeslik.online' baseUrl = 'https://magustoon.com'
overrideVersionCode = 8 overrideVersionCode = 34
} }
apply from: "$rootDir/common.gradle" 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 package eu.kanade.tachiyomi.extension.en.magusmanga
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesiaAlt import eu.kanade.tachiyomi.multisrc.keyoapp.Keyoapp
import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.network.interceptor.rateLimitHost
import okhttp3.Cookie import eu.kanade.tachiyomi.source.model.Page
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response import okhttp3.Response
import okio.IOException
import org.jsoup.Jsoup import org.jsoup.Jsoup
import java.text.SimpleDateFormat import org.jsoup.nodes.Document
import java.util.Locale
import java.util.concurrent.TimeUnit
class MagusManga : MangaThemesiaAlt( class MagusManga : Keyoapp(
"Magus Manga", "Magus Manga",
"https://recipeslik.online", "https://magustoon.com",
"en", "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() override val versionId = 2
.addInterceptor(::wafffCookieInterceptor)
.rateLimit(1, 1, TimeUnit.SECONDS) override val client = network.cloudflareClient.newBuilder()
.addInterceptor(::captchaInterceptor)
.addInterceptor(::fallbackCdnInterceptor)
.rateLimitHost(baseUrl.toHttpUrl(), 1)
.rateLimitHost(cdnUrl.toHttpUrl(), 1)
.build() .build()
private fun wafffCookieInterceptor(chain: Interceptor.Chain): Response { private fun captchaInterceptor(chain: Interceptor.Chain): Response {
val request = chain.request() val request = chain.request()
val response = chain.proceed(request) val response = chain.proceed(request)
val document = Jsoup.parse( if (response.code == 401) {
response.peekBody(Long.MAX_VALUE).string(), val document = Jsoup.parse(
response.request.url.toString(), 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),
) )
response.close() 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 { } else {
response response
} }
} }
private val waffRegex = Regex("""document\.cookie\s*=\s*['"](?<waff>.*)['"]""")
} }