pull/32/head
kunfei 5 years ago
parent da594a27b0
commit 7e43288185
  1. 2
      app/src/main/java/io/legado/app/model/WebBook.kt
  2. 16
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -18,7 +18,7 @@ class WebBook(private val bookSource: BookSource) {
bookSource.getSearchRule().searchUrl?.let { searchUrl ->
val analyzeUrl = AnalyzeUrl(searchUrl, key, page)
val response = analyzeUrl.getResponseAsync().await()
return@async BookList.analyzeBookList(response, bookSource, analyzeUrl)
return@let BookList.analyzeBookList(response, bookSource, analyzeUrl)
}
return@async arrayListOf<SearchBook>()
}

@ -41,8 +41,7 @@ class AnalyzeUrl(
private val jsonType = MediaType.parse("application/json; charset=utf-8")
}
lateinit var baseUrl: String
private set
private var baseUrl: String = ""
lateinit var url: String
private set
var path: String? = null
@ -101,14 +100,11 @@ class AnalyzeUrl(
if (ruleUrl.contains("{{") && ruleUrl.contains("}}")) {
var jsEval: Any
val sb = StringBuffer(ruleUrl.length)
val simpleBindings = object : SimpleBindings() {
init {
this["baseUrl"] = baseUrl
this["page"] = page
this["key"] = key
this["book"] = book
}
}
val simpleBindings = SimpleBindings()
simpleBindings["baseUrl"] = baseUrl
simpleBindings["page"] = page
simpleBindings["key"] = key
simpleBindings["book"] = book
val expMatcher = EXP_PATTERN.matcher(ruleUrl)
while (expMatcher.find()) {
jsEval = SCRIPT_ENGINE.eval(expMatcher.group(1), simpleBindings)

Loading…
Cancel
Save