diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 89555fe9e..bb9ac86da 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -25,8 +25,8 @@ data class Book( var customTag: String? = null, // 分类信息(用户修改) var coverUrl: String? = null, // 封面Url(书源获取) var customCoverUrl: String? = null, // 封面Url(用户修改) - var description: String? = null, // 简介内容(书源获取) - var customDescription: String? = null, // 简介内容(用户修改) + var intro: String? = null, // 简介内容(书源获取) + var customIntro: String? = null, // 简介内容(用户修改) var charset: String? = null, // 自定义字符集名称(仅适用于本地书籍) var type: Int = 0, // @BookType var group: Int = 0, // 自定义分组索引号 @@ -56,7 +56,7 @@ data class Book( fun getDisplayCover() = customCoverUrl ?: coverUrl - fun getDisplayDescription() = customDescription ?: description + fun getDisplayIntro() = customIntro ?: intro private fun initVariableMap() { if (variableMap == null) { diff --git a/app/src/main/java/io/legado/app/model/webbook/BookInfo.kt b/app/src/main/java/io/legado/app/model/webbook/BookInfo.kt index 4c241bd69..3b03ca292 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookInfo.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookInfo.kt @@ -4,6 +4,7 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookSource +import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeUrl object BookInfo { @@ -23,7 +24,26 @@ object BookInfo { baseUrl ) ) - + val infoRule = bookSource.getBookInfoRule() + val analyzeRule = AnalyzeRule(book) + analyzeRule.setContent(body) + infoRule.init?.let { + if (it.isNotEmpty()) { + analyzeRule.setContent(analyzeRule.getElement(it)) + } + } + analyzeRule.getString(infoRule.name ?: "")?.let { + if (it.isNotEmpty()) book.name = it + } + analyzeRule.getString(infoRule.author ?: "")?.let { + if (it.isNotEmpty()) book.author = it + } + analyzeRule.getString(infoRule.kind ?: "")?.let { + if (it.isNotEmpty()) book.kind = it + } + analyzeRule.getString(infoRule.intro ?: "")?.let { + if (it.isNotEmpty()) book.intro = it + } }