This commit is contained in:
Horis
2025-02-01 14:49:59 +08:00
parent 899f910797
commit cce7b9ee0a
2 changed files with 16 additions and 5 deletions
@@ -32,6 +32,7 @@ object BookList {
baseUrl: String, baseUrl: String,
body: String?, body: String?,
isSearch: Boolean = true, isSearch: Boolean = true,
isRedirect: Boolean = false
): ArrayList<SearchBook> { ): ArrayList<SearchBook> {
body ?: throw NoStackTraceException( body ?: throw NoStackTraceException(
appCtx.getString( appCtx.getString(
@@ -53,9 +54,11 @@ object BookList {
getInfoItem( getInfoItem(
bookSource, bookSource,
analyzeRule, analyzeRule,
analyzeUrl,
body, body,
baseUrl, baseUrl,
ruleData.getVariable() ruleData.getVariable(),
isRedirect
)?.let { searchBook -> )?.let { searchBook ->
searchBook.infoHtml = body searchBook.infoHtml = body
bookList.add(searchBook) bookList.add(searchBook)
@@ -84,7 +87,8 @@ object BookList {
if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) { if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) {
Debug.log(bookSource.bookSourceUrl, "└列表为空,按详情页解析") Debug.log(bookSource.bookSourceUrl, "└列表为空,按详情页解析")
getInfoItem( getInfoItem(
bookSource, analyzeRule, body, baseUrl, ruleData.getVariable() bookSource, analyzeRule, analyzeUrl, body, baseUrl, ruleData.getVariable(),
isRedirect
)?.let { searchBook -> )?.let { searchBook ->
searchBook.infoHtml = body searchBook.infoHtml = body
bookList.add(searchBook) bookList.add(searchBook)
@@ -133,12 +137,18 @@ object BookList {
private suspend fun getInfoItem( private suspend fun getInfoItem(
bookSource: BookSource, bookSource: BookSource,
analyzeRule: AnalyzeRule, analyzeRule: AnalyzeRule,
analyzeUrl: AnalyzeUrl,
body: String, body: String,
baseUrl: String, baseUrl: String,
variable: String? variable: String?,
isRedirect: Boolean
): SearchBook? { ): SearchBook? {
val book = Book(variable = variable) val book = Book(variable = variable)
book.bookUrl = baseUrl book.bookUrl = if (isRedirect) {
baseUrl
} else {
NetworkUtils.getAbsoluteURL(analyzeUrl.url, analyzeUrl.ruleUrl)
}
book.origin = bookSource.bookSourceUrl book.origin = bookSource.bookSourceUrl
book.originName = bookSource.bookSourceName book.originName = bookSource.bookSourceName
book.originOrder = bookSource.customOrder book.originOrder = bookSource.customOrder
@@ -79,7 +79,8 @@ object WebBook {
analyzeUrl = analyzeUrl, analyzeUrl = analyzeUrl,
baseUrl = res.url, baseUrl = res.url,
body = res.body, body = res.body,
isSearch = true isSearch = true,
isRedirect = res.raw.priorResponse?.isRedirect == true
) )
} }