From 267cc7b988b0f747d35f7d06ef74f209675a15e8 Mon Sep 17 00:00:00 2001 From: Alessandro Jean Date: Thu, 6 May 2021 11:25:27 -0300 Subject: [PATCH] Add a new source to Madara (closes #6845). (#6865) --- .../fudidoscanlator/src/FudidoScanlator.kt | 71 +++++++++++++++++++ .../multisrc/madara/MadaraGenerator.kt | 1 + 2 files changed, 72 insertions(+) create mode 100644 multisrc/overrides/madara/fudidoscanlator/src/FudidoScanlator.kt diff --git a/multisrc/overrides/madara/fudidoscanlator/src/FudidoScanlator.kt b/multisrc/overrides/madara/fudidoscanlator/src/FudidoScanlator.kt new file mode 100644 index 000000000..58d3c6066 --- /dev/null +++ b/multisrc/overrides/madara/fudidoscanlator/src/FudidoScanlator.kt @@ -0,0 +1,71 @@ +package eu.kanade.tachiyomi.extension.pt.fudidoscanlator + +import eu.kanade.tachiyomi.annotations.Nsfw +import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor +import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.source.model.MangasPage +import okhttp3.OkHttpClient +import okhttp3.Response +import java.text.SimpleDateFormat +import java.util.Locale +import java.util.concurrent.TimeUnit + +@Nsfw +class FudidoScanlator : Madara( + "Fudido Scanlator", + "https://fudidoscan.com", + "pt-BR", + SimpleDateFormat("MMMMM dd, yyyy", Locale("pt", "BR")) +) { + + override val client: OkHttpClient = super.client.newBuilder() + .addInterceptor(RateLimitInterceptor(1, 1, TimeUnit.SECONDS)) + .build() + + override fun popularMangaSelector() = "div.page-item-detail.manga" + + // The source has novels in text format, so we need to filter them. + override fun searchMangaParse(response: Response): MangasPage { + val mangaPage = super.searchMangaParse(response) + val filteredResult = mangaPage.mangas.filter { it.title.contains(NOVEL_REGEX).not() } + + return MangasPage(filteredResult, mangaPage.hasNextPage) + } + + // [...document.querySelectorAll('div.genres li a')] + // .map(x => `Genre("${x.innerText.slice(1, -4)}", "${x.href.replace(/.*-genre\/(.*)\//, '$1')}")`) + // .join(',\n') + override fun getGenreList(): List = listOf( + Genre("Ação", "acao"), + Genre("Artes Marciais", "artes-marciais"), + Genre("Aventura", "aventura"), + Genre("Comédia", "comedia"), + Genre("Drama", "drama"), + Genre("Ecchi", "ecchi"), + Genre("Escolar", "escolar"), + Genre("Fantasia ", "fantasia"), + Genre("Ficção", "ficcao"), + Genre("Harém", "harem"), + Genre("Horror", "horror"), + Genre("Isekai", "isekai"), + Genre("Josei", "josei"), + Genre("Magia ", "magia"), + Genre("Mistério", "misterio"), + Genre("Protagonista badass", "protagonista-badass"), + Genre("Psicológico", "psicologico"), + Genre("Romance", "romance"), + Genre("Seinen", "seinen"), + Genre("Shoujo", "shoujo"), + Genre("Shounen", "shounen"), + Genre("Slice of Life", "slice-of-life"), + Genre("Sobrenatural", "sobrenatural"), + Genre("Super Poderes", "super-poderes"), + Genre("Suspense", "suspense"), + Genre("Yaoi", "yaoi"), + Genre("Yuri", "yuri") + ) + + companion object { + private val NOVEL_REGEX = "novel|livro".toRegex(RegexOption.IGNORE_CASE) + } +} 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 ada79cc5d..69a6006f9 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 @@ -267,6 +267,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("MangaYami", "https://www.mangayami.club", "en", overrideVersionCode = 1), SingleLang("Manga Fenix", "https://manga-fenix.com", "es"), SingleLang("Manga Mitsu", "https://mangamitsu.com", "en", isNsfw = true, overrideVersionCode = 1), + SingleLang("Fudido Scanlator", "https://fudidoscan.com", "pt-BR", isNsfw = true) ) companion object {