pull/32/head
kunfei 5 years ago
parent 5696e8cbe9
commit 3aa6c3f945
  1. 6
      app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt
  2. 12
      app/src/main/java/io/legado/app/model/webbook/BookContent.kt

@ -50,11 +50,7 @@ object BookChapterList {
AnalyzeUrl(ruleUrl = nextUrl, book = book).getResponse().execute()
.body()?.let { nextBody ->
chapterData = analyzeChapterList(nextBody, nextUrl, tocRule, listRule, book)
nextUrl = if (chapterData.nextUrl.isEmpty()) {
""
} else {
chapterData.nextUrl[0]
}
nextUrl = if (chapterData.nextUrl.isNotEmpty()) chapterData.nextUrl[0] else ""
chapterData.chapterList?.let {
chapterList.addAll(it)
}

@ -31,27 +31,29 @@ object BookContent {
baseUrl
)
)
val content = StringBuilder()
val nextUrlList = arrayListOf(baseUrl)
val contentRule = bookSource.getContentRule()
var contentData = analyzeContent(body, contentRule, book, baseUrl)
var content = contentData.content
content.append(contentData.content)
if (contentData.nextUrl.size == 1) {
var nextUrl = contentData.nextUrl[0]
while (nextUrl.isNotEmpty() && !nextUrlList.contains(nextUrl)) {
nextUrlList.add(nextUrl)
AnalyzeUrl(ruleUrl = nextUrl, book = book).getResponse().execute()
.body()?.let { nextBody ->
analyzeContent(nextBody, contentRule, book, baseUrl)
contentData = analyzeContent(nextBody, contentRule, book, baseUrl)
nextUrl = if (contentData.nextUrl.isNotEmpty()) contentData.nextUrl[0] else ""
content.append(contentData.content)
}
}
} else if (contentData.nextUrl.size > 1) {
}
return content
return content.toString()
}
fun analyzeContent(
private fun analyzeContent(
body: String,
contentRule: ContentRule,
book: Book,

Loading…
Cancel
Save