From dddd3caba08021ec4afa5229a6f250d0a7570cc3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 Nov 2019 17:29:15 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/model/WebBook.kt | 24 ++++++++++++++----- .../app/model/analyzeRule/AnalyzeUrl.kt | 4 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) 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 dd1e86591..839561401 100644 --- a/app/src/main/java/io/legado/app/model/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/WebBook.kt @@ -86,16 +86,20 @@ class WebBook(val bookSource: BookSource) { context: CoroutineContext = Dispatchers.IO ): Coroutine { return Coroutine.async(scope, context) { - val body = if (book.infoHtml.isNullOrEmpty()) { + val body = if (!book.infoHtml.isNullOrEmpty()) { + book.infoHtml + } else { val analyzeUrl = AnalyzeUrl( book = book, ruleUrl = book.bookUrl, baseUrl = sourceUrl, headerMapF = bookSource.getHeaderMap() ) - analyzeUrl.getResponseAwait().body() - } else { - book.infoHtml + if (analyzeUrl.useWebView()) { + analyzeUrl.getResultByWebView(bookSource.bookSourceUrl) + } else { + analyzeUrl.getResponseAwait().body() + } } BookInfo.analyzeBookInfo(book, body, bookSource, book.bookUrl) book @@ -120,7 +124,11 @@ class WebBook(val bookSource: BookSource) { baseUrl = book.bookUrl, headerMapF = bookSource.getHeaderMap() ) - analyzeUrl.getResponseAwait().body() + if (analyzeUrl.useWebView()) { + analyzeUrl.getResultByWebView(bookSource.bookSourceUrl) + } else { + analyzeUrl.getResponseAwait().body() + } } BookChapterList.analyzeChapterList(this, book, body, bookSource, book.tocUrl) } @@ -150,7 +158,11 @@ class WebBook(val bookSource: BookSource) { baseUrl = book.tocUrl, headerMapF = bookSource.getHeaderMap() ) - analyzeUrl.getResponseAwait().body() + if (analyzeUrl.useWebView()) { + analyzeUrl.getResultByWebView(bookSource.bookSourceUrl) + } else { + analyzeUrl.getResponseAwait().body() + } } BookContent.analyzeContent( this, 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 5dd513433..262e3d1c5 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 @@ -292,6 +292,10 @@ class AnalyzeUrl( } } + fun useWebView(): Boolean { + return webViewJs != null || sourceRegex != null + } + suspend fun getResultByWebView(tag: String): String { val params = AjaxWebView.AjaxParams(tag) params.url = url