pull/873/head
gedoor 4 years ago
parent 6fd6657c15
commit 8823a8a7af
  1. 5
      app/src/main/java/io/legado/app/model/webBook/BookInfo.kt
  2. 16
      app/src/main/java/io/legado/app/model/webBook/BookList.kt

@ -32,12 +32,13 @@ object BookInfo {
val analyzeRule = AnalyzeRule(book) val analyzeRule = AnalyzeRule(book)
analyzeRule.setContent(body).setBaseUrl(baseUrl) analyzeRule.setContent(body).setBaseUrl(baseUrl)
analyzeRule.setRedirectUrl(redirectUrl) analyzeRule.setRedirectUrl(redirectUrl)
analyzeBookInfo(scope, book, analyzeRule, bookSource, baseUrl, redirectUrl, canReName) analyzeBookInfo(scope, book, body, analyzeRule, bookSource, baseUrl, redirectUrl, canReName)
} }
fun analyzeBookInfo( fun analyzeBookInfo(
scope: CoroutineScope, scope: CoroutineScope,
book: Book, book: Book,
body: String,
analyzeRule: AnalyzeRule, analyzeRule: AnalyzeRule,
bookSource: BookSource, bookSource: BookSource,
baseUrl: String, baseUrl: String,
@ -106,7 +107,7 @@ object BookInfo {
book.tocUrl = analyzeRule.getString(infoRule.tocUrl, true) book.tocUrl = analyzeRule.getString(infoRule.tocUrl, true)
if (book.tocUrl.isEmpty()) book.tocUrl = baseUrl if (book.tocUrl.isEmpty()) book.tocUrl = baseUrl
if (book.tocUrl == baseUrl) { if (book.tocUrl == baseUrl) {
book.tocHtml = analyzeRule.content.toString() book.tocHtml = body
} }
Debug.log(bookSource.bookSourceUrl, "${book.tocUrl}") Debug.log(bookSource.bookSourceUrl, "${book.tocUrl}")
} }

@ -43,7 +43,7 @@ object BookList {
scope.ensureActive() scope.ensureActive()
if (baseUrl.matches(it.toRegex())) { if (baseUrl.matches(it.toRegex())) {
Debug.log(bookSource.bookSourceUrl, "≡链接为详情页") Debug.log(bookSource.bookSourceUrl, "≡链接为详情页")
getInfoItem(scope, analyzeRule, bookSource, baseUrl, variableBook.variable) getInfoItem(scope, body, analyzeRule, bookSource, baseUrl, variableBook.variable)
?.let { searchBook -> ?.let { searchBook ->
searchBook.infoHtml = body searchBook.infoHtml = body
bookList.add(searchBook) bookList.add(searchBook)
@ -71,7 +71,7 @@ object BookList {
scope.ensureActive() scope.ensureActive()
if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) { if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) {
Debug.log(bookSource.bookSourceUrl, "└列表为空,按详情页解析") Debug.log(bookSource.bookSourceUrl, "└列表为空,按详情页解析")
getInfoItem(scope, analyzeRule, bookSource, baseUrl, variableBook.variable) getInfoItem(scope, body, analyzeRule, bookSource, baseUrl, variableBook.variable)
?.let { searchBook -> ?.let { searchBook ->
searchBook.infoHtml = body searchBook.infoHtml = body
bookList.add(searchBook) bookList.add(searchBook)
@ -120,6 +120,7 @@ object BookList {
@Throws(Exception::class) @Throws(Exception::class)
private fun getInfoItem( private fun getInfoItem(
scope: CoroutineScope, scope: CoroutineScope,
body: String,
analyzeRule: AnalyzeRule, analyzeRule: AnalyzeRule,
bookSource: BookSource, bookSource: BookSource,
baseUrl: String, baseUrl: String,
@ -132,7 +133,16 @@ object BookList {
book.originOrder = bookSource.customOrder book.originOrder = bookSource.customOrder
book.type = bookSource.bookSourceType book.type = bookSource.bookSourceType
analyzeRule.book = book analyzeRule.book = book
BookInfo.analyzeBookInfo(scope, book, analyzeRule, bookSource, baseUrl, baseUrl, false) BookInfo.analyzeBookInfo(
scope,
book,
body,
analyzeRule,
bookSource,
baseUrl,
baseUrl,
false
)
if (book.name.isNotBlank()) { if (book.name.isNotBlank()) {
return book.toSearchBook() return book.toSearchBook()
} }

Loading…
Cancel
Save