From 477f30a109c422bcecdd06e0083caf9fd680fc09 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 21 Aug 2021 21:19:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E7=B1=8Durl=E5=8F=96=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=90=8E=E7=9A=84=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/model/webBook/BookList.kt | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookList.kt b/app/src/main/java/io/legado/app/model/webBook/BookList.kt index 1fc3f9565..91422bef0 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookList.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookList.kt @@ -46,11 +46,12 @@ object BookList { scope.ensureActive() if (baseUrl.matches(it.toRegex())) { Debug.log(bookSource.bookSourceUrl, "≡链接为详情页") - getInfoItem(scope, body, analyzeRule, bookSource, baseUrl, variableBook.variable) - ?.let { searchBook -> - searchBook.infoHtml = body - bookList.add(searchBook) - } + getInfoItem( + scope, bookSource, analyzeRule, analyzeUrl, body, baseUrl, variableBook.variable + )?.let { searchBook -> + searchBook.infoHtml = body + bookList.add(searchBook) + } return bookList } } @@ -74,11 +75,12 @@ object BookList { scope.ensureActive() if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) { Debug.log(bookSource.bookSourceUrl, "└列表为空,按详情页解析") - getInfoItem(scope, body, analyzeRule, bookSource, baseUrl, variableBook.variable) - ?.let { searchBook -> - searchBook.infoHtml = body - bookList.add(searchBook) - } + getInfoItem( + scope, bookSource, analyzeRule, analyzeUrl, body, baseUrl, variableBook.variable + )?.let { searchBook -> + searchBook.infoHtml = body + bookList.add(searchBook) + } } else { val ruleName = analyzeRule.splitSourceRule(bookListRule.name) val ruleBookUrl = analyzeRule.splitSourceRule(bookListRule.bookUrl) @@ -91,12 +93,7 @@ object BookList { Debug.log(bookSource.bookSourceUrl, "└列表大小:${collections.size}") for ((index, item) in collections.withIndex()) { getSearchItem( - scope, - item, - analyzeRule, - bookSource, - baseUrl, - variableBook.variable, + scope, bookSource, analyzeRule, item, baseUrl, variableBook.variable, index == 0, ruleName = ruleName, ruleBookUrl = ruleBookUrl, @@ -123,14 +120,15 @@ object BookList { @Throws(Exception::class) private fun getInfoItem( scope: CoroutineScope, - body: String, - analyzeRule: AnalyzeRule, bookSource: BookSource, + analyzeRule: AnalyzeRule, + analyzeUrl: AnalyzeUrl, + body: String, baseUrl: String, variable: String? ): SearchBook? { val book = Book(variable = variable) - book.bookUrl = baseUrl + book.bookUrl = analyzeUrl.ruleUrl book.origin = bookSource.bookSourceUrl book.originName = bookSource.bookSourceName book.originOrder = bookSource.customOrder @@ -155,9 +153,9 @@ object BookList { @Throws(Exception::class) private fun getSearchItem( scope: CoroutineScope, - item: Any, - analyzeRule: AnalyzeRule, bookSource: BookSource, + analyzeRule: AnalyzeRule, + item: Any, baseUrl: String, variable: String?, log: Boolean,