This commit is contained in:
Horis 2023-06-20 19:00:50 +08:00
parent dbddf61132
commit d3f3912532

View File

@ -57,9 +57,8 @@ object LocalBook {
}.firstOrNull()?.let {
getBookInputStream(it)
}
} else if (webDavUrl != null) {
} else if (webDavUrl != null && downloadRemoteBook(book)) {
// 下载远程链接
downloadRemoteBook(book)
getBookInputStream(book)
} else {
null
@ -90,12 +89,15 @@ object LocalBook {
book.isEpub -> {
EpubFile.getChapterList(book)
}
book.isUmd -> {
UmdFile.getChapterList(book)
}
book.isPdf -> {
PdfFile.getChapterList(book)
}
else -> {
TextFile.getChapterList(book)
}
@ -117,12 +119,15 @@ object LocalBook {
book.isEpub -> {
EpubFile.getContent(book, chapter)
}
book.isUmd -> {
UmdFile.getContent(book, chapter)
}
book.isPdf -> {
PdfFile.getContent(book, chapter)
}
else -> {
TextFile.getContent(book, chapter)
}
@ -218,7 +223,7 @@ object LocalBook {
}
}
/* 批量导入 支持自动导入压缩包的支持书籍 */
/* 批量导入 支持自动导入压缩包的支持书籍 */
fun importFiles(uri: Uri): List<Book> {
val books = mutableListOf<Book>()
val fileDoc = FileDoc.fromUri(uri, false)
@ -329,6 +334,7 @@ object LocalBook {
Base64.DEFAULT
)
)
else -> throw NoStackTraceException("在线导入书籍支持http/https/DataURL")
}
return saveBookFile(inputStream, fileName)
@ -383,7 +389,7 @@ object LocalBook {
}
//下载book对应的远程文件 并更新Book
private fun downloadRemoteBook(localBook: Book) {
private fun downloadRemoteBook(localBook: Book): Boolean {
val webDavUrl = localBook.getRemoteUrl()
if (webDavUrl.isNullOrBlank()) throw NoStackTraceException("Book file is not webDav File")
try {
@ -415,9 +421,11 @@ object LocalBook {
localBook.save()
}
}
return true
} catch (e: Exception) {
e.printOnDebug()
AppLog.put("自动下载webDav书籍失败", e)
return false
}
}