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

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

Loading…
Cancel
Save