pull/32/head
kunfei 5 years ago
parent 3aa6c3f945
commit 1bf8b844d9
  1. 25
      app/src/main/java/io/legado/app/model/webbook/BookContent.kt
  2. 2
      app/src/main/java/io/legado/app/model/webbook/ContentData.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<ContentData<String>>()
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)
}
}

@ -1,6 +1,6 @@
package io.legado.app.model.webbook
data class ContentData<T>(
var content: String,
var content: String = "",
var nextUrl: T
)
Loading…
Cancel
Save