diff --git a/src/en/zinchanmanga/build.gradle b/src/en/zinchanmanga/build.gradle index ed4cd9a54..9ca5c87da 100644 --- a/src/en/zinchanmanga/build.gradle +++ b/src/en/zinchanmanga/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.ZinChanManga' themePkg = 'madara' baseUrl = 'https://zinchanmanga.net' - overrideVersionCode = 1 + overrideVersionCode = 2 isNsfw = true } diff --git a/src/en/zinchanmanga/src/eu/kanade/tachiyomi/extension/en/zinchanmanga/ZinChanManga.kt b/src/en/zinchanmanga/src/eu/kanade/tachiyomi/extension/en/zinchanmanga/ZinChanManga.kt index 74cb563d2..2acf8a49a 100644 --- a/src/en/zinchanmanga/src/eu/kanade/tachiyomi/extension/en/zinchanmanga/ZinChanManga.kt +++ b/src/en/zinchanmanga/src/eu/kanade/tachiyomi/extension/en/zinchanmanga/ZinChanManga.kt @@ -1,7 +1,52 @@ package eu.kanade.tachiyomi.extension.en.zinchanmanga import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.source.model.SManga +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element class ZinChanManga : Madara("ZinChanManga", "https://zinchanmanga.net", "en") { override val versionId = 2 + override val useNewChapterEndpoint = true + + override fun popularMangaFromElement(element: Element): SManga { + return super.popularMangaFromElement(element).apply { + title = url.urlToTitle() ?: title + } + } + + override fun searchMangaFromElement(element: Element): SManga { + return super.searchMangaFromElement(element).apply { + title = url.urlToTitle() ?: title + } + } + + override fun mangaDetailsParse(document: Document): SManga { + return super.mangaDetailsParse(document).apply { + title = document.location().urlToTitle() ?: title + } + } + + private fun String.urlToTitle(): String? { + val slug = substringAfter("/manga/", "") + .substringBefore("/") + .takeUnless { it.isBlank() } + ?: return null + + val result = StringBuilder(slug.length) + var capitalize = true + for (char in slug) { + result.append( + if (char == '-') { + ' ' + } else if (capitalize) { + char.uppercase() + } else { + char.lowercase() + }, + ) + capitalize = char == '-' + } + return result.toString() + } }