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'
|
extName = 'DMZJ'
|
||||||
pkgNameSuffix = 'zh.dmzj'
|
pkgNameSuffix = 'zh.dmzj'
|
||||||
extClass = '.Dmzj'
|
extClass = '.Dmzj'
|
||||||
extVersionCode = 32
|
extVersionCode = 33
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -30,13 +30,13 @@ fun parseStatus(status: String): Int = when (status) {
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val chapterNameRegex = Regex("""(?:连载版?)?(\d[.\d]*)([话卷])?""")
|
||||||
|
|
||||||
fun String.formatChapterName(): String {
|
fun String.formatChapterName(): String {
|
||||||
val replaced = removePrefix("连载")
|
val match = chapterNameRegex.matchEntire(this) ?: return this
|
||||||
if (!replaced[0].isDigit()) return replaced
|
val (number, optionalType) = match.destructured
|
||||||
return when (replaced.last()) {
|
val type = optionalType.ifEmpty { "话" }
|
||||||
'话', '卷' -> "第$replaced"
|
return "第$number$type"
|
||||||
else -> replaced
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.toHttps() = "https:" + substringAfter(':')
|
fun String.toHttps() = "https:" + substringAfter(':')
|
||||||
|
|
Loading…
Reference in New Issue