mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
添加更新bookUrl和更新tocUrl函数
This commit is contained in:
@@ -4,12 +4,11 @@ import android.text.TextUtils
|
||||
import androidx.annotation.Keep
|
||||
import io.legado.app.constant.AppConst.SCRIPT_ENGINE
|
||||
import io.legado.app.constant.AppPattern.JS_PATTERN
|
||||
import io.legado.app.data.entities.BaseBook
|
||||
import io.legado.app.data.entities.BaseSource
|
||||
import io.legado.app.data.entities.BookChapter
|
||||
import io.legado.app.data.entities.*
|
||||
import io.legado.app.help.CacheManager
|
||||
import io.legado.app.help.JsExtensions
|
||||
import io.legado.app.help.http.CookieStore
|
||||
import io.legado.app.model.webBook.WebBook
|
||||
import io.legado.app.utils.*
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jsoup.nodes.Entities
|
||||
@@ -684,6 +683,39 @@ class AnalyzeRule(
|
||||
return s
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新BookUrl,如果搜索结果有tocUrl也会更新,有些书源bookUrl定期更新,可以在js内调用更新
|
||||
*/
|
||||
fun refreshBookUrl() {
|
||||
runBlocking {
|
||||
val bookSource = source as? BookSource
|
||||
val book = book as? Book
|
||||
if (bookSource == null || book == null) return@runBlocking
|
||||
val books = WebBook.searchBookAwait(this, bookSource, book.name)
|
||||
books.forEach {
|
||||
if (it.name == book.name && it.author == book.author) {
|
||||
book.bookUrl = it.bookUrl
|
||||
if (it.tocUrl.isNotBlank()) {
|
||||
book.tocUrl = it.tocUrl
|
||||
}
|
||||
return@runBlocking
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新tocUrl,有些书源目录url定期更新,可以在js调用更新
|
||||
*/
|
||||
fun refreshTocUrl() {
|
||||
runBlocking {
|
||||
val bookSource = source as? BookSource
|
||||
val book = book as? Book
|
||||
if (bookSource == null || book == null) return@runBlocking
|
||||
WebBook.getBookInfoAwait(this, bookSource, book)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val putPattern = Pattern.compile("@put:(\\{[^}]+?\\})", Pattern.CASE_INSENSITIVE)
|
||||
private val evalPattern =
|
||||
|
||||
Reference in New Issue
Block a user