From cbda1e7f6c2c66d3048f93e42d78fc37fb51d3f1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 14 Nov 2020 17:10:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9Burl?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/data/entities/BookChapter.kt | 8 +++++++- .../java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 2 +- app/src/main/java/io/legado/app/model/webBook/WebBook.kt | 7 ++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt index 3441a4ed4..1668ef19c 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt @@ -5,6 +5,7 @@ import androidx.room.Entity import androidx.room.ForeignKey import androidx.room.Ignore import androidx.room.Index +import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.GSON import io.legado.app.utils.MD5Utils import io.legado.app.utils.NetworkUtils @@ -61,7 +62,12 @@ data class BookChapter( } fun getAbsoluteURL(): String { - return NetworkUtils.getAbsoluteURL(baseUrl, url)!! + val urlArray = url.split(AnalyzeUrl.splitUrlRegex) + var absoluteUrl = NetworkUtils.getAbsoluteURL(baseUrl, urlArray[0])!! + if (urlArray.size > 1) { + absoluteUrl += urlArray[1] + } + return absoluteUrl } fun getFileName(): String = String.format("%05d-%s.nb", index, MD5Utils.md5Encode16(title)) 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 60ef3b8d6..16d9f3d29 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 @@ -45,7 +45,7 @@ class AnalyzeUrl( headerMapF: Map? = null ) : JsExtensions { companion object { - private val splitUrlRegex = Regex(",\\s*(?=\\{)") + val splitUrlRegex = Regex(",\\s*(?=\\{)") private val pagePattern = Pattern.compile("<(.*?)>") private val jsonType = MediaType.parse("application/json; charset=utf-8") } 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 9e69cff3d..c9923b776 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 @@ -144,9 +144,10 @@ class WebBook(val bookSource: BookSource) { ).getResponseAwait(bookSource.bookSourceUrl) BookChapterList.analyzeChapterList( this, - book, res.body, + book, + res.body, bookSource, - res.url + book.tocUrl ) } @@ -211,7 +212,7 @@ class WebBook(val bookSource: BookSource) { book, bookChapter, bookSource, - res.url, + bookChapter.getAbsoluteURL(), nextChapterUrl ) }