Update BookContent.kt

优化
pull/1126/head
bushixuanqi 3 years ago committed by GitHub
parent 9bbcb6b64b
commit 324e72ccfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt

@ -52,7 +52,7 @@ object BookContent {
var contentData = analyzeContent( var contentData = analyzeContent(
book, baseUrl, redirectUrl, body, contentRule, bookChapter, bookSource, mNextChapterUrl book, baseUrl, redirectUrl, body, contentRule, bookChapter, bookSource, mNextChapterUrl
) )
content.append(contentData.content).append("\n") content.append(contentData.content)
if (contentData.nextUrl.size == 1) { if (contentData.nextUrl.size == 1) {
var nextUrl = contentData.nextUrl[0] var nextUrl = contentData.nextUrl[0]
while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) { while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) {
@ -74,7 +74,7 @@ object BookContent {
) )
nextUrl = nextUrl =
if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else "" if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else ""
content.append(contentData.content).append("\n") content.append("\n").append(contentData.content)
} }
} }
Debug.log(bookSource.bookSourceUrl, "◇本章总页数:${nextUrlList.size}") Debug.log(bookSource.bookSourceUrl, "◇本章总页数:${nextUrlList.size}")
@ -98,11 +98,10 @@ object BookContent {
} }
asyncArray.forEach { coroutine -> asyncArray.forEach { coroutine ->
scope.ensureActive() scope.ensureActive()
content.append(coroutine.await()).append("\n") content.append("\n").append(coroutine.await())
} }
} }
} }
content.deleteCharAt(content.length - 1)
var contentStr = content.toString() var contentStr = content.toString()
val replaceRegex = contentRule.replaceRegex val replaceRegex = contentRule.replaceRegex
if (!replaceRegex.isNullOrEmpty()) { if (!replaceRegex.isNullOrEmpty()) {

Loading…
Cancel
Save