From 0e72abab89c1e57b5322c9a2cc3449927f59e053 Mon Sep 17 00:00:00 2001 From: Alessandro Jean Date: Fri, 27 Aug 2021 07:27:13 -0300 Subject: [PATCH] Make RS into a MultiLang ext. (#8857) --- .../madara/reaperscans/src/ReaperScans.kt | 31 -------------- .../src/ReaperScansFactory.kt} | 40 ++++++++++++------- .../multisrc/madara/MadaraGenerator.kt | 3 +- .../IntelijConfigurationGeneratorMain.kt | 2 +- 4 files changed, 28 insertions(+), 48 deletions(-) delete mode 100644 multisrc/overrides/madara/reaperscans/src/ReaperScans.kt rename multisrc/overrides/madara/{reaperscansbr/src/ReaperScansBr.kt => reaperscans/src/ReaperScansFactory.kt} (70%) diff --git a/multisrc/overrides/madara/reaperscans/src/ReaperScans.kt b/multisrc/overrides/madara/reaperscans/src/ReaperScans.kt deleted file mode 100644 index 199c630d6..000000000 --- a/multisrc/overrides/madara/reaperscans/src/ReaperScans.kt +++ /dev/null @@ -1,31 +0,0 @@ -package eu.kanade.tachiyomi.extension.en.reaperscans - -import eu.kanade.tachiyomi.multisrc.madara.Madara -import eu.kanade.tachiyomi.source.model.SChapter -import org.jsoup.nodes.Element - -class ReaperScans : Madara("Reaper Scans", "https://reaperscans.com", "en") { - override val versionId = 2 - - override fun popularMangaSelector() = "div.page-item-detail.manga" - - override fun chapterFromElement(element: Element): SChapter { - val chapter = SChapter.create() - - with(element) { - select(chapterUrlSelector).first()?.let { urlElement -> - chapter.url = urlElement.attr("abs:href").let { - it.substringBefore("?style=paged") + if (!it.endsWith(chapterUrlSuffix)) chapterUrlSuffix else "" - } - chapter.name = urlElement.ownText() - } - // Dates can be part of a "new" graphic or plain text - // Added "title" alternative - chapter.date_upload = select("img").firstOrNull()?.attr("alt")?.let { parseRelativeDate(it) } - ?: select("span a").firstOrNull()?.attr("title")?.let { parseRelativeDate(it) } - ?: parseChapterDate(select("span.chapter-release-date i").firstOrNull()?.text()) - } - - return chapter - } -} diff --git a/multisrc/overrides/madara/reaperscansbr/src/ReaperScansBr.kt b/multisrc/overrides/madara/reaperscans/src/ReaperScansFactory.kt similarity index 70% rename from multisrc/overrides/madara/reaperscansbr/src/ReaperScansBr.kt rename to multisrc/overrides/madara/reaperscans/src/ReaperScansFactory.kt index 4404b99b6..6004db4d3 100644 --- a/multisrc/overrides/madara/reaperscansbr/src/ReaperScansBr.kt +++ b/multisrc/overrides/madara/reaperscans/src/ReaperScansFactory.kt @@ -1,26 +1,24 @@ -package eu.kanade.tachiyomi.extension.pt.reaperscansbr +package eu.kanade.tachiyomi.extension.all.reaperscans import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.source.SourceFactory import eu.kanade.tachiyomi.source.model.SChapter import okhttp3.OkHttpClient import org.jsoup.nodes.Element -import java.text.SimpleDateFormat -import java.util.Locale import java.util.concurrent.TimeUnit -class ReaperScansBr : Madara( - "Reaper Scans (BR)", - "https://reaperscans.com.br", - "pt-BR", - SimpleDateFormat("dd/MM/yyyy", Locale("pt", "BR")) -) { +class ReaperScansFactory : SourceFactory { + override fun createSources() = listOf( + ReaperScansEn(), + ReaperScansBr() + ) +} - override val client: OkHttpClient = super.client.newBuilder() - .addInterceptor(RateLimitInterceptor(1, 2, TimeUnit.SECONDS)) - .build() - - override val altName: String = "Nome alternativo: " +abstract class ReaperScans( + override val baseUrl: String, + override val lang: String +) : Madara("Reaper Scans", baseUrl, lang) { override fun popularMangaSelector() = "div.page-item-detail.manga" @@ -44,3 +42,17 @@ class ReaperScansBr : Madara( return chapter } } + +class ReaperScansEn : ReaperScans("https://reaperscans.com", "en") { + override val versionId = 2 +} + +class ReaperScansBr : ReaperScans("https://reaperscans.com.br", "pt-BR") { + override val id = 7767018058145795388 + + override val client: OkHttpClient = super.client.newBuilder() + .addInterceptor(RateLimitInterceptor(1, 2, TimeUnit.SECONDS)) + .build() + + override val altName: String = "Nome alternativo: " +} 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 88c762cb9..36d812a49 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 @@ -16,6 +16,7 @@ class MadaraGenerator : ThemeSourceGenerator { MultiLang("Leviatan Scans", "https://leviatanscans.com", listOf("en", "es"), className = "LeviatanScansFactory", overrideVersionCode = 7), MultiLang("MangaForFree.net", "https://mangaforfree.net", listOf("en", "ko", "all"), isNsfw = true, className = "MangaForFreeFactory", pkgName = "mangaforfree", overrideVersionCode = 1), MultiLang("Manhwa18.cc", "https://manhwa18.cc", listOf("en", "ko", "all"), isNsfw = true, className = "Manhwa18CcFactory", pkgName = "manhwa18cc"), + MultiLang("Reaper Scans", "https://reaperscans.com", listOf("en", "pt-BR"), className = "ReaperScansFactory", pkgName = "reaperscans", overrideVersionCode = 2), SingleLang("1st Kiss Manga.love", "https://1stkissmanga.love", "en", className = "FirstKissMangaLove"), SingleLang("1st Kiss", "https://1stkissmanga.com", "en", className = "FirstKissManga", pkgName = "firstkissmanga", overrideVersionCode = 5), SingleLang("1st Kiss Manhua", "https://1stkissmanhua.com", "en", className = "FirstKissManhua", overrideVersionCode = 2), @@ -327,8 +328,6 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("RawDEX", "https://rawdex.net", "ko", isNsfw = true, overrideVersionCode = 1), SingleLang("ReadAdult", "https://readadult.net", "en", isNsfw = true), SingleLang("ReadManhua", "https://readmanhua.net", "en", overrideVersionCode = 2), - SingleLang("Reaper Scans", "https://reaperscans.com", "en", overrideVersionCode = 1), - SingleLang("Reaper Scans (BR)", "https://reaperscans.com.br", "pt-BR", className = "ReaperScansBr"), SingleLang("Red Ribbon Scanlator", "https://redribbon.site", "pt-BR", overrideVersionCode = 1), SingleLang("Renascence Scans (Renascans)", "https://new.renascans.com", "en", className = "RenaScans", overrideVersionCode = 1), SingleLang("Reset Scans", "https://reset-scans.com", "en", overrideVersionCode = 3), diff --git a/multisrc/src/main/java/generator/IntelijConfigurationGeneratorMain.kt b/multisrc/src/main/java/generator/IntelijConfigurationGeneratorMain.kt index 4cdf35f4b..f8f875b21 100644 --- a/multisrc/src/main/java/generator/IntelijConfigurationGeneratorMain.kt +++ b/multisrc/src/main/java/generator/IntelijConfigurationGeneratorMain.kt @@ -13,7 +13,7 @@ fun main(args: Array) { // cleanup from past runs File("$userDir/.run").apply { - if(exists()) + if (exists()) deleteRecursively() mkdirs() }