pull/46/head
kunfei 5 years ago
parent 3f92af5b79
commit dddd3caba0
  1. 24
      app/src/main/java/io/legado/app/model/WebBook.kt
  2. 4
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -86,16 +86,20 @@ class WebBook(val bookSource: BookSource) {
context: CoroutineContext = Dispatchers.IO
): Coroutine<Book> {
return Coroutine.async(scope, context) {
val body = if (book.infoHtml.isNullOrEmpty()) {
val body = if (!book.infoHtml.isNullOrEmpty()) {
book.infoHtml
} else {
val analyzeUrl = AnalyzeUrl(
book = book,
ruleUrl = book.bookUrl,
baseUrl = sourceUrl,
headerMapF = bookSource.getHeaderMap()
)
analyzeUrl.getResponseAwait().body()
} else {
book.infoHtml
if (analyzeUrl.useWebView()) {
analyzeUrl.getResultByWebView(bookSource.bookSourceUrl)
} else {
analyzeUrl.getResponseAwait().body()
}
}
BookInfo.analyzeBookInfo(book, body, bookSource, book.bookUrl)
book
@ -120,7 +124,11 @@ class WebBook(val bookSource: BookSource) {
baseUrl = book.bookUrl,
headerMapF = bookSource.getHeaderMap()
)
analyzeUrl.getResponseAwait().body()
if (analyzeUrl.useWebView()) {
analyzeUrl.getResultByWebView(bookSource.bookSourceUrl)
} else {
analyzeUrl.getResponseAwait().body()
}
}
BookChapterList.analyzeChapterList(this, book, body, bookSource, book.tocUrl)
}
@ -150,7 +158,11 @@ class WebBook(val bookSource: BookSource) {
baseUrl = book.tocUrl,
headerMapF = bookSource.getHeaderMap()
)
analyzeUrl.getResponseAwait().body()
if (analyzeUrl.useWebView()) {
analyzeUrl.getResultByWebView(bookSource.bookSourceUrl)
} else {
analyzeUrl.getResponseAwait().body()
}
}
BookContent.analyzeContent(
this,

@ -292,6 +292,10 @@ class AnalyzeUrl(
}
}
fun useWebView(): Boolean {
return webViewJs != null || sourceRegex != null
}
suspend fun getResultByWebView(tag: String): String {
val params = AjaxWebView.AjaxParams(tag)
params.url = url

Loading…
Cancel
Save