From e3485cba92ca5c2d27def112d545c3cd7b96c63f Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 6 Oct 2020 15:26:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=AD=A3=E6=96=87url?= =?UTF-8?q?=E6=97=B6=E4=BC=A0=E5=85=A5chapter=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + .../legado/app/model/analyzeRule/AnalyzeUrl.kt | 4 +++- .../io/legado/app/model/webBook/WebBook.kt | 18 +++++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 43862984a..72b639197 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -6,6 +6,7 @@ **2020/10/04** * 更新时预下载10章 * 支持更多分组 +* **2020/10/02** * 优化规则解析 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 3508a3056..e274110a6 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 @@ -11,6 +11,7 @@ import io.legado.app.constant.AppConst.userAgent import io.legado.app.constant.AppPattern.EXP_PATTERN import io.legado.app.constant.AppPattern.JS_PATTERN import io.legado.app.data.entities.BaseBook +import io.legado.app.data.entities.BookChapter import io.legado.app.help.JsExtensions import io.legado.app.help.http.* import io.legado.app.help.http.api.HttpGetApi @@ -39,8 +40,9 @@ class AnalyzeUrl( speakSpeed: Int? = null, headerMapF: Map? = null, baseUrl: String? = null, - val book: BaseBook? = null, var useWebView: Boolean = false, + val book: BaseBook? = null, + val chapter: BookChapter? = null ) : JsExtensions { companion object { private val pagePattern = Pattern.compile("<(.*?)>") 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 bcc087839..3ae38d16e 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 @@ -106,10 +106,10 @@ class WebBook(val bookSource: BookSource) { book.infoHtml } else { val analyzeUrl = AnalyzeUrl( - book = book, ruleUrl = book.bookUrl, baseUrl = sourceUrl, - headerMapF = bookSource.getHeaderMap() + headerMapF = bookSource.getHeaderMap(), + book = book ) analyzeUrl.getResponseAwait(bookSource.bookSourceUrl).body } @@ -177,13 +177,13 @@ class WebBook(val bookSource: BookSource) { if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) { book.tocHtml } else { - val analyzeUrl = - AnalyzeUrl( - book = book, - ruleUrl = bookChapter.url, - baseUrl = book.tocUrl, - headerMapF = bookSource.getHeaderMap() - ) + val analyzeUrl = AnalyzeUrl( + ruleUrl = bookChapter.url, + baseUrl = book.tocUrl, + headerMapF = bookSource.getHeaderMap(), + book = book, + chapter = bookChapter + ) analyzeUrl.getResponseAwait( bookSource.bookSourceUrl, jsStr = bookSource.getContentRule().webJs,