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 ce9f76b69..e3e158296 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 @@ -10,6 +10,7 @@ import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.NetworkUtils import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.withContext import retrofit2.Response object BookContent { @@ -48,7 +49,26 @@ object BookContent { } } } else if (contentData.nextUrl.size > 1) { - + val contentDataList = arrayListOf>() + for (item in contentData.nextUrl) { + if (!nextUrlList.contains(item)) + contentDataList.add(ContentData(nextUrl = item)) + } + for (item in contentDataList) { + withContext(coroutineScope.coroutineContext) { + val nextResponse = AnalyzeUrl(ruleUrl = item.nextUrl, book = book).getResponseAsync().await() + val nextContentData = analyzeContent( + nextResponse.body() ?: "", + contentRule, + book, + item.nextUrl + ) + item.content = nextContentData.content + } + } + for (item in contentDataList) { + content.append(item.content) + } } return content.toString() } @@ -65,6 +85,7 @@ object BookContent { analyzeRule.getStringList(contentRule.nextContentUrl ?: "", true)?.let { nextUrlList.addAll(it) } - return ContentData("", nextUrlList) + val content = analyzeRule.getString(contentRule.content ?: "") ?: "" + return ContentData(content, nextUrlList) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/model/webbook/ContentData.kt b/app/src/main/java/io/legado/app/model/webbook/ContentData.kt index 98b8aed20..195778ce8 100644 --- a/app/src/main/java/io/legado/app/model/webbook/ContentData.kt +++ b/app/src/main/java/io/legado/app/model/webbook/ContentData.kt @@ -1,6 +1,6 @@ package io.legado.app.model.webbook data class ContentData( - var content: String, + var content: String = "", var nextUrl: T ) \ No newline at end of file