diff --git a/src/all/imhentai/build.gradle b/src/all/imhentai/build.gradle index 24689e031..f32e77484 100644 --- a/src/all/imhentai/build.gradle +++ b/src/all/imhentai/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'IMHentai' pkgNameSuffix = 'all.imhentai' extClass = '.IMHentaiFactory' - extVersionCode = 5 + extVersionCode = 6 isNsfw = true } diff --git a/src/all/imhentai/src/eu/kanade/tachiyomi/extension/all/imhentai/IMHentai.kt b/src/all/imhentai/src/eu/kanade/tachiyomi/extension/all/imhentai/IMHentai.kt index 65bc43c63..639f461e3 100644 --- a/src/all/imhentai/src/eu/kanade/tachiyomi/extension/all/imhentai/IMHentai.kt +++ b/src/all/imhentai/src/eu/kanade/tachiyomi/extension/all/imhentai/IMHentai.kt @@ -16,11 +16,13 @@ import okhttp3.HttpUrl.Companion.toHttpUrlOrNull 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 org.jsoup.select.Elements import rx.Observable import uy.kohesive.injekt.injectLazy +import java.io.IOException class IMHentai(override val lang: String, private val imhLang: String) : ParsedHttpSource() { @@ -34,6 +36,23 @@ class IMHentai(override val lang: String, private val imhLang: String) : ParsedH override val supportsLatest = true override val client: OkHttpClient = network.cloudflareClient + .newBuilder() + .addInterceptor( + fun(chain): Response { + val response = chain.proceed(chain.request()) + val responseContentType = response.body!!.contentType() + val responseString = response.body!!.string() + + if (responseString.contains("Overload... Please use the advanced search")) { + response.close() + throw IOException("IMHentai search is overloaded try again later") + } + + return response.newBuilder() + .body(responseString.toResponseBody(responseContentType)) + .build() + } + ).build() // Popular