From e3caa4f81f4b406d5874bfab82e80eb0ef36e52e Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 12 Jul 2019 14:31:03 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/model/WebBook.kt | 2 +- app/src/main/java/io/legado/app/model/webbook/BookList.kt | 7 ++++++- app/src/main/java/io/legado/app/utils/NetworkUtils.kt | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) 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)