Mangas.in: Optimize unescaping (#193)

Optimize unescaping
This commit is contained in:
bapeey 2024-01-12 14:52:57 -05:00 committed by Draff
parent 8f55b1e8d4
commit e2dc0795c3
2 changed files with 7 additions and 10 deletions

View File

@ -108,28 +108,25 @@ class MangasIn : MMRCMS("Mangas.in", "https://mangas.in", "es") {
} }
private fun String.unescape(): String { private fun String.unescape(): String {
return UNESCAPE_REGEX.replace(this) { return UNESCAPE_REGEX.replace(this, "$1")
it.groupValues[1]
}
} }
private fun String.unescapeJava(): String { private fun String.unescapeJava(): String {
var escaped = this var escaped = this
if (!escaped.contains("\\u")) return escaped if (!escaped.contains("\\u")) return escaped
val builder = StringBuilder()
var processed = ""
var position = escaped.indexOf("\\u") var position = escaped.indexOf("\\u")
while (position != -1) { while (position != -1) {
if (position != 0) { if (position != 0) {
processed += escaped.substring(0, position) builder.append(escaped, 0, position)
} }
val token = escaped.substring(position + 2, position + 6) val token = escaped.substring(position + 2, position + 6)
escaped = escaped.substring(position + 6) escaped = escaped.substring(position + 6)
processed += Integer.parseInt(token, 16).toChar() builder.append(Integer.parseInt(token, 16).toChar())
position = escaped.indexOf("\\u") position = escaped.indexOf("\\u")
} }
processed += escaped builder.append(escaped)
return processed return builder.toString()
} }
private fun String.parseDate(): Long { private fun String.parseDate(): Long {

View File

@ -19,7 +19,7 @@ class MMRCMSGenerator : ThemeSourceGenerator {
SingleLang("Scan VF", "https://www.scan-vf.net", "fr", overrideVersionCode = 1), SingleLang("Scan VF", "https://www.scan-vf.net", "fr", overrideVersionCode = 1),
SingleLang("Komikid", "https://www.komikid.com", "id"), SingleLang("Komikid", "https://www.komikid.com", "id"),
SingleLang("Mangadoor", "https://mangadoor.com", "es", overrideVersionCode = 1), SingleLang("Mangadoor", "https://mangadoor.com", "es", overrideVersionCode = 1),
SingleLang("Mangas.in", "https://mangas.in", "es", isNsfw = true, className = "MangasIn"), SingleLang("Mangas.in", "https://mangas.in", "es", isNsfw = true, className = "MangasIn", overrideVersionCode = 1),
SingleLang("Utsukushii", "https://manga.utsukushii-bg.com", "bg", overrideVersionCode = 1), SingleLang("Utsukushii", "https://manga.utsukushii-bg.com", "bg", overrideVersionCode = 1),
SingleLang("Phoenix-Scans", "https://phoenix-scans.pl", "pl", className = "PhoenixScans", overrideVersionCode = 1), SingleLang("Phoenix-Scans", "https://phoenix-scans.pl", "pl", className = "PhoenixScans", overrideVersionCode = 1),
SingleLang("Lelscan-VF", "https://lelscanvf.cc", "fr", className = "LelscanVF", overrideVersionCode = 2), SingleLang("Lelscan-VF", "https://lelscanvf.cc", "fr", className = "LelscanVF", overrideVersionCode = 2),