pull/373/head
gedoor 4 years ago
parent 69401f70cb
commit 0087746eb0
  1. 6
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  2. 5
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt

@ -580,6 +580,10 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
} }
fun get(key: String): String { fun get(key: String): String {
val chapter = chapter
if (chapter != null && key == "title") {
return chapter.title
}
return chapter?.variableMap?.get(key) return chapter?.variableMap?.get(key)
?: book?.variableMap?.get(key) ?: book?.variableMap?.get(key)
?: "" ?: ""
@ -594,6 +598,8 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
bindings["book"] = book bindings["book"] = book
bindings["result"] = result bindings["result"] = result
bindings["baseUrl"] = baseUrl bindings["baseUrl"] = baseUrl
bindings["chapter"] = chapter
bindings["title"] = chapter?.title
return SCRIPT_ENGINE.eval(jsStr, bindings) return SCRIPT_ENGINE.eval(jsStr, bindings)
} }

@ -96,7 +96,10 @@ object BookContent {
var contentStr = content.toString().htmlFormat() var contentStr = content.toString().htmlFormat()
val replaceRegex = bookSource.ruleContent?.replaceRegex val replaceRegex = bookSource.ruleContent?.replaceRegex
if (!replaceRegex.isNullOrEmpty()) { if (!replaceRegex.isNullOrEmpty()) {
contentStr = AnalyzeRule(book).setContent(contentStr).getString(replaceRegex) val analyzeRule = AnalyzeRule(book)
analyzeRule.setContent(body, baseUrl)
analyzeRule.chapter = bookChapter
contentStr = analyzeRule.getString(replaceRegex)
} }
Debug.log(bookSource.bookSourceUrl, "┌获取章节名称") Debug.log(bookSource.bookSourceUrl, "┌获取章节名称")
Debug.log(bookSource.bookSourceUrl, "${bookChapter.title}") Debug.log(bookSource.bookSourceUrl, "${bookChapter.title}")

Loading…
Cancel
Save