pull/32/head
kunfei 5 years ago
parent 10abf12674
commit 68c8110caf
  1. 10
      app/src/main/java/io/legado/app/model/WebBook.kt
  2. 5
      app/src/main/java/io/legado/app/model/webbook/BookContent.kt

@ -19,7 +19,7 @@ class WebBook(private val bookSource: BookSource) {
fun searchBook(key: String, page: Int?, isSearch: Boolean = true): Coroutine<List<SearchBook>> {
return Coroutine.async {
bookSource.getSearchRule().searchUrl?.let { searchUrl ->
val analyzeUrl = AnalyzeUrl(searchUrl, key, page, baseUrl = bookSource.bookSourceUrl)
val analyzeUrl = AnalyzeUrl(searchUrl, key, page, baseUrl = sourceUrl)
val response = analyzeUrl.getResponseAsync().await()
BookList.analyzeBookList(response, bookSource, analyzeUrl, isSearch)
} ?: arrayListOf()
@ -28,7 +28,7 @@ class WebBook(private val bookSource: BookSource) {
fun getBookInfo(book: Book): Coroutine<Book> {
return Coroutine.async {
val analyzeUrl = AnalyzeUrl(book = book, ruleUrl = book.bookUrl)
val analyzeUrl = AnalyzeUrl(book = book, ruleUrl = book.bookUrl, baseUrl = sourceUrl)
val response = analyzeUrl.getResponseAsync().await()
BookInfo.analyzeBookInfo(book, response.body(), bookSource, analyzeUrl)
book
@ -37,7 +37,7 @@ class WebBook(private val bookSource: BookSource) {
fun getChapterList(book: Book): Coroutine<List<BookChapter>> {
return Coroutine.async {
val analyzeUrl = AnalyzeUrl(book = book, ruleUrl = book.tocUrl)
val analyzeUrl = AnalyzeUrl(book = book, ruleUrl = book.tocUrl, baseUrl = book.bookUrl)
val response = analyzeUrl.getResponseAsync().await()
BookChapterList.analyzeChapterList(this, book, response, bookSource, analyzeUrl)
}
@ -45,9 +45,9 @@ class WebBook(private val bookSource: BookSource) {
fun getContent(book: Book, bookChapter: BookChapter): Coroutine<String> {
return Coroutine.async {
val analyzeUrl = AnalyzeUrl(book = book, ruleUrl = bookChapter.url)
val analyzeUrl = AnalyzeUrl(book = book, ruleUrl = bookChapter.url, baseUrl = book.tocUrl)
val response = analyzeUrl.getResponseAsync().await()
BookContent.analyzeContent(this, response, book, bookChapter, bookSource, analyzeUrl)
BookContent.analyzeContent(this, response, book, bookSource)
}
}
}

@ -3,7 +3,6 @@ package io.legado.app.model.webbook
import io.legado.app.App
import io.legado.app.R
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.rule.ContentRule
import io.legado.app.model.analyzeRule.AnalyzeRule
@ -20,9 +19,7 @@ object BookContent {
coroutineScope: CoroutineScope,
response: Response<String>,
book: Book,
bookChapter: BookChapter,
bookSource: BookSource,
analyzeUrl: AnalyzeUrl
bookSource: BookSource
): String {
val baseUrl: String = NetworkUtils.getUrl(response)
val body: String? = response.body()

Loading…
Cancel
Save