From 74b8b601c585cf5c32e3ada658e6ffd43eaba111 Mon Sep 17 00:00:00 2001 From: Alessandro Jean Date: Thu, 3 Jun 2021 21:27:11 -0300 Subject: [PATCH] Fix temporary blocking for a source and add a message. (#7437) --- .../src/IchirinNoHanaYuri.kt | 21 ++++++++++++++++++- .../multisrc/madara/MadaraGenerator.kt | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/multisrc/overrides/madara/ichirinnohanayuri/src/IchirinNoHanaYuri.kt b/multisrc/overrides/madara/ichirinnohanayuri/src/IchirinNoHanaYuri.kt index 2ac930a49..1008acaf3 100644 --- a/multisrc/overrides/madara/ichirinnohanayuri/src/IchirinNoHanaYuri.kt +++ b/multisrc/overrides/madara/ichirinnohanayuri/src/IchirinNoHanaYuri.kt @@ -2,7 +2,9 @@ package eu.kanade.tachiyomi.extension.pt.ichirinnohanayuri import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor import eu.kanade.tachiyomi.multisrc.madara.Madara +import okhttp3.Headers import okhttp3.OkHttpClient +import java.io.IOException import java.text.SimpleDateFormat import java.util.Locale import java.util.concurrent.TimeUnit @@ -15,6 +17,23 @@ class IchirinNoHanaYuri : Madara( ) { override val client: OkHttpClient = super.client.newBuilder() - .addInterceptor(RateLimitInterceptor(1, 1, TimeUnit.SECONDS)) + .addInterceptor(RateLimitInterceptor(1, 2, TimeUnit.SECONDS)) + .addInterceptor { chain -> + val response = chain.proceed(chain.request()) + + if (response.code == 403) { + response.close() + throw IOException(BLOCKING_MESSAGE) + } + + response + } .build() + + override fun headersBuilder(): Headers.Builder = Headers.Builder() + + companion object { + private const val BLOCKING_MESSAGE = "O site está bloqueando o Tachiyomi. " + + "Migre para outra fonte caso o problema persistir." + } } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt index 7b1729c8f..e28510407 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt @@ -75,7 +75,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("Hiperdex", "https://hiperdex.com", "en", isNsfw = true, overrideVersionCode = 1), SingleLang("Hscans", "https://hscans.com", "en", overrideVersionCode = 1), SingleLang("Hunter Fansub", "https://hunterfansub.com", "es"), - SingleLang("Ichirin No Hana Yuri", "https://ichirinnohanayuri.com.br", "pt-BR", overrideVersionCode = 1), + SingleLang("Ichirin No Hana Yuri", "https://ichirinnohanayuri.com.br", "pt-BR", overrideVersionCode = 2), SingleLang("Immortal Updates", "https://immortalupdates.com", "en", overrideVersionCode = 1), SingleLang("Império dos Otakus", "https://imperiodosotakus.tk", "pt-BR", className = "ImperioDosOtakus"), SingleLang("IsekaiScan.com", "https://isekaiscan.com", "en", className = "IsekaiScanCom", overrideVersionCode = 2),