pull/32/head
kunfei 5 years ago
parent 24e98561c9
commit 9f2cab3828
  1. 6
      app/src/main/java/io/legado/app/data/entities/Book.kt
  2. 22
      app/src/main/java/io/legado/app/model/webbook/BookInfo.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) {

@ -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
}
}

Loading…
Cancel
Save