From 8e34cc2a8ebd545345269e7d1040e2f88ee81b99 Mon Sep 17 00:00:00 2001 From: Basara-Hatake <53382992+Basara-Hatake@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:51:58 +0100 Subject: [PATCH] leviatanscans replace random url part (#9717) --- .../leviatanscans/src/LeviatanScansFactory.kt | 39 +++++++++++++++++++ .../multisrc/madara/MadaraGenerator.kt | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/multisrc/overrides/madara/leviatanscans/src/LeviatanScansFactory.kt b/multisrc/overrides/madara/leviatanscans/src/LeviatanScansFactory.kt index 765cac2ec..04857b198 100644 --- a/multisrc/overrides/madara/leviatanscans/src/LeviatanScansFactory.kt +++ b/multisrc/overrides/madara/leviatanscans/src/LeviatanScansFactory.kt @@ -3,6 +3,9 @@ package eu.kanade.tachiyomi.extension.all.leviatanscans import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceFactory +import eu.kanade.tachiyomi.source.model.SChapter +import eu.kanade.tachiyomi.source.model.SManga +import org.jsoup.nodes.Element class LeviatanScansFactory : SourceFactory { override fun createSources(): List = listOf( @@ -12,7 +15,43 @@ class LeviatanScansFactory : SourceFactory { } class LeviatanScansEN : Madara("Leviatan Scans", "https://leviatanscans.com", "en") { override val useNewChapterEndpoint: Boolean = true + + override fun popularMangaFromElement(element: Element) = + replaceRandomUrlPartInManga(super.popularMangaFromElement(element)) + + override fun latestUpdatesFromElement(element: Element) = + replaceRandomUrlPartInManga(super.latestUpdatesFromElement(element)) + + override fun searchMangaFromElement(element: Element) = + replaceRandomUrlPartInManga(super.searchMangaFromElement(element)) + + override fun chapterFromElement(element: Element) = + replaceRandomUrlPartInChapter(super.chapterFromElement(element)) } class LeviatanScansES : Madara("Leviatan Scans", "https://es.leviatanscans.com", "es") { override val useNewChapterEndpoint: Boolean = true + + override fun popularMangaFromElement(element: Element) = + replaceRandomUrlPartInManga(super.popularMangaFromElement(element)) + + override fun latestUpdatesFromElement(element: Element) = + replaceRandomUrlPartInManga(super.latestUpdatesFromElement(element)) + + override fun searchMangaFromElement(element: Element) = + replaceRandomUrlPartInManga(super.searchMangaFromElement(element)) + + override fun chapterFromElement(element: Element) = + replaceRandomUrlPartInChapter(super.chapterFromElement(element)) +} + +fun Madara.replaceRandomUrlPartInManga(manga: SManga): SManga { + val split = manga.url.split("/") + manga.url = split.slice(split.indexOf("manga") until split.size).joinToString("/", "/") + return manga +} + +fun Madara.replaceRandomUrlPartInChapter(chapter: SChapter): SChapter { + val split = chapter.url.split("/") + chapter.url = baseUrl + split.slice(split.indexOf("manga") until split.size).joinToString("/", "/") + 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 ad11e450f..6578a9f4c 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 @@ -13,7 +13,7 @@ class MadaraGenerator : ThemeSourceGenerator { override val baseVersionCode: Int = 11 override val sources = listOf( - MultiLang("Leviatan Scans", "https://leviatanscans.com", listOf("en", "es"), className = "LeviatanScansFactory", overrideVersionCode = 7), + MultiLang("Leviatan Scans", "https://leviatanscans.com", listOf("en", "es"), className = "LeviatanScansFactory", overrideVersionCode = 8), 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),