mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
**2023/05/16**
|
||||
|
||||
* 添加格式化目录规则,只能写js,不用@js:标志,提供变量index和title,index从1开始
|
||||
* 正文添加标题规则,结果更新到目录,有些网站只能在正文获取正确的标题
|
||||
|
||||
**2023/05/13**
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import kotlinx.parcelize.Parcelize
|
||||
@Parcelize
|
||||
data class ContentRule(
|
||||
var content: String? = null,
|
||||
var title: String? = null, //有些网站只能在正文中获取标题
|
||||
var nextContentUrl: String? = null,
|
||||
var webJs: String? = null,
|
||||
var sourceRegex: String? = null,
|
||||
|
||||
@@ -51,11 +51,25 @@ object BookContent {
|
||||
val content = StringBuilder()
|
||||
val nextUrlList = arrayListOf(redirectUrl)
|
||||
val contentRule = bookSource.getContentRule()
|
||||
val analyzeRule = AnalyzeRule(book, bookSource).setContent(body, baseUrl)
|
||||
val analyzeRule = AnalyzeRule(book, bookSource)
|
||||
analyzeRule.setContent(body, baseUrl)
|
||||
analyzeRule.setRedirectUrl(redirectUrl)
|
||||
analyzeRule.chapter = bookChapter
|
||||
analyzeRule.nextChapterUrl = mNextChapterUrl
|
||||
coroutineContext.ensureActive()
|
||||
contentRule.title?.let {
|
||||
if (it.isNotBlank()) {
|
||||
val title = analyzeRule.runCatching {
|
||||
getString(it)
|
||||
}.onFailure { e ->
|
||||
Debug.log(bookSource.bookSourceUrl, "获取标题出错, ${e.localizedMessage}")
|
||||
}.getOrNull()
|
||||
if (!title.isNullOrBlank()) {
|
||||
bookChapter.title = title
|
||||
appDb.bookChapterDao.upDate(bookChapter)
|
||||
}
|
||||
}
|
||||
}
|
||||
var contentData = analyzeContent(
|
||||
book, baseUrl, redirectUrl, body, contentRule, bookChapter, bookSource, mNextChapterUrl
|
||||
)
|
||||
|
||||
@@ -320,6 +320,7 @@ class BookSourceEditActivity :
|
||||
contentEntities.clear()
|
||||
contentEntities.apply {
|
||||
add(EditEntity("content", cr.content, R.string.rule_book_content))
|
||||
add(EditEntity("title", cr.title, R.string.rule_chapter_name))
|
||||
add(EditEntity("nextContentUrl", cr.nextContentUrl, R.string.rule_next_content))
|
||||
add(EditEntity("webJs", cr.webJs, R.string.rule_web_js))
|
||||
add(EditEntity("sourceRegex", cr.sourceRegex, R.string.rule_source_regex))
|
||||
@@ -476,10 +477,11 @@ class BookSourceEditActivity :
|
||||
}
|
||||
contentEntities.forEach {
|
||||
when (it.key) {
|
||||
"content" -> contentRule.content =
|
||||
viewModel.ruleComplete(it.value)
|
||||
"content" -> contentRule.content = viewModel.ruleComplete(it.value)
|
||||
"title" -> contentRule.title = viewModel.ruleComplete(it.value)
|
||||
"nextContentUrl" -> contentRule.nextContentUrl =
|
||||
viewModel.ruleComplete(it.value, type = 2)
|
||||
|
||||
"webJs" -> contentRule.webJs = it.value
|
||||
"sourceRegex" -> contentRule.sourceRegex = it.value
|
||||
"replaceRegex" -> contentRule.replaceRegex = it.value
|
||||
|
||||
Reference in New Issue
Block a user