Alessandro Jean 219bf0b1d2
Add support to string l10n in Madara (#10814)
* Localize the Madara strings.

* Lint some overrides.

* Add missing comma.

* Fix build error due to final in multilang sources.

* Fix typo in author string.

* Fix a merge conflict.
2022-02-28 16:37:21 -05:00

42 lines
1.5 KiB
Kotlin

package eu.kanade.tachiyomi.extension.pt.sweettimescan
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 org.jsoup.nodes.Element
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.concurrent.TimeUnit
class SweetTimeScan : Madara(
"Sweet Time Scan",
"https://sweetscan.net",
"pt-BR",
SimpleDateFormat("MMMMM dd, yyyy", Locale("pt", "BR"))
) {
override val client: OkHttpClient = super.client.newBuilder()
.addInterceptor(RateLimitInterceptor(1, 2, TimeUnit.SECONDS))
.build()
// 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)
}
// The site uses some image cache plugin that made the thumbnails don't load.
// This removes the plugin site base URL and returns the direct image URL.
override fun imageFromElement(element: Element): String {
return baseUrl + super.imageFromElement(element)?.substringAfter(baseUrl)
}
companion object {
private val NOVEL_REGEX = "novel|livro".toRegex(RegexOption.IGNORE_CASE)
}
}