下载时,检查并下载图片

pull/946/head
gedoor 4 years ago
parent f6fcd2b3b6
commit 52e3034f34
  1. 18
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 2
      app/src/main/java/io/legado/app/service/CacheBookService.kt

@ -149,6 +149,24 @@ object BookHelp {
}
}
fun hasImageContent(book: Book, bookChapter: BookChapter): Boolean {
if (!hasContent(book, bookChapter)) {
return false
}
getContent(book, bookChapter)?.let {
val matcher = AppPattern.imgPattern.matcher(it)
while (matcher.find()) {
matcher.group(1)?.let { src ->
val image = getImage(book, src)
if (!image.exists()) {
return false
}
}
}
}
return true
}
fun getContent(book: Book, bookChapter: BookChapter): String? {
if (book.isLocalTxt()) {
return LocalBook.getContext(book, bookChapter)

@ -184,7 +184,7 @@ class CacheBookService : BaseService() {
postDownloading(true)
return@async
}
if (!BookHelp.hasContent(book, bookChapter)) {
if (!BookHelp.hasImageContent(book, bookChapter)) {
webBook.getContent(this, book, bookChapter, context = searchPool)
.timeout(60000L)
.onError {

Loading…
Cancel
Save