From cb7d9ad482568710bea77f2f5eeae3e9d415aa7e Mon Sep 17 00:00:00 2001 From: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> Date: Thu, 7 Apr 2022 05:53:20 -0300 Subject: [PATCH] Add a new source to Madara (closes #11340). (#11351) --- .../overrides/madara/thesugar/src/TheSugar.kt | 22 +++++++++++++++++++ .../tachiyomi/multisrc/madara/Madara.kt | 2 +- .../multisrc/madara/MadaraGenerator.kt | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 multisrc/overrides/madara/thesugar/src/TheSugar.kt diff --git a/multisrc/overrides/madara/thesugar/src/TheSugar.kt b/multisrc/overrides/madara/thesugar/src/TheSugar.kt new file mode 100644 index 000000000..35cf624cb --- /dev/null +++ b/multisrc/overrides/madara/thesugar/src/TheSugar.kt @@ -0,0 +1,22 @@ +package eu.kanade.tachiyomi.extension.pt.thesugar + +import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor +import eu.kanade.tachiyomi.multisrc.madara.Madara +import okhttp3.OkHttpClient +import java.text.SimpleDateFormat +import java.util.Locale +import java.util.concurrent.TimeUnit + +class TheSugar : Madara( + "The Sugar", + "https://thesugarscan.com", + "pt-BR", + SimpleDateFormat("dd/MM/yyyy", Locale("pt", "BR")) +) { + + override val client: OkHttpClient = super.client.newBuilder() + .addInterceptor(RateLimitInterceptor(1, 2, TimeUnit.SECONDS)) + .build() + + override val useNewChapterEndpoint = true +} diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt index ef482fb56..d46179801 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt @@ -784,7 +784,7 @@ abstract class Madara( // Added "title" alternative chapter.date_upload = select("img:not(.thumb)").firstOrNull()?.attr("alt")?.let { parseRelativeDate(it) } ?: select("span a").firstOrNull()?.attr("title")?.let { parseRelativeDate(it) } - ?: parseChapterDate(select("span.chapter-release-date").firstOrNull()?.text()) + ?: parseChapterDate(select("span.chapter-release-date").firstOrNull()?.text()) } return chapter 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 f831e51f9..4b1dc86b6 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 @@ -403,6 +403,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("TeenManhua", "https://teenmanhua.com", "en"), SingleLang("The Beginning After The End", "https://www.thebeginningaftertheend.fr", "fr"), SingleLang("The Guild", "https://theguildscans.com", "en"), + SingleLang("The Sugar", "https://thesugarscan.com", "pt-BR"), SingleLang("TheFluffyHangoutGroup", "https://www.fluffyhangout.club", "en", overrideVersionCode = 2), SingleLang("Three Queens Scanlator", "https://tqscan.com.br", "pt-BR", overrideVersionCode = 3), SingleLang("Tiempo de webeo", "https://tiempodewebeo.com", "es", className = "TiempoDeWebeo", isNsfw = true),