From 2ea28b60708c988c162977873ad439f329d6f371 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 21 Nov 2022 13:57:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/model/webBook/WebBook.kt | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt index 7e4dbfbd0..ee73cfc7e 100644 --- a/app/src/main/java/io/legado/app/model/webBook/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/webBook/WebBook.kt @@ -41,35 +41,36 @@ object WebBook { key: String, page: Int? = 1, ): ArrayList { + val searchUrl = bookSource.searchUrl + if (searchUrl.isNullOrBlank()) { + throw NoStackTraceException("搜索url不能为空") + } val ruleData = RuleData() - bookSource.searchUrl?.let { searchUrl -> - val analyzeUrl = AnalyzeUrl( - mUrl = searchUrl, - key = key, - page = page, - baseUrl = bookSource.bookSourceUrl, - headerMapF = bookSource.getHeaderMap(true), - source = bookSource, - ruleData = ruleData, - ) - var res = analyzeUrl.getStrResponseAwait() - //检测书源是否已登录 - bookSource.loginCheckJs?.let { checkJs -> - if (checkJs.isNotBlank()) { - res = analyzeUrl.evalJS(checkJs, res) as StrResponse - } + val analyzeUrl = AnalyzeUrl( + mUrl = searchUrl, + key = key, + page = page, + baseUrl = bookSource.bookSourceUrl, + headerMapF = bookSource.getHeaderMap(true), + source = bookSource, + ruleData = ruleData, + ) + var res = analyzeUrl.getStrResponseAwait() + //检测书源是否已登录 + bookSource.loginCheckJs?.let { checkJs -> + if (checkJs.isNotBlank()) { + res = analyzeUrl.evalJS(checkJs, res) as StrResponse } - checkRedirect(bookSource, res) - return BookList.analyzeBookList( - bookSource = bookSource, - ruleData = ruleData, - analyzeUrl = analyzeUrl, - baseUrl = res.url, - body = res.body, - isSearch = true - ) } - return arrayListOf() + checkRedirect(bookSource, res) + return BookList.analyzeBookList( + bookSource = bookSource, + ruleData = ruleData, + analyzeUrl = analyzeUrl, + baseUrl = res.url, + body = res.body, + isSearch = true + ) } /**