diff --git a/src/pt/opex/build.gradle b/src/pt/opex/build.gradle index a6c00894d..074858e04 100644 --- a/src/pt/opex/build.gradle +++ b/src/pt/opex/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'One Piece Ex' pkgNameSuffix = 'pt.opex' extClass = '.OnePieceEx' - extVersionCode = 6 + extVersionCode = 7 } apply from: "$rootDir/common.gradle" diff --git a/src/pt/opex/src/eu/kanade/tachiyomi/extension/pt/opex/OnePieceEx.kt b/src/pt/opex/src/eu/kanade/tachiyomi/extension/pt/opex/OnePieceEx.kt index c7e697210..00428f5b0 100644 --- a/src/pt/opex/src/eu/kanade/tachiyomi/extension/pt/opex/OnePieceEx.kt +++ b/src/pt/opex/src/eu/kanade/tachiyomi/extension/pt/opex/OnePieceEx.kt @@ -14,11 +14,9 @@ import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive import okhttp3.Headers import okhttp3.HttpUrl.Companion.toHttpUrl -import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response -import okhttp3.ResponseBody.Companion.toResponseBody import org.jsoup.nodes.Document import org.jsoup.nodes.Element import rx.Observable @@ -37,8 +35,14 @@ class OnePieceEx : ParsedHttpSource() { override val supportsLatest = false override val client: OkHttpClient = network.cloudflareClient.newBuilder() - .addInterceptor(::bypassHttp103Intercept) .rateLimit(1, 2, TimeUnit.SECONDS) + .apply { + val interceptors = interceptors() + val index = interceptors.indexOfFirst { "Brotli" in it.javaClass.simpleName } + if (index >= 0) { + interceptors.add(interceptors.removeAt(index)) + } + } .build() override fun headersBuilder(): Headers.Builder = Headers.Builder() @@ -230,33 +234,6 @@ class OnePieceEx : ParsedHttpSource() { override fun latestUpdatesNextPageSelector() = throw UnsupportedOperationException("Not used") - private fun bypassHttp103Intercept(chain: Interceptor.Chain): Response { - val request = chain.request() - - if (request.url.pathSegments[0] != "mangas") { - return chain.proceed(request) - } - - val bypasserUrl = "https://translate.google.com/translate".toHttpUrl().newBuilder() - .addQueryParameter("pto", "op") - .addQueryParameter("u", request.url.toString()) - .build() - - val bypasserRequest = request.newBuilder() - .url(bypasserUrl) - .build() - - val bypasserResponse = chain.proceed(bypasserRequest) - val fixedBody = bypasserResponse.body.string() - .replace("onepieceex-net.translate.goog", baseUrl.removePrefix("https://")) - .toResponseBody(bypasserResponse.body.contentType()) - - return bypasserResponse.newBuilder() - .body(fixedBody) - .request(request) - .build() - } - companion object { private const val ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9," + "image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"