diff --git a/app/src/main/java/io/legado/app/model/WebBook.kt b/app/src/main/java/io/legado/app/model/WebBook.kt index e662ce6dc..e6703866b 100644 --- a/app/src/main/java/io/legado/app/model/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/WebBook.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() } diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 8f0ddb328..c9261b447 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -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)