[TuMangaOnline] Fix pages parsing
This commit is contained in:
@@ -210,7 +210,7 @@ class TuMangaOnlineParser(context: MangaLoaderContext) : PagedMangaParser(
|
|||||||
|
|
||||||
if (script1 != null) {
|
if (script1 != null) {
|
||||||
val data = script1.data()
|
val data = script1.data()
|
||||||
val regexParams = """\{uniqid:'(.+)',cascade:(.+)\}""".toRegex()
|
val regexParams = """\{uniqid:\s*'(\S+)',\s*cascade:\s*(\S+)}""".toRegex()
|
||||||
val regexAction = """form\.action\s?=\s?'(.+)'""".toRegex()
|
val regexAction = """form\.action\s?=\s?'(.+)'""".toRegex()
|
||||||
val params = regexParams.find(data)!!
|
val params = regexParams.find(data)!!
|
||||||
val action = regexAction.find(data)!!.groupValues[1].toHttpUrl()
|
val action = regexAction.find(data)!!.groupValues[1].toHttpUrl()
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ import okhttp3.Response
|
|||||||
import org.koitharu.kotatsu.parsers.config.MangaSourceConfig
|
import org.koitharu.kotatsu.parsers.config.MangaSourceConfig
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
import org.koitharu.kotatsu.parsers.util.await
|
import org.koitharu.kotatsu.parsers.util.await
|
||||||
|
import java.security.SecureRandom
|
||||||
|
import java.security.cert.X509Certificate
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
import javax.net.ssl.SSLContext
|
||||||
|
import javax.net.ssl.SSLSocketFactory
|
||||||
|
import javax.net.ssl.X509TrustManager
|
||||||
|
|
||||||
internal object MangaLoaderContextMock : MangaLoaderContext() {
|
internal object MangaLoaderContextMock : MangaLoaderContext() {
|
||||||
|
|
||||||
@@ -15,6 +20,7 @@ internal object MangaLoaderContextMock : MangaLoaderContext() {
|
|||||||
|
|
||||||
override val httpClient: OkHttpClient = OkHttpClient.Builder()
|
override val httpClient: OkHttpClient = OkHttpClient.Builder()
|
||||||
.cookieJar(cookieJar)
|
.cookieJar(cookieJar)
|
||||||
|
.permissiveSSL()
|
||||||
.addInterceptor(CommonHeadersInterceptor())
|
.addInterceptor(CommonHeadersInterceptor())
|
||||||
.addInterceptor(CloudFlareInterceptor())
|
.addInterceptor(CloudFlareInterceptor())
|
||||||
.connectTimeout(20, TimeUnit.SECONDS)
|
.connectTimeout(20, TimeUnit.SECONDS)
|
||||||
@@ -52,4 +58,24 @@ internal object MangaLoaderContextMock : MangaLoaderContext() {
|
|||||||
cookieJar.loadFromStream(it)
|
cookieJar.loadFromStream(it)
|
||||||
} ?: println("No cookies loaded!")
|
} ?: println("No cookies loaded!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun OkHttpClient.Builder.permissiveSSL() = also { builder ->
|
||||||
|
runCatching {
|
||||||
|
val trustAllCerts = object : X509TrustManager {
|
||||||
|
override fun checkClientTrusted(chain: Array<X509Certificate>, authType: String) = Unit
|
||||||
|
|
||||||
|
override fun checkServerTrusted(chain: Array<X509Certificate>, authType: String) = Unit
|
||||||
|
|
||||||
|
override fun getAcceptedIssuers(): Array<X509Certificate> = emptyArray()
|
||||||
|
}
|
||||||
|
val sslContext = SSLContext.getInstance("SSL")
|
||||||
|
sslContext.init(null, arrayOf(trustAllCerts), SecureRandom())
|
||||||
|
val sslSocketFactory: SSLSocketFactory = sslContext.socketFactory
|
||||||
|
builder.sslSocketFactory(sslSocketFactory, trustAllCerts)
|
||||||
|
builder.hostnameVerifier { _, _ -> true }
|
||||||
|
}.onFailure {
|
||||||
|
it.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user