From b3220a05d129c001512cc3fbf2bcf859da7baa96 Mon Sep 17 00:00:00 2001 From: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> Date: Sat, 27 Aug 2022 17:52:58 -0300 Subject: [PATCH] Add two new sources to Madara. (#13232) --- .../madara/mryaoifansub/src/MrYaoiFansub.kt | 40 +++++++++++++++++++ .../madara/portalyaoi/src/PortalYaoi.kt | 20 ++++++++++ .../multisrc/madara/MadaraGenerator.kt | 2 + 3 files changed, 62 insertions(+) create mode 100644 multisrc/overrides/madara/mryaoifansub/src/MrYaoiFansub.kt create mode 100644 multisrc/overrides/madara/portalyaoi/src/PortalYaoi.kt diff --git a/multisrc/overrides/madara/mryaoifansub/src/MrYaoiFansub.kt b/multisrc/overrides/madara/mryaoifansub/src/MrYaoiFansub.kt new file mode 100644 index 000000000..fd2755150 --- /dev/null +++ b/multisrc/overrides/madara/mryaoifansub/src/MrYaoiFansub.kt @@ -0,0 +1,40 @@ +package eu.kanade.tachiyomi.extension.pt.mryaoifansub + +import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.network.interceptor.rateLimit +import okhttp3.Interceptor +import okhttp3.OkHttpClient +import okhttp3.Response +import okhttp3.internal.closeQuietly +import java.io.IOException +import java.text.SimpleDateFormat +import java.util.Locale +import java.util.concurrent.TimeUnit + +class MrYaoiFansub : Madara( + "MR Yaoi Fansub", + "https://mrtenzus.com", + "pt-BR", + SimpleDateFormat("dd/MM/yyyy", Locale("pt", "BR")) +) { + + override val client: OkHttpClient = super.client.newBuilder() + .addInterceptor(::loginCheckIntercept) + .rateLimit(1, 2, TimeUnit.SECONDS) + .build() + + private fun loginCheckIntercept(chain: Interceptor.Chain): Response { + val response = chain.proceed(chain.request()) + + if (response.request.url.queryParameter("password-protected").isNullOrEmpty()) { + return response + } + + response.closeQuietly() + throw IOException(LOGIN_THROUGH_WEBVIEW_ERROR) + } + + companion object { + private const val LOGIN_THROUGH_WEBVIEW_ERROR = "Autentique-se pela WebView para usar a extensão." + } +} diff --git a/multisrc/overrides/madara/portalyaoi/src/PortalYaoi.kt b/multisrc/overrides/madara/portalyaoi/src/PortalYaoi.kt new file mode 100644 index 000000000..353f45aaf --- /dev/null +++ b/multisrc/overrides/madara/portalyaoi/src/PortalYaoi.kt @@ -0,0 +1,20 @@ +package eu.kanade.tachiyomi.extension.pt.portalyaoi + +import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.network.interceptor.rateLimit +import okhttp3.OkHttpClient +import java.text.SimpleDateFormat +import java.util.Locale +import java.util.concurrent.TimeUnit + +class PortalYaoi : Madara( + "Portal Yaoi", + "https://portalyaoi.com", + "pt-BR", + SimpleDateFormat("dd/MM/yyyy", Locale("pt", "BR")) +) { + + override val client: OkHttpClient = super.client.newBuilder() + .rateLimit(1, 2, TimeUnit.SECONDS) + .build() +} 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 6a0631112..a4ce7f6fb 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 @@ -353,6 +353,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("Momo no Hana Scan", "https://momonohanascan.com", "pt-BR", className = "MomoNoHanaScan", overrideVersionCode = 1), SingleLang("MonarcaManga", "https://monarcamanga.com", "es"), SingleLang("Mortals Groove", "https://mortalsgroove.com", "en", overrideVersionCode = 1), + SingleLang("MR Yaoi Fansub", "https://mrtenzus.com", "pt-BR", isNsfw = true, className = "MrYaoiFansub"), SingleLang("Muctau", "https://muctau.com", "en", overrideVersionCode = 1), SingleLang("MurimScan", "https://murimscan.run", "en", isNsfw = true), SingleLang("MyKomiks", "https://mykomiks.fun", "en", overrideVersionCode = 2), @@ -383,6 +384,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("PoManga", "https://pomanga.com", "en"), SingleLang("PornComix", "https://www.porncomixonline.net", "en", isNsfw = true, overrideVersionCode = 1), SingleLang("Pornwha", "https://pornwha.com", "en", isNsfw = true, overrideVersionCode = 1), + SingleLang("Portal Yaoi", "https://portalyaoi.com", "pt-BR", isNsfw = true), SingleLang("Prisma Hentais", "https://prismahentai.com", "pt-BR", isNsfw = true), SingleLang("Prisma Scans", "https://prismascans.net", "pt-BR", overrideVersionCode = 2), SingleLang("Projeto Scanlator", "https://projetoscanlator.com", "pt-BR", overrideVersionCode = 3),