|
|
@ -189,21 +189,31 @@ object WebBook { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
suspend fun getChapterListAwait( |
|
|
|
fun runPreUpdateJs(bookSource: BookSource, book: Book): Result<Boolean> { |
|
|
|
bookSource: BookSource, |
|
|
|
|
|
|
|
book: Book, |
|
|
|
|
|
|
|
runPerJs: Boolean = false |
|
|
|
|
|
|
|
): Result<List<BookChapter>> { |
|
|
|
|
|
|
|
book.type = bookSource.getBookType() |
|
|
|
|
|
|
|
return kotlin.runCatching { |
|
|
|
return kotlin.runCatching { |
|
|
|
val preUpdateJs = bookSource.ruleToc?.preUpdateJs |
|
|
|
val preUpdateJs = bookSource.ruleToc?.preUpdateJs |
|
|
|
if (runPerJs && !preUpdateJs.isNullOrBlank()) { |
|
|
|
if (!preUpdateJs.isNullOrBlank()) { |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
AnalyzeRule(book, bookSource).evalJS(preUpdateJs) |
|
|
|
AnalyzeRule(book, bookSource).evalJS(preUpdateJs) |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
AppLog.put("执行preUpdateJs规则失败 书源:${bookSource.bookSourceName}", it) |
|
|
|
AppLog.put("执行preUpdateJs规则失败 书源:${bookSource.bookSourceName}", it) |
|
|
|
throw it |
|
|
|
throw it |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return@runCatching true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return@runCatching false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
suspend fun getChapterListAwait( |
|
|
|
|
|
|
|
bookSource: BookSource, |
|
|
|
|
|
|
|
book: Book, |
|
|
|
|
|
|
|
runPerJs: Boolean = false |
|
|
|
|
|
|
|
): Result<List<BookChapter>> { |
|
|
|
|
|
|
|
book.type = bookSource.getBookType() |
|
|
|
|
|
|
|
return kotlin.runCatching { |
|
|
|
|
|
|
|
if (runPerJs) { |
|
|
|
|
|
|
|
runPreUpdateJs(bookSource, book).getOrThrow() |
|
|
|
} |
|
|
|
} |
|
|
|
if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { |
|
|
|
if (book.bookUrl == book.tocUrl && !book.tocHtml.isNullOrEmpty()) { |
|
|
|
BookChapterList.analyzeChapterList( |
|
|
|
BookChapterList.analyzeChapterList( |
|
|
|