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 + ) } /**