书籍url取解析后的地址

pull/1259/head
gedoor 3 years ago
parent ffb95cb53d
commit 477f30a109
  1. 40
      app/src/main/java/io/legado/app/model/webBook/BookList.kt

@ -46,11 +46,12 @@ 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, body, analyzeRule, bookSource, baseUrl, variableBook.variable) getInfoItem(
?.let { searchBook -> scope, bookSource, analyzeRule, analyzeUrl, body, baseUrl, variableBook.variable
searchBook.infoHtml = body )?.let { searchBook ->
bookList.add(searchBook) searchBook.infoHtml = body
} bookList.add(searchBook)
}
return bookList return bookList
} }
} }
@ -74,11 +75,12 @@ 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, body, analyzeRule, bookSource, baseUrl, variableBook.variable) getInfoItem(
?.let { searchBook -> scope, bookSource, analyzeRule, analyzeUrl, body, baseUrl, variableBook.variable
searchBook.infoHtml = body )?.let { searchBook ->
bookList.add(searchBook) searchBook.infoHtml = body
} bookList.add(searchBook)
}
} else { } else {
val ruleName = analyzeRule.splitSourceRule(bookListRule.name) val ruleName = analyzeRule.splitSourceRule(bookListRule.name)
val ruleBookUrl = analyzeRule.splitSourceRule(bookListRule.bookUrl) val ruleBookUrl = analyzeRule.splitSourceRule(bookListRule.bookUrl)
@ -91,12 +93,7 @@ object BookList {
Debug.log(bookSource.bookSourceUrl, "└列表大小:${collections.size}") Debug.log(bookSource.bookSourceUrl, "└列表大小:${collections.size}")
for ((index, item) in collections.withIndex()) { for ((index, item) in collections.withIndex()) {
getSearchItem( getSearchItem(
scope, scope, bookSource, analyzeRule, item, baseUrl, variableBook.variable,
item,
analyzeRule,
bookSource,
baseUrl,
variableBook.variable,
index == 0, index == 0,
ruleName = ruleName, ruleName = ruleName,
ruleBookUrl = ruleBookUrl, ruleBookUrl = ruleBookUrl,
@ -123,14 +120,15 @@ object BookList {
@Throws(Exception::class) @Throws(Exception::class)
private fun getInfoItem( private fun getInfoItem(
scope: CoroutineScope, scope: CoroutineScope,
body: String,
analyzeRule: AnalyzeRule,
bookSource: BookSource, bookSource: BookSource,
analyzeRule: AnalyzeRule,
analyzeUrl: AnalyzeUrl,
body: String,
baseUrl: String, baseUrl: String,
variable: String? variable: String?
): SearchBook? { ): SearchBook? {
val book = Book(variable = variable) val book = Book(variable = variable)
book.bookUrl = baseUrl book.bookUrl = 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
@ -155,9 +153,9 @@ object BookList {
@Throws(Exception::class) @Throws(Exception::class)
private fun getSearchItem( private fun getSearchItem(
scope: CoroutineScope, scope: CoroutineScope,
item: Any,
analyzeRule: AnalyzeRule,
bookSource: BookSource, bookSource: BookSource,
analyzeRule: AnalyzeRule,
item: Any,
baseUrl: String, baseUrl: String,
variable: String?, variable: String?,
log: Boolean, log: Boolean,

Loading…
Cancel
Save