From 38188d73d849c4f19629daa14d6914805c23fd65 Mon Sep 17 00:00:00 2001 From: Rolando Lecca <90949336+bapeey@users.noreply.github.com> Date: Tue, 6 Jun 2023 04:20:51 -0500 Subject: [PATCH] Update RagnarokScan (#16644) * Custom Madara theme * Lint --- .../madara/ragnarokscan/src/RagnarokScan.kt | 75 ++++++++++++++++++- .../multisrc/madara/MadaraGenerator.kt | 2 +- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/multisrc/overrides/madara/ragnarokscan/src/RagnarokScan.kt b/multisrc/overrides/madara/ragnarokscan/src/RagnarokScan.kt index 48185dbb3..8ffac26c9 100644 --- a/multisrc/overrides/madara/ragnarokscan/src/RagnarokScan.kt +++ b/multisrc/overrides/madara/ragnarokscan/src/RagnarokScan.kt @@ -1,7 +1,80 @@ package eu.kanade.tachiyomi.extension.es.ragnarokscan import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.multisrc.madara.WordSet +import eu.kanade.tachiyomi.source.model.SChapter +import eu.kanade.tachiyomi.source.model.SManga +import org.jsoup.nodes.Element +import java.text.ParseException import java.text.SimpleDateFormat import java.util.Locale -class RagnarokScan : Madara("RagnarokScan", "https://ragnarokscan.com", "es", SimpleDateFormat("MMMMM dd, yyyy", Locale("es"))) +class RagnarokScan : Madara( + "RagnarokScan", + "https://ragnarokscan.com", + "es", + SimpleDateFormat("MMMMM dd, yyyy", Locale("es")), +) { + // "mangaSubstring" has changed, so users will have to migrate + override val versionId = 2 + override val mangaSubString = "series" + override val chapterUrlSuffix = "" + + override fun popularMangaSelector() = "div#series-card:has(a:not([href*='bilibilicomics.com']))" + override val popularMangaUrlSelector = "a.series-link" + + override val mangaDetailsSelectorTag = "div.tags-content a.notUsed" // Source use this for the scanlator + override val mangaDetailsSelectorStatus = "div.post-status div.summary-content" + + override fun popularMangaFromElement(element: Element): SManga { + val manga = SManga.create() + + with(element) { + select(popularMangaUrlSelector).first()?.let { + manga.setUrlWithoutDomain(it.attr("abs:href")) + manga.title = it.attr("title") + } + + select("img").first()?.let { + manga.thumbnail_url = imageFromElement(it) + } + } + + return 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.select("p.chapter-manhwa-title").text() + chapter.date_upload = parseChapterDate(select("span.chapter-release-date").text()) + } + } + + return chapter + } + + override fun parseChapterDate(date: String?): Long { + date ?: return 0 + + fun SimpleDateFormat.tryParse(string: String): Long { + return try { + parse(string)?.time ?: 0 + } catch (_: ParseException) { + 0 + } + } + + return when { + WordSet("minuto", "minutos", "hora", "horas", "día", "días").endsWith(date) -> { + parseRelativeDate(date) + } + else -> SimpleDateFormat("MMMMM dd, yyyy", Locale("es")).tryParse(date) + } + } +} 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 00a77ecd0..87a12d96f 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 @@ -345,7 +345,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("Projeto Scanlator", "https://projetoscanlator.com", "pt-BR", overrideVersionCode = 3), SingleLang("ROG Mangás", "https://rogmangas.com", "pt-BR", pkgName = "mangasoverall", className = "RogMangas", overrideVersionCode = 1), SingleLang("Ragnarok Scanlation", "https://ragnarokscanlation.com", "es", className = "RagnarokScanlation"), - SingleLang("RagnarokScan", "https://ragnarokscan.com", "es"), + SingleLang("RagnarokScan", "https://ragnarokscan.com", "es", overrideVersionCode = 1), SingleLang("Rainbow Fairy Scan", "https://rainbowfairyscan.com", "pt-BR"), SingleLang("Random Scan", "https://randomscans.com", "pt-BR", overrideVersionCode = 5), SingleLang("RawDEX", "https://rawdex.net", "ko", isNsfw = true, overrideVersionCode = 1),