|
|
@ -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 |
|
|
@ -121,6 +123,11 @@ class CheckSourceService : BaseService() { |
|
|
|
searchWord = it |
|
|
|
searchWord = it |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
source.bookSourceComment = source.bookSourceComment |
|
|
|
|
|
|
|
?.split("\n\n") |
|
|
|
|
|
|
|
?.filterNot { |
|
|
|
|
|
|
|
it.startsWith("Error: ") |
|
|
|
|
|
|
|
}?.joinToString("\n") |
|
|
|
//校验搜索 用户设置校验搜索 并且 搜索链接不为空 |
|
|
|
//校验搜索 用户设置校验搜索 并且 搜索链接不为空 |
|
|
|
if (CheckSource.checkSearch && !source.searchUrl.isNullOrBlank()) { |
|
|
|
if (CheckSource.checkSearch && !source.searchUrl.isNullOrBlank()) { |
|
|
|
val searchBooks = WebBook.searchBookAwait(this, source, searchWord) |
|
|
|
val searchBooks = WebBook.searchBookAwait(this, source, searchWord) |
|
|
@ -173,9 +180,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 +191,7 @@ class CheckSourceService : BaseService() { |
|
|
|
nextChapterUrl = nextChapterUrl, |
|
|
|
nextChapterUrl = nextChapterUrl, |
|
|
|
needSave = false |
|
|
|
needSave = false |
|
|
|
) |
|
|
|
) |
|
|
|
if ( !toc.first().isVolume && content.isBlank()) { |
|
|
|
source.removeGroup("正文失效") |
|
|
|
throw NoStackTraceException("正文内容为空") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -193,20 +199,15 @@ 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) { |
|
|
|
if (source.bookSourceComment?.contains("Error: ") == false) { |
|
|
|
is ContentEmptyException -> source.addGroup("正文失效") |
|
|
|
source.bookSourceComment = |
|
|
|
is TocEmptyException -> source.addGroup("目录失效") |
|
|
|
"Error: ${it.localizedMessage} \n\n" + "${source.bookSourceComment}" |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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("失效") |
|
|
|
Debug.updateFinalMessage(source.bookSourceUrl, "校验成功") |
|
|
|
source.bookSourceComment = source.bookSourceComment |
|
|
|
|
|
|
|
?.split("\n\n") |
|
|
|
|
|
|
|
?.filterNot { |
|
|
|
|
|
|
|
it.startsWith("Error: ") |
|
|
|
|
|
|
|
}?.joinToString("\n") |
|
|
|
|
|
|
|
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) |
|
|
|