From 980c3e0b0961bb364c49dacf7b35ef57d76e4f6e Mon Sep 17 00:00:00 2001 From: no bk Date: Sun, 4 Apr 2021 13:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E6=96=87=E4=BB=B6=E5=90=8D'=E4=B9=A6?= =?UTF-8?q?=E5=90=8D=20by=20=E4=BD=9C=E8=80=85.txt'=E6=88=96.epub=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E4=B9=A6=E5=90=8D=E3=80=81=E4=BD=9C=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/localBook/LocalBook.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) 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,