mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-20 16:01:14 +01:00
Fix universal captcha detection
This commit is contained in:
@@ -3,7 +3,10 @@ package eu.kanade.tachiyomi.network
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import exh.log.maybeInjectEHLogger
|
||||
import exh.patch.MANGADEX_DOMAIN
|
||||
import exh.patch.MANGADEX_SOURCE_ID
|
||||
import exh.patch.attachMangaDexLogin
|
||||
import exh.patch.detectCaptchas
|
||||
import okhttp3.*
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
@@ -33,6 +36,7 @@ open class NetworkHelper(context: Context) {
|
||||
open val cloudflareClient = client.newBuilder()
|
||||
.addInterceptor(CloudflareInterceptor(context))
|
||||
.attachMangaDexLogin()
|
||||
.detectCaptchas(context, MANGADEX_SOURCE_ID, listOf(MANGADEX_DOMAIN))
|
||||
.build()
|
||||
|
||||
private fun OkHttpClient.Builder.enableTLS12(): OkHttpClient.Builder {
|
||||
|
||||
@@ -6,9 +6,8 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.network.*
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.*
|
||||
import exh.patch.detectCaptchas
|
||||
import exh.source.DelegatedHttpSource
|
||||
import exh.ui.captcha.BrowserActionActivity
|
||||
import exh.util.interceptAsHtml
|
||||
import okhttp3.*
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
@@ -79,22 +78,10 @@ abstract class HttpSource : CatalogueSource {
|
||||
* Default network client for doing requests.
|
||||
*/
|
||||
open val client: OkHttpClient
|
||||
get() = delegate?.baseHttpClient ?: network.client.newBuilder().addInterceptor { chain ->
|
||||
// Automatic captcha detection
|
||||
val response = chain.proceed(chain.request())
|
||||
if(!response.isSuccessful) {
|
||||
response.interceptAsHtml { doc ->
|
||||
if (doc.getElementsByClass("g-recaptcha").isNotEmpty()) {
|
||||
// Found it, allow the user to solve this thing
|
||||
BrowserActionActivity.launchUniversal(
|
||||
Injekt.get<Application>(),
|
||||
this,
|
||||
chain.request().url().toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
} else response
|
||||
}.build()
|
||||
get() = delegate?.baseHttpClient ?: network.client
|
||||
.newBuilder()
|
||||
.detectCaptchas(Injekt.get<Application>(), id, null)
|
||||
.build()
|
||||
|
||||
/**
|
||||
* Headers builder for requests. Implementations can override this method for custom headers.
|
||||
|
||||
Reference in New Issue
Block a user