From dd978469f110ca0053752256b0857909ce7a798e Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 11:58:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=A1=E9=AA=8C=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E5=88=86=E7=BB=84=E5=92=8C=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/CheckSourceService.kt | 17 ++++++++++------- .../ui/book/source/manage/BookSourceAdapter.kt | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 0d4ac1351..7735fa736 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -15,6 +15,8 @@ import io.legado.app.help.coroutine.CompositeCoroutine import io.legado.app.model.CheckSource import io.legado.app.model.Debug import io.legado.app.model.NoStackTraceException +import io.legado.app.model.ContentEmptyException +import io.legado.app.model.TocEmptyException import io.legado.app.model.webBook.WebBook import io.legado.app.ui.book.source.manage.BookSourceActivity import io.legado.app.utils.activityPendingIntent @@ -173,9 +175,10 @@ class CheckSourceService : BaseService() { if (CheckSource.checkCategory) { val toc = WebBook.getChapterListAwait(this, source, book) val nextChapterUrl = toc.getOrNull(1)?.url ?: toc.first().url + source.removeGroup("目录失效") //校验正文 if (CheckSource.checkContent) { - val content = WebBook.getContentAwait( + WebBook.getContentAwait( this, bookSource = source, book = book, @@ -183,9 +186,7 @@ class CheckSourceService : BaseService() { nextChapterUrl = nextChapterUrl, needSave = false ) - if ( !toc.first().isVolume && content.isBlank()) { - throw NoStackTraceException("正文内容为空") - } + source.removeGroup("正文失效") } } } @@ -193,20 +194,22 @@ class CheckSourceService : BaseService() { if (source.hasGroup("发现失效")) throw NoStackTraceException("发现失效") }.timeout(CheckSource.timeout) .onError(searchCoroutine) { - source.addGroup("失效") + when(it) { + is ContentEmptyException -> source.addGroup("正文失效") + is TocEmptyException -> source.addGroup("目录失效") + } if (source.bookSourceComment?.contains("Error: ") == false) { source.bookSourceComment = "Error: ${it.localizedMessage} \n\n" + "${source.bookSourceComment}" } Debug.updateFinalMessage(source.bookSourceUrl, "失败:${it.localizedMessage}") }.onSuccess(searchCoroutine) { - source.removeGroup("失效") source.bookSourceComment = source.bookSourceComment ?.split("\n\n") ?.filterNot { it.startsWith("Error: ") }?.joinToString("\n") - Debug.updateFinalMessage(source.bookSourceUrl, "成功") + Debug.updateFinalMessage(source.bookSourceUrl, "校验成功") }.onFinally(searchCoroutine) { source.respondTime = Debug.getRespondTime(source.bookSourceUrl) appDb.bookSourceDao.update(source) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index 1c663c27b..9ffeed0d3 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -92,7 +92,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : var isFinalMessage = ivDebugText.text.toString().contains(Regex("成功|失败")) if (!isEmpty && !Debug.isChecking && !isFinalMessage) { - Debug.updateFinalMessage(item.bookSourceUrl, "失败") + Debug.updateFinalMessage(item.bookSourceUrl, "校验失败") ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" isFinalMessage = true }