mirror of
https://github.com/keiyoushi/extensions-source.git
synced 2024-11-22 10:22:47 +01:00
Clean ZinChanManga.com titles (#5646)
This commit is contained in:
parent
fea1087e24
commit
a14fabf78f
@ -3,7 +3,7 @@ ext {
|
||||
extClass = '.ZinChanMangaCom'
|
||||
themePkg = 'madara'
|
||||
baseUrl = 'https://zinchanmanga.com'
|
||||
overrideVersionCode = 0
|
||||
overrideVersionCode = 1
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,51 @@
|
||||
package eu.kanade.tachiyomi.extension.en.zinchanmangacom
|
||||
|
||||
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 ZinChanMangaCom : Madara("ZinChanManga.com", "https://zinchanmanga.com", "en")
|
||||
class ZinChanMangaCom : Madara("ZinChanManga.com", "https://zinchanmanga.com", "en") {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user