Update Manamoa Extension (#2207)

* Update Manamoa Extension

* Update base url
* New CDN Handler that ~~abusing CF and~~ prevent image load fails

* WIP DDOSGuardBypass, which doesn't work for now.

* Remove WIP Code

It will be very hard one with okhttp + main thread....
This commit is contained in:
DitFranXX 2020-02-16 07:59:32 +09:00 committed by GitHub
parent 3f67efea73
commit 047cd441a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 29 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: ManaMoa' appName = 'Tachiyomi: ManaMoa'
pkgNameSuffix = 'ko.mangashowme' pkgNameSuffix = 'ko.mangashowme'
extClass = '.ManaMoa' extClass = '.ManaMoa'
extVersionCode = 17 extVersionCode = 18
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -0,0 +1,20 @@
package eu.kanade.tachiyomi.extension.ko.mangashowme
import org.json.JSONArray
internal class CDNUrlHandler(scripts: String) {
private val domains = JSONArray("[${scripts.substringBetween("var cdn_domains = [", "];")}]")
private val chapter = scripts.substringBetween("var chapter = ", ";")
.toIntOrNull() ?: 0
fun replace(array: JSONArray): List<String> {
return (0 until array.length())
.map {
val cdn: String = domains.get((chapter + 4 * it) % domains.length()) as String
(array.get(it) as String)
.replace("cdntigermask.xyz", cdn)
.replace("cdnmadmax.xyz", cdn)
.replace("filecdn.xyz", cdn)
}
}
}

View File

@ -23,9 +23,9 @@ import kotlin.math.tan
*/ */
internal class ImageDecoder(scripts: String) { internal class ImageDecoder(scripts: String) {
private val cnt = substringBetween(scripts, "var view_cnt = ", ";") private val cnt = scripts.substringBetween("var view_cnt = ", ";")
.toIntOrNull() ?: 0 .toIntOrNull() ?: 0
private val chapter = substringBetween(scripts, "var chapter = ", ";") private val chapter = scripts.substringBetween("var chapter = ", ";")
.toIntOrNull() ?: 0 .toIntOrNull() ?: 0
fun request(url: String): String { fun request(url: String): String {
@ -162,7 +162,3 @@ internal class ImageDecoderInterceptor : Interceptor {
floor(10000 * (a - floor(a)))).toInt() floor(10000 * (a - floor(a)))).toInt()
} }
} }
private fun substringBetween(target: String, prefix: String, suffix: String): String = {
target.substringAfter(prefix).substringBefore(suffix)
}()

View File

