修复baseUrl丢失参数的bug

pull/1576/head^2
kunfei 3 years ago
parent 17b5f3a1a8
commit ff36db4e39
  1. 8
      app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
  2. 10
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt
  3. 8
      app/src/main/java/io/legado/app/model/webBook/BookInfo.kt
  4. 18
      app/src/main/java/io/legado/app/model/webBook/WebBook.kt

@ -28,8 +28,8 @@ object BookChapterList {
scope: CoroutineScope, scope: CoroutineScope,
bookSource: BookSource, bookSource: BookSource,
book: Book, book: Book,
redirectUrl: String,
baseUrl: String, baseUrl: String,
redirectUrl: String,
body: String? body: String?
): List<BookChapter> { ): List<BookChapter> {
body ?: throw NoStackTraceException( body ?: throw NoStackTraceException(
@ -39,7 +39,7 @@ object BookChapterList {
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}")
Debug.log(bookSource.bookSourceUrl, body, state = 30) Debug.log(bookSource.bookSourceUrl, body, state = 30)
val tocRule = bookSource.getTocRule() val tocRule = bookSource.getTocRule()
val nextUrlList = arrayListOf(baseUrl) val nextUrlList = arrayListOf(redirectUrl)
var reverse = false var reverse = false
var listRule = tocRule.chapterList ?: "" var listRule = tocRule.chapterList ?: ""
if (listRule.startsWith("-")) { if (listRule.startsWith("-")) {
@ -157,7 +157,7 @@ object BookChapterList {
Debug.log(bookSource.bookSourceUrl, "┌获取目录下一页列表", log) Debug.log(bookSource.bookSourceUrl, "┌获取目录下一页列表", log)
analyzeRule.getStringList(nextTocRule, isUrl = true)?.let { analyzeRule.getStringList(nextTocRule, isUrl = true)?.let {
for (item in it) { for (item in it) {
if (item != baseUrl) { if (item != redirectUrl) {
nextUrlList.add(item) nextUrlList.add(item)
} }
} }
@ -180,7 +180,7 @@ object BookChapterList {
elements.forEachIndexed { index, item -> elements.forEachIndexed { index, item ->
scope.ensureActive() scope.ensureActive()
analyzeRule.setContent(item) analyzeRule.setContent(item)
val bookChapter = BookChapter(bookUrl = book.bookUrl, baseUrl = baseUrl) val bookChapter = BookChapter(bookUrl = book.bookUrl, baseUrl = redirectUrl)
analyzeRule.chapter = bookChapter analyzeRule.chapter = bookChapter
bookChapter.title = analyzeRule.getString(nameRule) bookChapter.title = analyzeRule.getString(nameRule)
bookChapter.url = analyzeRule.getString(urlRule) bookChapter.url = analyzeRule.getString(urlRule)

@ -32,8 +32,8 @@ object BookContent {
bookSource: BookSource, bookSource: BookSource,
book: Book, book: Book,
bookChapter: BookChapter, bookChapter: BookChapter,
redirectUrl: String,
baseUrl: String, baseUrl: String,
redirectUrl: String,
body: String?, body: String?,
nextChapterUrl: String?, nextChapterUrl: String?,
needSave: Boolean = true needSave: Boolean = true
@ -50,10 +50,10 @@ object BookContent {
nextChapterUrl nextChapterUrl
} }
val content = StringBuilder() val content = StringBuilder()
val nextUrlList = arrayListOf(baseUrl) val nextUrlList = arrayListOf(redirectUrl)
val contentRule = bookSource.getContentRule() val contentRule = bookSource.getContentRule()
val analyzeRule = AnalyzeRule(book, bookSource).setContent(body, baseUrl) val analyzeRule = AnalyzeRule(book, bookSource).setContent(body, baseUrl)
analyzeRule.setRedirectUrl(baseUrl) analyzeRule.setRedirectUrl(redirectUrl)
analyzeRule.nextChapterUrl = mNextChapterUrl analyzeRule.nextChapterUrl = mNextChapterUrl
scope.ensureActive() scope.ensureActive()
var contentData = analyzeContent( var contentData = analyzeContent(
@ -64,8 +64,8 @@ object BookContent {
var nextUrl = contentData.second[0] var nextUrl = contentData.second[0]
while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) { while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) {
if (!mNextChapterUrl.isNullOrEmpty() if (!mNextChapterUrl.isNullOrEmpty()
&& NetworkUtils.getAbsoluteURL(baseUrl, nextUrl) && NetworkUtils.getAbsoluteURL(redirectUrl, nextUrl)
== NetworkUtils.getAbsoluteURL(baseUrl, mNextChapterUrl) == NetworkUtils.getAbsoluteURL(redirectUrl, mNextChapterUrl)
) break ) break
nextUrlList.add(nextUrl) nextUrlList.add(nextUrl)
scope.ensureActive() scope.ensureActive()

@ -25,8 +25,8 @@ object BookInfo {
scope: CoroutineScope, scope: CoroutineScope,
bookSource: BookSource, bookSource: BookSource,
book: Book, book: Book,
redirectUrl: String,
baseUrl: String, baseUrl: String,
redirectUrl: String,
body: String?, body: String?,
canReName: Boolean, canReName: Boolean,
) { ) {
@ -126,7 +126,7 @@ object BookInfo {
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接") Debug.log(bookSource.bookSourceUrl, "┌获取封面链接")
try { try {
analyzeRule.getString(infoRule.coverUrl).let { 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}") Debug.log(bookSource.bookSourceUrl, "${it}")
} }
} catch (e: Exception) { } catch (e: Exception) {
@ -136,8 +136,8 @@ object BookInfo {
scope.ensureActive() scope.ensureActive()
Debug.log(bookSource.bookSourceUrl, "┌获取目录链接") Debug.log(bookSource.bookSourceUrl, "┌获取目录链接")
book.tocUrl = analyzeRule.getString(infoRule.tocUrl, isUrl = true) book.tocUrl = analyzeRule.getString(infoRule.tocUrl, isUrl = true)
if (book.tocUrl.isEmpty()) book.tocUrl = redirectUrl if (book.tocUrl.isEmpty()) book.tocUrl = baseUrl
if (book.tocUrl == redirectUrl) { if (book.tocUrl == baseUrl) {
book.tocHtml = body book.tocHtml = body
} }
Debug.log(bookSource.bookSourceUrl, "${book.tocUrl}") Debug.log(bookSource.bookSourceUrl, "${book.tocUrl}")

@ -144,8 +144,8 @@ object WebBook {
scope = scope, scope = scope,
bookSource = bookSource, bookSource = bookSource,
book = book, book = book,
redirectUrl = book.bookUrl,
baseUrl = book.bookUrl, baseUrl = book.bookUrl,
redirectUrl = book.bookUrl,
body = book.infoHtml, body = book.infoHtml,
canReName = canReName canReName = canReName
) )
@ -168,8 +168,8 @@ object WebBook {
scope = scope, scope = scope,
bookSource = bookSource, bookSource = bookSource,
book = book, book = book,
redirectUrl = book.bookUrl, baseUrl = book.bookUrl,
baseUrl = res.url, redirectUrl = res.url,
body = res.body, body = res.body,
canReName = canReName canReName = canReName
) )
@ -202,8 +202,8 @@ object WebBook {
scope = scope, scope = scope,
bookSource = bookSource, bookSource = bookSource,
book = book, book = book,
redirectUrl = book.tocUrl,
baseUrl = book.tocUrl, baseUrl = book.tocUrl,
redirectUrl = book.tocUrl,
body = book.tocHtml body = book.tocHtml
) )
} else { } else {
@ -225,8 +225,8 @@ object WebBook {
scope = scope, scope = scope,
bookSource = bookSource, bookSource = bookSource,
book = book, book = book,
redirectUrl = book.tocUrl, baseUrl = book.tocUrl,
baseUrl = res.url, redirectUrl = res.url,
body = res.body body = res.body
) )
} }
@ -271,8 +271,8 @@ object WebBook {
bookSource = bookSource, bookSource = bookSource,
book = book, book = book,
bookChapter = bookChapter, bookChapter = bookChapter,
redirectUrl = bookChapter.getAbsoluteURL(),
baseUrl = bookChapter.getAbsoluteURL(), baseUrl = bookChapter.getAbsoluteURL(),
redirectUrl = bookChapter.getAbsoluteURL(),
body = book.tocHtml, body = book.tocHtml,
nextChapterUrl = nextChapterUrl, nextChapterUrl = nextChapterUrl,
needSave = needSave needSave = needSave
@ -301,8 +301,8 @@ object WebBook {
bookSource = bookSource, bookSource = bookSource,
book = book, book = book,
bookChapter = bookChapter, bookChapter = bookChapter,
redirectUrl = bookChapter.getAbsoluteURL(), baseUrl = bookChapter.getAbsoluteURL(),
baseUrl = res.url, redirectUrl = res.url,
body = res.body, body = res.body,
nextChapterUrl = nextChapterUrl, nextChapterUrl = nextChapterUrl,
needSave = needSave needSave = needSave

Loading…
Cancel
Save