diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt index 19e293b2b..142571054 100644 --- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt +++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt @@ -72,6 +72,16 @@ object LocalBook { if (smhStart != -1 && smhEnd != -1) { name = (name.substring(smhStart + 1, smhEnd)) } + if (author == "" && fileName.contains(" by ")) { + val rstr = fileName.reversed() + // find last ' by ' near '.txt' or '.epub' using reversed string + val pattern = """^(txt|bupe)\.(.*) yb (.*)$""".toRegex() + val matches = pattern.findAll(input = rstr) + matches.forEach { matchResult -> + name = matchResult.groupValues[3].reversed() + author = matchResult.groupValues[2].reversed() + } + } val book = Book( bookUrl = path, name = name,