From 6b742f672672e22cfca16c9085f28f8153ec36f5 Mon Sep 17 00:00:00 2001 From: Alexander Chernov Date: Tue, 3 May 2022 21:53:55 +0100 Subject: [PATCH] fix: mmscans theme change (#11724) --- .../overrides/madara/mmscans/src/MMScans.kt | 61 +++++++++++++++++++ .../multisrc/madara/MadaraGenerator.kt | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 multisrc/overrides/madara/mmscans/src/MMScans.kt diff --git a/multisrc/overrides/madara/mmscans/src/MMScans.kt b/multisrc/overrides/madara/mmscans/src/MMScans.kt new file mode 100644 index 000000000..cd9d35bee --- /dev/null +++ b/multisrc/overrides/madara/mmscans/src/MMScans.kt @@ -0,0 +1,61 @@ +package eu.kanade.tachiyomi.extension.en.mmscans + +import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.source.model.SChapter +import eu.kanade.tachiyomi.source.model.SManga +import org.jsoup.nodes.Element + +class MMScans : Madara("MMScans", "https://mm-scans.org", "en") { + override val popularMangaUrlSelector = "div.item-summary a" + override fun chapterListSelector() = "li.chapter-li" + override fun searchMangaSelector() = "a" + + 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.selectFirst("h3").ownText() + } + + 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.selectFirst(".chapter-title-date p").text() + } + chapter.date_upload = parseChapterDate(select(chapterDateSelector()).firstOrNull()?.text()) + } + + return chapter + } + + override fun searchMangaFromElement(element: Element): SManga { + val manga = SManga.create() + + with(element) { + manga.setUrlWithoutDomain(attr("abs:href")) + select("div.post-title h3").first()?.let { + manga.title = it.ownText() + } + select("img").first()?.let { + manga.thumbnail_url = imageFromElement(it) + } + } + + return manga + } +} 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 f8921ab39..0436e122f 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 @@ -173,7 +173,7 @@ class MadaraGenerator : ThemeSourceGenerator { SingleLang("Lumine Scans", "https://luminescans.xyz", "en", overrideVersionCode = 1), SingleLang("MG Komik", "https://mgkomik.com", "id", overrideVersionCode = 2), SingleLang("MHentais", "https://mhentais.com", "pt-BR", isNsfw = true, overrideVersionCode = 1), - SingleLang("MMScans", "https://mm-scans.org", "en", overrideVersionCode = 2), + SingleLang("MMScans", "https://mm-scans.org", "en", overrideVersionCode = 3), SingleLang("MadaraDex", "https://madaradx.org", "en", isNsfw = true), SingleLang("Manga Action", "https://mangaaction.com", "en", overrideVersionCode = 2), SingleLang("Manga Bin", "https://mangabin.com", "en", overrideVersionCode = 1),