From 52e3034f348e609e58e7dbe618080963b06a8ee0 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 8 Apr 2021 20:43:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=97=B6,=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=B9=B6=E4=B8=8B=E8=BD=BD=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/BookHelp.kt | 18 ++++++++++++++++++ .../io/legado/app/service/CacheBookService.kt | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 3e6731912..aa89a5505 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.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) diff --git a/app/src/main/java/io/legado/app/service/CacheBookService.kt b/app/src/main/java/io/legado/app/service/CacheBookService.kt index 963dc534c..9ed25441b 100644 --- a/app/src/main/java/io/legado/app/service/CacheBookService.kt +++ b/app/src/main/java/io/legado/app/service/CacheBookService.kt @@ -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 {