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 9c28e7b16..740e2e150 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 @@ -35,7 +35,6 @@ import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaPage import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.parsers.util.runCatchingCancellable -import org.koitharu.kotatsu.parsers.util.toCamelCase import org.koitharu.kotatsu.parsers.util.toFileNameSafe import java.io.File @@ -85,7 +84,7 @@ class LocalMangaParser(private val uri: Uri) { }, ) } else { - val title = rootFile.nameWithoutExtension.replace("_", " ").toCamelCase() + val title = rootFile.name.fileNameToTitle() val coverEntry = fileSystem.findFirstImage(rootPath) val mimeTypeMap = MimeTypeMap.getSingleton() Manga( @@ -116,7 +115,7 @@ class LocalMangaParser(private val uri: Uri) { }.toString().removePrefix(Path.DIRECTORY_SEPARATOR) MangaChapter( id = "$i$s".longHashCode(), - name = s.ifEmpty { title }, + name = s.fileNameToTitle().ifEmpty { title }, number = 0f, volume = 0, source = LocalMangaSource, @@ -275,6 +274,10 @@ class LocalMangaParser(private val uri: Uri) { Path.DIRECTORY_SEPARATOR + this }.toPath() + private fun String.fileNameToTitle() = substringBeforeLast('.') + .replace('_', ' ') + .replaceFirstChar { it.uppercase() } + private fun Manga.copyInternal( url: String = this.url, coverUrl: String = this.coverUrl,