Add Magical Translators source (#7941)

This commit is contained in:
qtcomput3 2021-07-02 20:27:05 -05:00 committed by GitHub
parent 8935d7b899
commit 2635d10527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -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<Source> = 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") }
)
}

View File

@ -222,7 +222,7 @@ abstract class Guya(
throw Exception("Unused.") 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 results = JSONObject(response.body!!.string())
val mangaIter = results.keys() val mangaIter = results.keys()
val truncatedJSON = JSONObject() val truncatedJSON = JSONObject()
@ -239,7 +239,7 @@ abstract class Guya(
return parseManga(truncatedJSON) 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 res = response.body!!.string()
val json = JSONObject(res) val json = JSONObject(res)
val truncatedJSON = JSONObject() val truncatedJSON = JSONObject()
@ -348,7 +348,7 @@ abstract class Guya(
return proxySeriesRequest(query) return proxySeriesRequest(query)
} }
private fun proxySearchMangaParse(response: Response, query: String): MangasPage { protected open fun proxySearchMangaParse(response: Response, query: String): MangasPage {
return MangasPage( return MangasPage(
arrayListOf(parseMangaFromJson(JSONObject(response.body!!.string()), query)), arrayListOf(parseMangaFromJson(JSONObject(response.body!!.string()), query)),
false false

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.multisrc.guya package eu.kanade.tachiyomi.multisrc.guya
import generator.ThemeSourceData.SingleLang import generator.ThemeSourceData.SingleLang
import generator.ThemeSourceData.MultiLang
import generator.ThemeSourceGenerator import generator.ThemeSourceGenerator
class GuyaGenerator : ThemeSourceGenerator { class GuyaGenerator : ThemeSourceGenerator {
@ -16,6 +17,7 @@ class GuyaGenerator : ThemeSourceGenerator {
SingleLang("Danke fürs Lesen", "https://danke.moe", "en", className = "DankeFursLesen"), SingleLang("Danke fürs Lesen", "https://danke.moe", "en", className = "DankeFursLesen"),
SingleLang("Colored Council", "https://coloredcouncil.moe", "en"), SingleLang("Colored Council", "https://coloredcouncil.moe", "en"),
SingleLang("Hachirumi", "https://hachirumi.com", "en", isNsfw = true), SingleLang("Hachirumi", "https://hachirumi.com", "en", isNsfw = true),
MultiLang("Magical Translators", "https://mahoushoujobu.com", listOf("en", "pl"), className = "MagicalTranslatorsFactory"),
) )
companion object { companion object {
@JvmStatic @JvmStatic