diff --git a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt index f59e62e17..2550a007c 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt @@ -28,8 +28,8 @@ object BookChapterList { scope: CoroutineScope, bookSource: BookSource, book: Book, - redirectUrl: String, baseUrl: String, + redirectUrl: String, body: String? ): List { body ?: throw NoStackTraceException( @@ -39,7 +39,7 @@ object BookChapterList { Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") Debug.log(bookSource.bookSourceUrl, body, state = 30) val tocRule = bookSource.getTocRule() - val nextUrlList = arrayListOf(baseUrl) + val nextUrlList = arrayListOf(redirectUrl) var reverse = false var listRule = tocRule.chapterList ?: "" if (listRule.startsWith("-")) { @@ -157,7 +157,7 @@ object BookChapterList { Debug.log(bookSource.bookSourceUrl, "┌获取目录下一页列表", log) analyzeRule.getStringList(nextTocRule, isUrl = true)?.let { for (item in it) { - if (item != baseUrl) { + if (item != redirectUrl) { nextUrlList.add(item) } } @@ -180,7 +180,7 @@ object BookChapterList { elements.forEachIndexed { index, item -> scope.ensureActive() analyzeRule.setContent(item) - val bookChapter = BookChapter(bookUrl = book.bookUrl, baseUrl = baseUrl) + val bookChapter = BookChapter(bookUrl = book.bookUrl, baseUrl = redirectUrl) analyzeRule.chapter = bookChapter bookChapter.title = analyzeRule.getString(nameRule) bookChapter.url = analyzeRule.getString(urlRule) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt index edcb4c9d2..64b727e2a 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt @@ -32,8 +32,8 @@ object BookContent { bookSource: BookSource, book: Book, bookChapter: BookChapter, - redirectUrl: String, baseUrl: String, + redirectUrl: String, body: String?, nextChapterUrl: String?, needSave: Boolean = true @@ -50,10 +50,10 @@ object BookContent { nextChapterUrl } val content = StringBuilder() - val nextUrlList = arrayListOf(baseUrl) + val nextUrlList = arrayListOf(redirectUrl) val contentRule = bookSource.getContentRule() val analyzeRule = AnalyzeRule(book, bookSource).setContent(body, baseUrl) - analyzeRule.setRedirectUrl(baseUrl) + analyzeRule.setRedirectUrl(redirectUrl) analyzeRule.nextChapterUrl = mNextChapterUrl scope.ensureActive() var contentData = analyzeContent( @@ -64,8 +64,8 @@ object BookContent { var nextUrl = contentData.second[0] while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) { if (!mNextChapterUrl.isNullOrEmpty() - && NetworkUtils.getAbsoluteURL(baseUrl, nextUrl) - == NetworkUtils.getAbsoluteURL(baseUrl, mNextChapterUrl) + && NetworkUtils.getAbsoluteURL(redirectUrl, nextUrl) + == NetworkUtils.getAbsoluteURL(redirectUrl, mNextChapterUrl) ) break nextUrlList.add(nextUrl) scope.ensureActive() diff --git a/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt b/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt index a7829d21a..153c8e3e7 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt @@ -25,8 +25,8 @@ object BookInfo { scope: CoroutineScope, bookSource: BookSource, book: Book, - redirectUrl: String, baseUrl: String, + redirectUrl: String, body: String?, canReName: Boolean, ) { @@ -126,7 +126,7 @@ object BookInfo { Debug.log(bookSource.bookSourceUrl, "┌获取封面链接") try { analyzeRule.getString(infoRule.coverUrl).let { - if (it.isNotEmpty()) book.coverUrl = NetworkUtils.getAbsoluteURL(baseUrl, it) + if (it.isNotEmpty()) book.coverUrl = NetworkUtils.getAbsoluteURL(redirectUrl, it) Debug.log(bookSource.bookSourceUrl, "└${it}") } } catch (e: Exception) { @@ -136,8 +136,8 @@ object BookInfo { scope.ensureActive() Debug.log(bookSource.bookSourceUrl, "┌获取目录链接") book.tocUrl = analyzeRule.getString(infoRule.tocUrl, isUrl = true) - if (book.tocUrl.isEmpty()) book.tocUrl = redirectUrl - if (book.tocUrl == redirectUrl) { + if (book.tocUrl.isEmpty()) book.tocUrl = baseUrl + if (book.tocUrl == baseUrl) { book.tocHtml = body } Debug.log(bookSource.bookSourceUrl, "└${book.tocUrl}") 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 9cda244cf..f657b4e13 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,8 +144,8 @@ object WebBook { scope = scope, bookSource = bookSource, book = book, - redirectUrl = book.bookUrl, baseUrl = book.bookUrl, + redirectUrl = book.bookUrl, body = book.infoHtml, canReName = canReName ) @@ -168,8 +168,8 @@ object WebBook { scope = scope, bookSource = bookSource, book = book, - redirectUrl = book.bookUrl, - baseUrl = res.url, + baseUrl = book.bookUrl, + redirectUrl = res.url, body = res.body, canReName = canReName ) @@ -202,8 +202,8 @@ object WebBook { scope = scope, bookSource = bookSource, book = book, - redirectUrl = book.tocUrl, baseUrl = book.tocUrl, + redirectUrl = book.tocUrl, body = book.tocHtml ) } else { @@ -225,8 +225,8 @@ object WebBook { scope = scope, bookSource = bookSource, book = book, - redirectUrl = book.tocUrl, - baseUrl = res.url, + baseUrl = book.tocUrl, + redirectUrl = res.url, body = res.body ) } @@ -271,8 +271,8 @@ object WebBook { bookSource = bookSource, book = book, bookChapter = bookChapter, - redirectUrl = bookChapter.getAbsoluteURL(), baseUrl = bookChapter.getAbsoluteURL(), + redirectUrl = bookChapter.getAbsoluteURL(), body = book.tocHtml, nextChapterUrl = nextChapterUrl, needSave = needSave @@ -301,8 +301,8 @@ object WebBook { bookSource = bookSource, book = book, bookChapter = bookChapter, - redirectUrl = bookChapter.getAbsoluteURL(), - baseUrl = res.url, + baseUrl = bookChapter.getAbsoluteURL(), + redirectUrl = res.url, body = res.body, nextChapterUrl = nextChapterUrl, needSave = needSave