From f7c70577ae9a99ac01c6ad92bfd6f430b9c56c83 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 15 Mar 2025 09:00:25 +0200 Subject: [PATCH] Fix local chapters names (close #1323) --- .../koitharu/kotatsu/local/data/input/LocalMangaParser.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt index 81ac408ff..1aaf24aa9 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt @@ -37,6 +37,7 @@ import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaPage import org.koitharu.kotatsu.parsers.util.longHashCode import org.koitharu.kotatsu.parsers.util.runCatchingCancellable +import org.koitharu.kotatsu.parsers.util.toTitleCase import java.io.File /** @@ -113,7 +114,7 @@ class LocalMangaParser(private val uri: Uri) { }.toString().removePrefix(Path.DIRECTORY_SEPARATOR) MangaChapter( id = "$i$s".longHashCode(), - title = null, + title = p.userFriendlyName(), number = 0f, volume = 0, source = LocalMangaSource, @@ -220,6 +221,10 @@ class LocalMangaParser(private val uri: Uri) { e.printStackTraceDebug() }.getOrNull() + private fun Path.userFriendlyName(): String = name.substringBeforeLast('.') + .replace('_', ' ') + .toTitleCase() + private class FsAndPath( val fileSystem: FileSystem, val path: Path,