|
@@ -15,6 +15,8 @@ import io.legado.app.help.coroutine.CompositeCoroutine
|
|
|
import io.legado.app.model.CheckSource
|
|
import io.legado.app.model.CheckSource
|
|
|
import io.legado.app.model.Debug
|
|
import io.legado.app.model.Debug
|
|
|
import io.legado.app.model.NoStackTraceException
|
|
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.model.webBook.WebBook
|
|
|
import io.legado.app.ui.book.source.manage.BookSourceActivity
|
|
import io.legado.app.ui.book.source.manage.BookSourceActivity
|
|
|
import io.legado.app.utils.activityPendingIntent
|
|
import io.legado.app.utils.activityPendingIntent
|
|
@@ -173,9 +175,10 @@ class CheckSourceService : BaseService() {
|
|
|
if (CheckSource.checkCategory) {
|
|
if (CheckSource.checkCategory) {
|
|
|
val toc = WebBook.getChapterListAwait(this, source, book)
|
|
val toc = WebBook.getChapterListAwait(this, source, book)
|
|
|
val nextChapterUrl = toc.getOrNull(1)?.url ?: toc.first().url
|
|
val nextChapterUrl = toc.getOrNull(1)?.url ?: toc.first().url
|
|
|
|
|
+ source.removeGroup("目录失效")
|
|
|
//校验正文
|
|
//校验正文
|
|
|
if (CheckSource.checkContent) {
|
|
if (CheckSource.checkContent) {
|
|
|
- val content = WebBook.getContentAwait(
|
|
|
|
|
|
|
+ WebBook.getContentAwait(
|
|
|
this,
|
|
this,
|
|
|
bookSource = source,
|
|
bookSource = source,
|
|
|
book = book,
|
|
book = book,
|
|
@@ -183,9 +186,7 @@ class CheckSourceService : BaseService() {
|
|
|
nextChapterUrl = nextChapterUrl,
|
|
nextChapterUrl = nextChapterUrl,
|
|
|
needSave = false
|
|
needSave = false
|
|
|
)
|
|
)
|
|
|
- if ( !toc.first().isVolume && content.isBlank()) {
|
|
|
|
|
- throw NoStackTraceException("正文内容为空")
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ source.removeGroup("正文失效")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -193,20 +194,22 @@ class CheckSourceService : BaseService() {
|
|
|
if (source.hasGroup("发现失效")) throw NoStackTraceException("发现失效")
|
|
if (source.hasGroup("发现失效")) throw NoStackTraceException("发现失效")
|
|
|
}.timeout(CheckSource.timeout)
|
|
}.timeout(CheckSource.timeout)
|
|
|
.onError(searchCoroutine) {
|
|
.onError(searchCoroutine) {
|
|
|
- source.addGroup("失效")
|
|
|
|
|
|
|
+ when(it) {
|
|
|
|
|
+ is ContentEmptyException -> source.addGroup("正文失效")
|
|
|
|
|
+ is TocEmptyException -> source.addGroup("目录失效")
|
|
|
|
|
+ }
|
|
|
if (source.bookSourceComment?.contains("Error: ") == false) {
|
|
if (source.bookSourceComment?.contains("Error: ") == false) {
|
|
|
source.bookSourceComment =
|
|
source.bookSourceComment =
|
|
|
"Error: ${it.localizedMessage} \n\n" + "${source.bookSourceComment}"
|
|
"Error: ${it.localizedMessage} \n\n" + "${source.bookSourceComment}"
|
|
|
}
|
|
}
|
|
|
Debug.updateFinalMessage(source.bookSourceUrl, "失败:${it.localizedMessage}")
|
|
Debug.updateFinalMessage(source.bookSourceUrl, "失败:${it.localizedMessage}")
|
|
|
}.onSuccess(searchCoroutine) {
|
|
}.onSuccess(searchCoroutine) {
|
|
|
- source.removeGroup("失效")
|
|
|
|
|
source.bookSourceComment = source.bookSourceComment
|
|
source.bookSourceComment = source.bookSourceComment
|
|
|
?.split("\n\n")
|
|
?.split("\n\n")
|
|
|
?.filterNot {
|
|
?.filterNot {
|
|
|
it.startsWith("Error: ")
|
|
it.startsWith("Error: ")
|
|
|
}?.joinToString("\n")
|
|
}?.joinToString("\n")
|
|
|
- Debug.updateFinalMessage(source.bookSourceUrl, "成功")
|
|
|
|
|
|
|
+ Debug.updateFinalMessage(source.bookSourceUrl, "校验成功")
|
|
|
}.onFinally(searchCoroutine) {
|
|
}.onFinally(searchCoroutine) {
|
|
|
source.respondTime = Debug.getRespondTime(source.bookSourceUrl)
|
|
source.respondTime = Debug.getRespondTime(source.bookSourceUrl)
|
|
|
appDb.bookSourceDao.update(source)
|
|
appDb.bookSourceDao.update(source)
|