diff --git a/app/src/main/java/io/legado/app/model/WebBook.kt b/app/src/main/java/io/legado/app/model/WebBook.kt index 545f673ec..b6f4b90dc 100644 --- a/app/src/main/java/io/legado/app/model/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/WebBook.kt @@ -33,7 +33,7 @@ class WebBook(private val bookSource: BookSource) : CoroutineScope by MainScope( } return@with BookList().analyzeBookList(response, bookSource, analyzeUrl) } - ArrayList() + return@with ArrayList() } } diff --git a/app/src/main/java/io/legado/app/model/webbook/BookList.kt b/app/src/main/java/io/legado/app/model/webbook/BookList.kt index 2078c93d2..ee66e20c0 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookList.kt @@ -4,7 +4,9 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.SearchBook +import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeUrl +import io.legado.app.utils.NetworkUtils import retrofit2.Response class BookList { @@ -17,13 +19,16 @@ class BookList { isSearch: Boolean = true ): ArrayList { var bookList = ArrayList() + val baseUrl: String = NetworkUtils.getUrl(response) val body: String? = response.body() body ?: throw Exception( App.INSTANCE.getString( R.string.get_web_content_error, - analyzeUrl.url + baseUrl ) ) + val analyzer = AnalyzeRule(null) + analyzer.setContent(body, baseUrl) return bookList } diff --git a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt index ae2d42d47..90e68f004 100644 --- a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt +++ b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt @@ -1,10 +1,16 @@ package io.legado.app.utils import android.text.TextUtils +import retrofit2.Response import java.net.URL import java.util.* object NetworkUtils { + fun getUrl(response: Response<*>): String { + val networkResponse = response.raw().networkResponse() + return networkResponse?.request()?.url()?.toString() + ?: response.raw().request().url().toString() + } private val notNeedEncoding: BitSet by lazy { val bitSet = BitSet(256)