Fix broken search and chapter images at MP. (#7580)
This commit is contained in:
parent
d6cd87b712
commit
ca27731aa8
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'MangaPark v3'
|
extName = 'MangaPark v3'
|
||||||
pkgNameSuffix = 'all.mangapark'
|
pkgNameSuffix = 'all.mangapark'
|
||||||
extClass = '.MangaParkFactory'
|
extClass = '.MangaParkFactory'
|
||||||
extVersionCode = 5
|
extVersionCode = 6
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
containsNsfw = true
|
containsNsfw = true
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,16 @@ import kotlinx.serialization.json.put
|
|||||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
import okhttp3.MediaType.Companion.toMediaType
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
import okhttp3.Response
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import okhttp3.Response
|
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
open class MangaPark(
|
open class MangaPark(
|
||||||
override val lang: String,
|
override val lang: String,
|
||||||
@ -92,7 +92,7 @@ open class MangaPark(
|
|||||||
val url = "$baseUrl/search?word=$query&page=$page"
|
val url = "$baseUrl/search?word=$query&page=$page"
|
||||||
client.newCall(GET(url, headers)).asObservableSuccess()
|
client.newCall(GET(url, headers)).asObservableSuccess()
|
||||||
.map { response ->
|
.map { response ->
|
||||||
searchParse(response)
|
searchMangaParse(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +115,8 @@ open class MangaPark(
|
|||||||
}
|
}
|
||||||
|
|
||||||
with(genreFilter) {
|
with(genreFilter) {
|
||||||
url.addQueryParameter("genres", included.joinToString(",") + "|" + excluded.joinToString(",")
|
url.addQueryParameter(
|
||||||
|
"genres", included.joinToString(",") + "|" + excluded.joinToString(",")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +130,7 @@ open class MangaPark(
|
|||||||
|
|
||||||
client.newCall(GET(url.build().toString(), headers)).asObservableSuccess()
|
client.newCall(GET(url.build().toString(), headers)).asObservableSuccess()
|
||||||
.map { response ->
|
.map { response ->
|
||||||
searchParse(response)
|
searchMangaParse(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,41 +147,30 @@ open class MangaPark(
|
|||||||
return MangasPage(listOf(manga), false)
|
return MangasPage(listOf(manga), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun searchParse(response: Response): MangasPage {
|
|
||||||
val mangas = mutableListOf<SManga>()
|
|
||||||
|
|
||||||
response.asJsoup().select("div#search-list div.col").forEach { element ->
|
|
||||||
mangas.add(latestUpdatesFromElement(element))
|
|
||||||
}
|
|
||||||
|
|
||||||
val nextPage = response.asJsoup().select(latestUpdatesNextPageSelector()).first() != null
|
|
||||||
|
|
||||||
return MangasPage(mangas, nextPage)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = throw UnsupportedOperationException("Not used")
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = throw UnsupportedOperationException("Not used")
|
||||||
override fun searchMangaSelector() = throw UnsupportedOperationException("Not used")
|
|
||||||
override fun searchMangaFromElement(element: Element) = throw UnsupportedOperationException("Not used")
|
override fun searchMangaSelector() = "div#search-list div.col"
|
||||||
override fun searchMangaNextPageSelector() = throw UnsupportedOperationException("Not used")
|
|
||||||
|
override fun searchMangaFromElement(element: Element) = latestUpdatesFromElement(element)
|
||||||
|
|
||||||
|
override fun searchMangaNextPageSelector() = latestUpdatesNextPageSelector()
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document): SManga {
|
override fun mangaDetailsParse(document: Document): SManga {
|
||||||
|
|
||||||
val infoElement = document.select("div#mainer div.container-fluid")
|
val infoElement = document.select("div#mainer div.container-fluid")
|
||||||
val genreList = mutableListOf<String>()
|
|
||||||
val statusStr = infoElement.select("div.attr-item:contains(status) span").text()
|
val statusStr = infoElement.select("div.attr-item:contains(status) span").text()
|
||||||
infoElement.select("div.attr-item:contains(genres) span span").forEach { element ->
|
|
||||||
genreList.add(element.text())
|
|
||||||
}
|
|
||||||
|
|
||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
title = infoElement.select("h3.item-title").text()
|
title = infoElement.select("h3.item-title").text()
|
||||||
description = infoElement.select("div.limit-height-body").select("h5.text-muted, div.limit-html").joinToString("\n\n") { it.text() }
|
description = infoElement.select("div.limit-height-body")
|
||||||
author = infoElement.select("div.attr-item:contains(author)").text().split("/").joinToString(", ") { it.trim() }
|
.select("h5.text-muted, div.limit-html")
|
||||||
|
.joinToString("\n\n") { it.text() }
|
||||||
|
author = infoElement.select("div.attr-item:contains(author) a")
|
||||||
|
.joinToString { it.text().trim() }
|
||||||
status = parseStatus(statusStr)
|
status = parseStatus(statusStr)
|
||||||
thumbnail_url = infoElement.select("div.detail-set div.attr-cover img").attr("abs:src")
|
thumbnail_url = infoElement.select("div.detail-set div.attr-cover img").attr("abs:src")
|
||||||
genre = genreList.joinToString(", ") { it.trim() }
|
genre = infoElement.select("div.attr-item:contains(genres) span span")
|
||||||
|
.joinToString { it.text().trim() }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseStatus(status: String?) = when {
|
private fun parseStatus(status: String?) = when {
|
||||||
@ -272,32 +262,25 @@ open class MangaPark(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
|
|
||||||
val pages = mutableListOf<Page>()
|
|
||||||
|
|
||||||
val duktape = Duktape.create()
|
val duktape = Duktape.create()
|
||||||
val script = document.select("script").html()
|
val script = document.select("script").html()
|
||||||
val imgCdnHost = script.substringAfter("const imgCdnHost = ").substringBefore(";")
|
val imgCdnHost = script.substringAfter("const imgCdnHost = \"").substringBefore("\";")
|
||||||
val imgPathLisRaw = script.substringAfter("const imgPathLis = ").substringBefore(";")
|
val imgPathLisRaw = script.substringAfter("const imgPathLis = ").substringBefore(";")
|
||||||
val imgPathLis = json.parseToJsonElement(imgPathLisRaw).jsonArray
|
val imgPathLis = json.parseToJsonElement(imgPathLisRaw).jsonArray
|
||||||
val amPass = duktape.evaluate(script.substringAfter("const amPass = ").substringBefore(";")).toString()
|
val amPass = script.substringAfter("const amPass = ").substringBefore(";")
|
||||||
val amWord = script.substringAfter("const amWord = ").substringBefore(";")
|
val amWord = script.substringAfter("const amWord = ").substringBefore(";")
|
||||||
|
|
||||||
val decryptScript = cryptoJS + "CryptoJS.AES.decrypt($amWord, \"$amPass\").toString(CryptoJS.enc.Utf8);"
|
val decryptScript = cryptoJS + "CryptoJS.AES.decrypt($amWord, $amPass).toString(CryptoJS.enc.Utf8);"
|
||||||
|
|
||||||
val imgWordLisRaw = duktape.evaluate(decryptScript).toString()
|
val imgWordLisRaw = duktape.evaluate(decryptScript).toString()
|
||||||
val imgWordLis = json.parseToJsonElement(imgWordLisRaw).jsonArray
|
val imgWordLis = json.parseToJsonElement(imgWordLisRaw).jsonArray
|
||||||
|
|
||||||
imgPathLis.mapIndexed { i, imgPathE ->
|
return imgWordLis.mapIndexed { i, imgWordE ->
|
||||||
val imgPath = imgPathE.jsonPrimitive.content
|
val imgPath = imgPathLis[i].jsonPrimitive.content
|
||||||
val imgWordE = imgWordLis.elementAt(i)
|
|
||||||
val imgWord = imgWordE.jsonPrimitive.content
|
val imgWord = imgWordE.jsonPrimitive.content
|
||||||
|
|
||||||
val page = "$imgCdnHost$imgPath?$imgWord"
|
Page(i, "", "$imgCdnHost$imgPath?$imgWord")
|
||||||
pages.add(Page(i, "", "$page"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pages
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val cryptoJS by lazy {
|
private val cryptoJS by lazy {
|
||||||
@ -311,7 +294,6 @@ open class MangaPark(
|
|||||||
|
|
||||||
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
|
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
|
||||||
|
|
||||||
|
|
||||||
override fun getFilterList() = FilterList(
|
override fun getFilterList() = FilterList(
|
||||||
// LetterFilter(),
|
// LetterFilter(),
|
||||||
Filter.Header("NOTE: Ignored if using text search!"),
|
Filter.Header("NOTE: Ignored if using text search!"),
|
||||||
@ -498,7 +480,5 @@ open class MangaPark(
|
|||||||
const val PREFIX_ID_SEARCH = "id:"
|
const val PREFIX_ID_SEARCH = "id:"
|
||||||
|
|
||||||
const val CryptoJSUrl = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"
|
const val CryptoJSUrl = "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user