|
|
@ -128,9 +128,9 @@ object LocalBook { |
|
|
|
val m1 = Pattern |
|
|
|
val m1 = Pattern |
|
|
|
.compile("(.*?)《([^《》]+)》(.*)") |
|
|
|
.compile("(.*?)《([^《》]+)》(.*)") |
|
|
|
.matcher(tempFileName) |
|
|
|
.matcher(tempFileName) |
|
|
|
//匹配 书名 by 作者名.txt |
|
|
|
//匹配 书名 作者:作者名.txt |
|
|
|
val m2 = Pattern |
|
|
|
val m2 = Pattern |
|
|
|
.compile("(^)(.+) by (.+)$") |
|
|
|
.compile("(^)(.+) 作者:(.+)$") |
|
|
|
.matcher(tempFileName) |
|
|
|
.matcher(tempFileName) |
|
|
|
|
|
|
|
|
|
|
|
(m1.takeIf { m1.find() } ?: m2.takeIf { m2.find() }).run { |
|
|
|
(m1.takeIf { m1.find() } ?: m2.takeIf { m2.find() }).run { |
|
|
@ -152,13 +152,13 @@ object LocalBook { |
|
|
|
name = bookMess["name"] ?: tempFileName |
|
|
|
name = bookMess["name"] ?: tempFileName |
|
|
|
author = bookMess["author"]?.takeIf { it.length != tempFileName.length } ?: "" |
|
|
|
author = bookMess["author"]?.takeIf { it.length != tempFileName.length } ?: "" |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
name = tempFileName.replace(AppPattern.nameRegex, "") |
|
|
|
name = BookHelp.formatBookName(tempFileName) |
|
|
|
author = tempFileName.replace(AppPattern.authorRegex, "") |
|
|
|
author = BookHelp.formatBookAuthor(tempFileName.replace(name, "")) |
|
|
|
.takeIf { it.length != tempFileName.length } ?: "" |
|
|
|
.takeIf { it.length != tempFileName.length } ?: "" |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
name = tempFileName.replace(AppPattern.nameRegex, "") |
|
|
|
name = BookHelp.formatBookName(tempFileName) |
|
|
|
author = tempFileName.replace(AppPattern.authorRegex, "") |
|
|
|
author = BookHelp.formatBookAuthor(tempFileName.replace(name, "")) |
|
|
|
.takeIf { it.length != tempFileName.length } ?: "" |
|
|
|
.takeIf { it.length != tempFileName.length } ?: "" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|