diff --git a/multisrc/overrides/guya/magicaltranslators/res/mipmap-hdpi/ic_launcher.png b/multisrc/overrides/guya/magicaltranslators/res/mipmap-hdpi/ic_launcher.png new file mode 100755 index 000000000..915b10c78 Binary files /dev/null and b/multisrc/overrides/guya/magicaltranslators/res/mipmap-hdpi/ic_launcher.png differ diff --git a/multisrc/overrides/guya/magicaltranslators/res/mipmap-mdpi/ic_launcher.png b/multisrc/overrides/guya/magicaltranslators/res/mipmap-mdpi/ic_launcher.png new file mode 100755 index 000000000..1cd439c14 Binary files /dev/null and b/multisrc/overrides/guya/magicaltranslators/res/mipmap-mdpi/ic_launcher.png differ diff --git a/multisrc/overrides/guya/magicaltranslators/res/mipmap-xhdpi/ic_launcher.png b/multisrc/overrides/guya/magicaltranslators/res/mipmap-xhdpi/ic_launcher.png new file mode 100755 index 000000000..a2b798398 Binary files /dev/null and b/multisrc/overrides/guya/magicaltranslators/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/multisrc/overrides/guya/magicaltranslators/res/mipmap-xxhdpi/ic_launcher.png b/multisrc/overrides/guya/magicaltranslators/res/mipmap-xxhdpi/ic_launcher.png new file mode 100755 index 000000000..b13ecf747 Binary files /dev/null and b/multisrc/overrides/guya/magicaltranslators/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/multisrc/overrides/guya/magicaltranslators/res/mipmap-xxxhdpi/ic_launcher.png b/multisrc/overrides/guya/magicaltranslators/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100755 index 000000000..170d2ead7 Binary files /dev/null and b/multisrc/overrides/guya/magicaltranslators/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/multisrc/overrides/guya/magicaltranslators/res/web_hi_res_512.png b/multisrc/overrides/guya/magicaltranslators/res/web_hi_res_512.png new file mode 100755 index 000000000..f14298820 Binary files /dev/null and b/multisrc/overrides/guya/magicaltranslators/res/web_hi_res_512.png differ diff --git a/multisrc/overrides/guya/magicaltranslators/src/MagicalTranslators.kt b/multisrc/overrides/guya/magicaltranslators/src/MagicalTranslators.kt new file mode 100644 index 000000000..6f664276a --- /dev/null +++ b/multisrc/overrides/guya/magicaltranslators/src/MagicalTranslators.kt @@ -0,0 +1,42 @@ +package eu.kanade.tachiyomi.extension.all.magicaltranslators + +import eu.kanade.tachiyomi.multisrc.guya.Guya +import eu.kanade.tachiyomi.source.Source +import eu.kanade.tachiyomi.source.SourceFactory +import eu.kanade.tachiyomi.source.model.MangasPage +import okhttp3.Response + +class MagicalTranslatorsFactory : SourceFactory { + override fun createSources(): List = listOf( + MagicalTranslatorsEN(), + MagicalTranslatorsPL(), + ) +} + +abstract class MagicalTranslatorsCommon(lang: String) : + Guya("Magical Translators", "https://mahoushoujobu.com", lang) { + protected abstract fun filterMangasPage(mangasPage: MangasPage): MangasPage + override fun popularMangaParse(response: Response): MangasPage = + filterMangasPage(super.popularMangaParse(response)) + + override fun proxySearchMangaParse(response: Response, slug: String): MangasPage = + filterMangasPage(super.proxySearchMangaParse(response, slug)) + + override fun searchMangaParseWithSlug(response: Response, slug: String): MangasPage = + filterMangasPage(super.searchMangaParseWithSlug(response, slug)) + + override fun searchMangaParse(response: Response, slug: String): MangasPage = + filterMangasPage(super.searchMangaParse(response, slug)) +} + +class MagicalTranslatorsEN : MagicalTranslatorsCommon("en") { + override fun filterMangasPage(mangasPage: MangasPage): MangasPage = mangasPage.copy( + mangas = mangasPage.mangas.filterNot { it.url.endsWith("-PL") } + ) +} + +class MagicalTranslatorsPL : MagicalTranslatorsCommon("pl") { + override fun filterMangasPage(mangasPage: MangasPage): MangasPage = mangasPage.copy( + mangas = mangasPage.mangas.filter { it.url.endsWith("-PL") } + ) +} diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/Guya.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/Guya.kt index 546c113cd..ae472b72f 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/Guya.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/Guya.kt @@ -222,7 +222,7 @@ abstract class Guya( throw Exception("Unused.") } - private fun searchMangaParseWithSlug(response: Response, slug: String): MangasPage { + protected open fun searchMangaParseWithSlug(response: Response, slug: String): MangasPage { val results = JSONObject(response.body!!.string()) val mangaIter = results.keys() val truncatedJSON = JSONObject() @@ -239,7 +239,7 @@ abstract class Guya( return parseManga(truncatedJSON) } - private fun searchMangaParse(response: Response, query: String): MangasPage { + protected open fun searchMangaParse(response: Response, query: String): MangasPage { val res = response.body!!.string() val json = JSONObject(res) val truncatedJSON = JSONObject() @@ -348,7 +348,7 @@ abstract class Guya( return proxySeriesRequest(query) } - private fun proxySearchMangaParse(response: Response, query: String): MangasPage { + protected open fun proxySearchMangaParse(response: Response, query: String): MangasPage { return MangasPage( arrayListOf(parseMangaFromJson(JSONObject(response.body!!.string()), query)), false diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/GuyaGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/GuyaGenerator.kt index 3e55f5567..66c206641 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/GuyaGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/GuyaGenerator.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.multisrc.guya import generator.ThemeSourceData.SingleLang +import generator.ThemeSourceData.MultiLang import generator.ThemeSourceGenerator class GuyaGenerator : ThemeSourceGenerator { @@ -16,6 +17,7 @@ class GuyaGenerator : ThemeSourceGenerator { SingleLang("Danke fürs Lesen", "https://danke.moe", "en", className = "DankeFursLesen"), SingleLang("Colored Council", "https://coloredcouncil.moe", "en"), SingleLang("Hachirumi", "https://hachirumi.com", "en", isNsfw = true), + MultiLang("Magical Translators", "https://mahoushoujobu.com", listOf("en", "pl"), className = "MagicalTranslatorsFactory"), ) companion object { @JvmStatic