@ -44,7 +44,7 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
override val name = "ManaMoa" override val name = "ManaMoa"
// This keeps updating: https://twitter.com/manamoa24 // This keeps updating: https://twitter.com/manamoa24
private val defaultBaseUrl = "https://manamoa26.net" private val defaultBaseUrl = "https://manamoa27.net"
override val baseUrl by lazy { getCurrentBaseUrl() } override val baseUrl by lazy { getCurrentBaseUrl() }
override val lang: String = "ko" override val lang: String = "ko"
@ -203,24 +203,25 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
// They are using full url in every links. // They are using full url in every links.
// There's possibility to using another domain for serve manga(s). Like marumaru. // There's possibility to using another domain for serve manga(s). Like marumaru.
//override fun pageListRequest(chapter: SChapter) = GET(chapter.url, headers) //override fun pageListRequest(chapter: SChapter) = GET(chapter.url, headers)
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
val pages = mutableListOf<Page>() val pages = mutableListOf<Page>()
try { try {
val element = document.select("div.col-md-9.at-col.at-main script").html() val element = document.select("div.col-md-9.at-col.at-main script").html()
val imageUrl = element.substringAfter("var img_list = [").substringBefore("];") val cdnHandler = CDNUrlHandler(element)
val imageUrls = JSONArray("[$imageUrl]")
val imageUrl1 = element.substringAfter("var img_list1 = [").substringBefore("];") val imageUrl = element.substringBetween("var img_list = [", "];")
val imageUrls1 = JSONArray("[$imageUrl1]") val imageUrls = cdnHandler.replace(JSONArray("[$imageUrl]"))
val imageUrl1 = element.substringAfter("var img_list1 = [", "];")
val imageUrls1 = cdnHandler.replace(JSONArray("[$imageUrl1]"))
val decoder = ImageDecoder(element) val decoder = ImageDecoder(element)
(0 until imageUrls.length()) (imageUrls.indices)
.map { .map {
imageUrls.getString(it) + try { imageUrls[it] + try {
"!!${imageUrls1.getString(it)}?quick" "!!${imageUrls1[it]}?quick"
} catch (_: Exception) { } catch (_: Exception) {
"" ""
} }
@ -306,7 +307,7 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
key = AUTOFETCH_URL_PREF_TITLE key = AUTOFETCH_URL_PREF_TITLE
title = AUTOFETCH_URL_PREF_TITLE title = AUTOFETCH_URL_PREF_TITLE
summary = AUTOFETCH_URL_PREF_SUMMARY summary = AUTOFETCH_URL_PREF_SUMMARY
this.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) this.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
try { try {
@ -349,7 +350,7 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
key = AUTOFETCH_URL_PREF_TITLE key = AUTOFETCH_URL_PREF_TITLE
title = AUTOFETCH_URL_PREF_TITLE title = AUTOFETCH_URL_PREF_TITLE
summary = AUTOFETCH_URL_PREF_SUMMARY summary = AUTOFETCH_URL_PREF_SUMMARY
this.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) this.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
try { try {
@ -373,9 +374,9 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
return prefBaseUrl return prefBaseUrl
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
try { try {
@TargetApi(Build.VERSION_CODES.N) @TargetApi(Build.VERSION_CODES.O)
class CallbackFuture : CompletableFuture<Response?>(), Callback { class CallbackFuture : CompletableFuture<Response?>(), Callback {
override fun onResponse(call: Call?, response: Response?) { override fun onResponse(call: Call?, response: Response?) {
super.complete(response) super.complete(response)
@ -387,14 +388,21 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
} }
val request: Request = Request.Builder().get() val request: Request = Request.Builder().get()
.url("http://13.229.223.203") //.url("https://mnmnmnmnm.xyz/")
.url("http://52.74.159.59")
.build() .build()
val future = CallbackFuture() val future = CallbackFuture()
network.client.newCall(request).enqueue(future) network.client
//.newBuilder()
//.addInterceptor(DDOSGuardInterceptor())
//.build()!!
.newCall(request).enqueue(future)
val response = future.get()!! val response = future.get()!!
return "https://${response.request().url().host()}" return "https://${response.request().url().host()}"
//val code = response.body().toString().substringBetween("manamoa", ".net")
//return "https://manamoa$code.net"
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
return prefBaseUrl return prefBaseUrl
@ -418,8 +426,8 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
private const val AUTOFETCH_URL_PREF_TITLE = "Automatically fetch new domain" private const val AUTOFETCH_URL_PREF_TITLE = "Automatically fetch new domain"
private const val AUTOFETCH_URL_PREF = "autoFetchNewUrl" private const val AUTOFETCH_URL_PREF = "autoFetchNewUrl"
private const val AUTOFETCH_URL_PREF_SUMMARY = private const val AUTOFETCH_URL_PREF_SUMMARY =
"Experimental, May cause Tachiyomi unstable.\n" + "Experimental, May cause Tachiyomi *very* unstable.\n" +
"Requires Android Nougat or newer." "Requires Android Oreo or newer."
private const val RESTART_TACHIYOMI = "Restart Tachiyomi to apply new setting." private const val RESTART_TACHIYOMI = "Restart Tachiyomi to apply new setting."

View File

@ -0,0 +1,5 @@
package eu.kanade.tachiyomi.extension.ko.mangashowme
internal fun String.substringBetween(prefix: String, suffix: String): String = {
this.substringAfter(prefix).substringBefore(suffix)
}()