去除刷新前重新获取目录url
添加刷新前js,功能更强大
This commit is contained in:
@@ -16,8 +16,9 @@
|
||||
* 更新cronet: 102.0.5005.78
|
||||
* 缓存导出添加导出图片文件选项
|
||||
* 其他设置添加图片绘制缓存选项
|
||||
* 移除刷新时重新获取目录页链接Url的配置
|
||||
* 移除书源详情页规则添加刷新时重新获取目录页链接Url
|
||||
* 添加刷新前Js,功能更强大
|
||||
* 添加java.reGetBook(), 重新获取书籍
|
||||
|
||||
**2022/05/27**
|
||||
|
||||
|
||||
@@ -704,14 +704,33 @@ class AnalyzeRule(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新获取book
|
||||
*/
|
||||
fun reGetBook() {
|
||||
val bookSource = source as? BookSource
|
||||
val book = book as? Book
|
||||
if (bookSource == null || book == null) return
|
||||
runBlocking {
|
||||
WebBook.preciseSearchAwait(this, bookSource, book.name, book.author)
|
||||
.getOrThrow().let {
|
||||
book.bookUrl = it.bookUrl
|
||||
it.variableMap.forEach { entry ->
|
||||
book.putVariable(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
WebBook.getBookInfoAwait(this, bookSource, book, false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新tocUrl,有些书源目录url定期更新,可以在js调用更新
|
||||
*/
|
||||
fun refreshTocUrl() {
|
||||
val bookSource = source as? BookSource
|
||||
val book = book as? Book
|
||||
if (bookSource == null || book == null) return
|
||||
runBlocking {
|
||||
val bookSource = source as? BookSource
|
||||
val book = book as? Book
|
||||
if (bookSource == null || book == null) return@runBlocking
|
||||
WebBook.getBookInfoAwait(this, bookSource, book)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,20 +339,20 @@ object WebBook {
|
||||
bookSource: BookSource,
|
||||
name: String,
|
||||
author: String,
|
||||
): Result<Book?> {
|
||||
): Result<Book> {
|
||||
return kotlin.runCatching {
|
||||
if (!scope.isActive) return@runCatching null
|
||||
scope.isActive
|
||||
searchBookAwait(scope, bookSource, name).firstOrNull {
|
||||
it.name == name && it.author == author
|
||||
}?.let { searchBook ->
|
||||
if (!scope.isActive) return@runCatching null
|
||||
scope.isActive
|
||||
var book = searchBook.toBook()
|
||||
if (book.tocUrl.isBlank()) {
|
||||
book = getBookInfoAwait(scope, bookSource, book)
|
||||
}
|
||||
return@runCatching book
|
||||
}
|
||||
return@runCatching null
|
||||
throw NoStackTraceException("未搜索到 $name($author) 书籍")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user