pull/45/head
kunfei 5 years ago
parent 9e3e843d5e
commit 43cbda6865
  1. 17
      app/src/main/java/io/legado/app/model/WebBook.kt
  2. 7
      app/src/main/java/io/legado/app/model/webbook/BookList.kt

@ -10,6 +10,7 @@ import io.legado.app.model.webbook.BookChapterList
import io.legado.app.model.webbook.BookContent
import io.legado.app.model.webbook.BookInfo
import io.legado.app.model.webbook.BookList
import io.legado.app.utils.NetworkUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlin.coroutines.CoroutineContext
@ -38,7 +39,13 @@ class WebBook(val bookSource: BookSource) {
headerMapF = bookSource.getHeaderMap()
)
val response = analyzeUrl.getResponseAsync().await()
BookList.analyzeBookList(response, bookSource, analyzeUrl, true)
BookList.analyzeBookList(
response.body(),
bookSource,
analyzeUrl,
NetworkUtils.getUrl(response),
true
)
} ?: arrayListOf()
}
}
@ -60,7 +67,13 @@ class WebBook(val bookSource: BookSource) {
headerMapF = bookSource.getHeaderMap()
)
val response = analyzeUrl.getResponseAsync().await()
BookList.analyzeBookList(response, bookSource, analyzeUrl, false)
BookList.analyzeBookList(
response.body(),
bookSource,
analyzeUrl,
NetworkUtils.getUrl(response),
false
)
}
}

@ -7,21 +7,18 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.help.BookHelp
import io.legado.app.model.analyzeRule.AnalyzeRule
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.utils.NetworkUtils
import retrofit2.Response
object BookList {
@Throws(Exception::class)
fun analyzeBookList(
response: Response<String>,
body: String?,
bookSource: BookSource,
analyzeUrl: AnalyzeUrl,
baseUrl: String,
isSearch: Boolean = true
): ArrayList<SearchBook> {
val bookList = ArrayList<SearchBook>()
val baseUrl: String = NetworkUtils.getUrl(response)
val body: String? = response.body()
body ?: throw Exception(
App.INSTANCE.getString(
R.string.error_get_web_content,

Loading…
Cancel
Save