pull/46/head
kunfei 5 years ago
parent 3f92af5b79
commit dddd3caba0
  1. 18
      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()
if (analyzeUrl.useWebView()) {
analyzeUrl.getResultByWebView(bookSource.bookSourceUrl)
} else {
book.infoHtml
analyzeUrl.getResponseAwait().body()
}
}
BookInfo.analyzeBookInfo(book, body, bookSource, book.bookUrl)
book
@ -120,8 +124,12 @@ class WebBook(val bookSource: BookSource) {
baseUrl = book.bookUrl,
headerMapF = bookSource.getHeaderMap()
)
if (analyzeUrl.useWebView()) {
analyzeUrl.getResultByWebView(bookSource.bookSourceUrl)
} else {
analyzeUrl.getResponseAwait().body()
}
}
BookChapterList.analyzeChapterList(this, book, body, bookSource, book.tocUrl)
}
}
@ -150,8 +158,12 @@ class WebBook(val bookSource: BookSource) {
baseUrl = book.tocUrl,
headerMapF = bookSource.getHeaderMap()
)
if (analyzeUrl.useWebView()) {
analyzeUrl.getResultByWebView(bookSource.bookSourceUrl)
} else {
analyzeUrl.getResponseAwait().body()
}
}
BookContent.analyzeContent(
this,
body,

@ -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