diff --git a/src/main/java/org/lightink/reader/ReaderApplication.kt b/src/main/java/org/lightink/reader/ReaderApplication.kt index f33718e..49d303c 100644 --- a/src/main/java/org/lightink/reader/ReaderApplication.kt +++ b/src/main/java/org/lightink/reader/ReaderApplication.kt @@ -35,7 +35,8 @@ class ReaderApplication { private lateinit var restVerticle: RestVerticle companion object { - fun vertx() = Vertx.vertx() + val vertx by lazy { Vertx.vertx() } + fun vertx() = vertx } @PostConstruct diff --git a/src/main/java/org/lightink/reader/api/YueduApi.kt b/src/main/java/org/lightink/reader/api/YueduApi.kt index 3ef1de4..33188c6 100644 --- a/src/main/java/org/lightink/reader/api/YueduApi.kt +++ b/src/main/java/org/lightink/reader/api/YueduApi.kt @@ -40,6 +40,8 @@ class YueduApi : BaseApi { it.success(YueduSchedule.Shuyuan.shuyuanlist) } + + private fun getBookInfo(context: RoutingContext) { val bookSourceCode = context.bodyAsJson.getString("bookSourceCode") val bookSource = if (bookSourceCode != null) { @@ -64,7 +66,7 @@ class YueduApi : BaseApi { } else { context.bodyAsJson.getJsonObject("bookSource").toString() } - val book = context.bodyAsJson.getJsonObject("book").mapTo(Book::class.java) + val book = context.bodyAsJson.getJsonObject("book")?.mapTo(Book::class.java) val bookChapter = context.bodyAsJson.getJsonObject("bookChapter").mapTo(BookChapter::class.java) WebBook(bookSource).getContent(book, bookChapter) .onSuccess { diff --git a/src/main/java/org/lightink/reader/service/yuedu/WebBook.kt b/src/main/java/org/lightink/reader/service/yuedu/WebBook.kt index 862584b..dea6a89 100644 --- a/src/main/java/org/lightink/reader/service/yuedu/WebBook.kt +++ b/src/main/java/org/lightink/reader/service/yuedu/WebBook.kt @@ -15,6 +15,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import mu.KotlinLogging import kotlin.coroutines.CoroutineContext + private val logger = KotlinLogging.logger {} class WebBook(val bookSource: BookSource) { @@ -45,7 +46,7 @@ class WebBook(val bookSource: BookSource) { ) val currentTimeMillis = System.currentTimeMillis() val res = analyzeUrl.getResponseAwait() - logger.info { "getResponseAwait " + (System.currentTimeMillis() - currentTimeMillis)} + logger.info { "getResponseAwait " + (System.currentTimeMillis() - currentTimeMillis) } BookList.analyzeBookList( res.body, bookSource, @@ -138,7 +139,7 @@ class WebBook(val bookSource: BookSource) { * 章节内容 */ fun getContent( - book: Book, + book: Book?, bookChapter: BookChapter, nextChapterUrl: String? = null, scope: CoroutineScope = Coroutine.DEFAULT, @@ -148,14 +149,14 @@ class WebBook(val bookSource: BookSource) { if (bookSource.getContentRule().content.isNullOrEmpty()) { return@async bookChapter.url } - val body = if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) { + val body = if (book != null && bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) { book.tocHtml } else { val analyzeUrl = AnalyzeUrl( book = book, ruleUrl = bookChapter.url, - baseUrl = book.tocUrl, + baseUrl = book?.tocUrl, headerMapF = bookSource.getHeaderMap() ) analyzeUrl.getResponseAwait( diff --git a/src/main/java/org/lightink/reader/service/yuedu/analyzeRule/AnalyzeUrl.kt b/src/main/java/org/lightink/reader/service/yuedu/analyzeRule/AnalyzeUrl.kt index 630cf2d..10a1471 100644 --- a/src/main/java/org/lightink/reader/service/yuedu/analyzeRule/AnalyzeUrl.kt +++ b/src/main/java/org/lightink/reader/service/yuedu/analyzeRule/AnalyzeUrl.kt @@ -46,8 +46,8 @@ class AnalyzeUrl( private var baseUrl: String = "" lateinit var url: String private set - var path: String? = null - private set +// var path: String? = null +// private set val headerMap = HashMap() private var queryStr: String? = null private val fieldMap = LinkedHashMap() diff --git a/src/main/java/org/lightink/reader/service/yuedu/webbook/BookContent.kt b/src/main/java/org/lightink/reader/service/yuedu/webbook/BookContent.kt index 0b8e9fa..7f6bd5d 100644 --- a/src/main/java/org/lightink/reader/service/yuedu/webbook/BookContent.kt +++ b/src/main/java/org/lightink/reader/service/yuedu/webbook/BookContent.kt @@ -19,7 +19,7 @@ object BookContent { suspend fun analyzeContent( coroutineScope: CoroutineScope, body: String?, - book: Book, + book: Book?, bookChapter: BookChapter, bookSource: BookSource, baseUrl: String, @@ -108,7 +108,7 @@ object BookContent { private fun analyzeContent( body: String, contentRule: ContentRule, - book: Book, + book: Book?, chapter: BookChapter, bookSource: BookSource, baseUrl: String,