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:
parent
3f67efea73
commit
047cd441a3
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: ManaMoa'
|
||||
pkgNameSuffix = 'ko.mangashowme'
|
||||
extClass = '.ManaMoa'
|
||||
extVersionCode = 17
|
||||
extVersionCode = 18
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,10 +23,10 @@ import kotlin.math.tan
|
|||
*/
|
||||
|
||||
internal class ImageDecoder(scripts: String) {
|
||||
private val cnt = substringBetween(scripts, "var view_cnt = ", ";")
|
||||
private val cnt = scripts.substringBetween("var view_cnt = ", ";")
|
||||
.toIntOrNull() ?: 0
|
||||
private val chapter = scripts.substringBetween("var chapter = ", ";")
|
||||
.toIntOrNull() ?: 0
|
||||
private val chapter = substringBetween(scripts, "var chapter = ", ";")
|
||||
.toIntOrNull() ?: 0
|
||||
|
||||
fun request(url: String): String {
|
||||
if (cnt < 10) return url
|
||||
|
@ -162,7 +162,3 @@ internal class ImageDecoderInterceptor : Interceptor {
|
|||
floor(10000 * (a - floor(a)))).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
private fun substringBetween(target: String, prefix: String, suffix: String): String = {
|
||||
target.substringAfter(prefix).substringBefore(suffix)
|
||||
}()
|
||||
|
|
|
@ -44,7 +44,7 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
|
|||
override val name = "ManaMoa"
|
||||
|
||||
// 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 lang: String = "ko"
|
||||
|
@ -203,28 +203,29 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
|
|||
// They are using full url in every links.
|
||||
// There's possibility to using another domain for serve manga(s). Like marumaru.
|
||||
//override fun pageListRequest(chapter: SChapter) = GET(chapter.url, headers)
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val pages = mutableListOf<Page>()
|
||||
|
||||
try {
|
||||
val element = document.select("div.col-md-9.at-col.at-main script").html()
|
||||
val imageUrl = element.substringAfter("var img_list = [").substringBefore("];")
|
||||
val imageUrls = JSONArray("[$imageUrl]")
|
||||
val cdnHandler = CDNUrlHandler(element)
|
||||
|
||||
val imageUrl1 = element.substringAfter("var img_list1 = [").substringBefore("];")
|
||||
val imageUrls1 = JSONArray("[$imageUrl1]")
|
||||
val imageUrl = element.substringBetween("var img_list = [", "];")
|
||||
val imageUrls = cdnHandler.replace(JSONArray("[$imageUrl]"))
|
||||
|
||||
val imageUrl1 = element.substringAfter("var img_list1 = [", "];")
|
||||
val imageUrls1 = cdnHandler.replace(JSONArray("[$imageUrl1]"))
|
||||
|
||||
val decoder = ImageDecoder(element)
|
||||
|
||||
(0 until imageUrls.length())
|
||||
.map {
|
||||
imageUrls.getString(it) + try {
|
||||
"!!${imageUrls1.getString(it)}?quick"
|
||||
} catch (_: Exception) {
|
||||
""
|
||||
}
|
||||
(imageUrls.indices)
|
||||
.map {
|
||||
imageUrls[it] + try {
|
||||
"!!${imageUrls1[it]}?quick"
|
||||
} catch (_: Exception) {
|
||||
""
|
||||
}
|
||||
}
|
||||
.forEach { pages.add(Page(pages.size, decoder.request(it), "${it.substringBefore("!!")}?quick")) }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
@ -306,7 +307,7 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
|
|||
key = AUTOFETCH_URL_PREF_TITLE
|
||||
title = AUTOFETCH_URL_PREF_TITLE
|
||||
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 ->
|
||||
try {
|
||||
|
@ -349,7 +350,7 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
|
|||
key = AUTOFETCH_URL_PREF_TITLE
|
||||
title = AUTOFETCH_URL_PREF_TITLE
|
||||
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 ->
|
||||
try {
|
||||
|
@ -373,9 +374,9 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
|
|||
return prefBaseUrl
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
try {
|
||||
@TargetApi(Build.VERSION_CODES.N)
|
||||
@TargetApi(Build.VERSION_CODES.O)
|
||||
class CallbackFuture : CompletableFuture<Response?>(), Callback {
|
||||
override fun onResponse(call: Call?, response: Response?) {
|
||||
super.complete(response)
|
||||
|
@ -387,14 +388,21 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
|
|||
}
|
||||
|
||||
val request: Request = Request.Builder().get()
|
||||
.url("http://13.229.223.203")
|
||||
//.url("https://mnmnmnmnm.xyz/")
|
||||
.url("http://52.74.159.59")
|
||||
.build()
|
||||
|
||||
val future = CallbackFuture()
|
||||
network.client.newCall(request).enqueue(future)
|
||||
network.client
|
||||
//.newBuilder()
|
||||
//.addInterceptor(DDOSGuardInterceptor())
|
||||
//.build()!!
|
||||
.newCall(request).enqueue(future)
|
||||
|
||||
val response = future.get()!!
|
||||
return "https://${response.request().url().host()}"
|
||||
//val code = response.body().toString().substringBetween("manamoa", ".net")
|
||||
//return "https://manamoa$code.net"
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
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 = "autoFetchNewUrl"
|
||||
private const val AUTOFETCH_URL_PREF_SUMMARY =
|
||||
"Experimental, May cause Tachiyomi unstable.\n" +
|
||||
"Requires Android Nougat or newer."
|
||||
"Experimental, May cause Tachiyomi *very* unstable.\n" +
|
||||
"Requires Android Oreo or newer."
|
||||
|
||||
private const val RESTART_TACHIYOMI = "Restart Tachiyomi to apply new setting."
|
||||
|
||||
|
|
|
@ -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)
|
||||
}()
|
Loading…
Reference in New Issue