DMZJ: fix chapter name format (#13697)
* DMZJ: fix chapter name format * make regex private
This commit is contained in:
parent
f6a916634b
commit
9b7e28848b
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'DMZJ'
|
||||
pkgNameSuffix = 'zh.dmzj'
|
||||
extClass = '.Dmzj'
|
||||
extVersionCode = 32
|
||||
extVersionCode = 33
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
|
|
@ -30,13 +30,13 @@ fun parseStatus(status: String): Int = when (status) {
|
|||
else -> SManga.UNKNOWN
|
||||
}
|
||||
|
||||
private val chapterNameRegex = Regex("""(?:连载版?)?(\d[.\d]*)([话卷])?""")
|
||||
|
||||
fun String.formatChapterName(): String {
|
||||
val replaced = removePrefix("连载")
|
||||
if (!replaced[0].isDigit()) return replaced
|
||||
return when (replaced.last()) {
|
||||
'话', '卷' -> "第$replaced"
|
||||
else -> replaced
|
||||
}
|
||||
val match = chapterNameRegex.matchEntire(this) ?: return this
|
||||
val (number, optionalType) = match.destructured
|
||||
val type = optionalType.ifEmpty { "话" }
|
||||
return "第$number$type"
|
||||
}
|
||||
|
||||
fun String.toHttps() = "https:" + substringAfter(':')
|
||||
|
|
Loading…
Reference in New Issue