pull/32/head
kunfei 5 years ago
parent 4941ea3c47
commit 5f0f9e2ec7
  1. 70
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  2. 2
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  3. 2
      app/src/main/java/io/legado/app/model/webbook/BookList.kt
  4. 4
      app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt
  5. 2
      app/src/main/res/values/strings.xml

@ -17,48 +17,48 @@ import java.util.*
@Parcelize
@Entity(
tableName = "book_sources",
indices = [(Index(value = ["bookSourceUrl"], unique = false))]
tableName = "book_sources",
indices = [(Index(value = ["bookSourceUrl"], unique = false))]
)
data class BookSource(
var bookSourceName: String = "", // 名称
var bookSourceGroup: String? = null, // 分组
@PrimaryKey
var bookSourceUrl: String = "", // 地址,包括 http/https
var bookSourceType: Int = 0, // 类型,0 文本,1 音频
var infoUrlPattern: String? = null,
var customOrder: Int = 0, // 手动排序编号
var enabled: Boolean = true, // 是否启用
var enabledExplore: Boolean = true, //启用发现
var header: String? = null, // header
var loginUrl: String? = null, // 登录地址
var lastUpdateTime: Long = 0, // 最后更新时间,用于排序
var weight: Int = 0, // 智能排序的权重
var ruleExplore: String? = null, // 发现规则
var ruleSearch: String? = null, // 搜索规则
var ruleBookInfo: String? = null, // 书籍信息页规则
var ruleToc: String? = null, // 目录页规则
var ruleContent: String? = null // 正文页规则
var bookSourceName: String = "", // 名称
var bookSourceGroup: String? = null, // 分组
@PrimaryKey
var bookSourceUrl: String = "", // 地址,包括 http/https
var bookSourceType: Int = 0, // 类型,0 文本,1 音频
var bookUrlPattern: String? = null,
var customOrder: Int = 0, // 手动排序编号
var enabled: Boolean = true, // 是否启用
var enabledExplore: Boolean = true, //启用发现
var header: String? = null, // header
var loginUrl: String? = null, // 登录地址
var lastUpdateTime: Long = 0, // 最后更新时间,用于排序
var weight: Int = 0, // 智能排序的权重
var ruleExplore: String? = null, // 发现规则
var ruleSearch: String? = null, // 搜索规则
var ruleBookInfo: String? = null, // 书籍信息页规则
var ruleToc: String? = null, // 目录页规则
var ruleContent: String? = null // 正文页规则
) : Parcelable {
@Ignore
@IgnoredOnParcel
var searchRuleV:SearchRule? = null
var searchRuleV: SearchRule? = null
@Ignore
@IgnoredOnParcel
var exploreRuleV:ExploreRule? = null
var exploreRuleV: ExploreRule? = null
@Ignore
@IgnoredOnParcel
var bookInfoRuleV:BookInfoRule? = null
var bookInfoRuleV: BookInfoRule? = null
@Ignore
@IgnoredOnParcel
var tocRuleV:TocRule? = null
var tocRuleV: TocRule? = null
@Ignore
@IgnoredOnParcel
var contentRuleV:ContentRule? = null
var contentRuleV: ContentRule? = null
fun getHeaderMap(): Map<String, String> {
val headerMap = HashMap<String, String>()
@ -73,41 +73,41 @@ data class BookSource(
fun getSearchRule(): SearchRule {
searchRuleV?:let {
searchRuleV ?: let {
searchRuleV = GSON.fromJsonObject<SearchRule>(ruleSearch)
searchRuleV?:let { searchRuleV = SearchRule() }
searchRuleV ?: let { searchRuleV = SearchRule() }
}
return searchRuleV!!
}
fun getExploreRule(): ExploreRule {
exploreRuleV?:let {
exploreRuleV ?: let {
exploreRuleV = GSON.fromJsonObject<ExploreRule>(ruleExplore)
exploreRuleV?:let { exploreRuleV = ExploreRule() }
exploreRuleV ?: let { exploreRuleV = ExploreRule() }
}
return exploreRuleV!!
}
fun getBookInfoRule(): BookInfoRule? {
bookInfoRuleV?:let {
bookInfoRuleV ?: let {
bookInfoRuleV = GSON.fromJsonObject<BookInfoRule>(ruleBookInfo)
bookInfoRuleV?:let { bookInfoRuleV = BookInfoRule() }
bookInfoRuleV ?: let { bookInfoRuleV = BookInfoRule() }
}
return bookInfoRuleV!!
}
fun getTocRule(): TocRule? {
tocRuleV?:let {
tocRuleV ?: let {
tocRuleV = GSON.fromJsonObject<TocRule>(ruleToc)
tocRuleV?:let { tocRuleV = TocRule() }
tocRuleV ?: let { tocRuleV = TocRule() }
}
return tocRuleV!!
}
fun getContentRule(): ContentRule? {
contentRuleV?:let {
contentRuleV ?: let {
contentRuleV = GSON.fromJsonObject<ContentRule>(ruleContent)
contentRuleV?:let { contentRuleV = ContentRule() }
contentRuleV ?: let { contentRuleV = ContentRule() }
}
return contentRuleV!!
}

@ -105,7 +105,7 @@ object Restore {
source.bookSourceName = jsonItem.readString("bookSourceName") ?: ""
source.bookSourceGroup = jsonItem.readString("bookSourceGroup") ?: ""
source.loginUrl = jsonItem.readString("loginUrl")
source.infoUrlPattern = jsonItem.readString("ruleBookUrlPattern")
source.bookUrlPattern = jsonItem.readString("ruleBookUrlPattern")
val searchRule = SearchRule(
searchUrl = jsonItem.readString("ruleSearchUrl"),
bookList = jsonItem.readString("ruleSearchList"),

@ -29,7 +29,7 @@ class BookList {
)
val analyzer = AnalyzeRule(null)
analyzer.setContent(body, baseUrl)
return bookList
}
}

@ -120,7 +120,7 @@ class SourceEditActivity : BaseActivity<SourceEditViewModel>(false), KeyboardToo
sourceEditList.add(EditEntity("bookSourceName", this?.bookSourceName, R.string.book_source_name))
sourceEditList.add(EditEntity("bookSourceGroup", this?.bookSourceGroup, R.string.book_source_group))
sourceEditList.add(EditEntity("loginUrl", this?.loginUrl, R.string.book_source_login_url))
sourceEditList.add(EditEntity("urlPattern", this?.infoUrlPattern, R.string.book_url_pattern))
sourceEditList.add(EditEntity("bookUrlPattern", this?.bookUrlPattern, R.string.book_url_pattern))
sourceEditList.add(EditEntity("header", this?.header, R.string.source_http_header))
}
//搜索
@ -203,7 +203,7 @@ class SourceEditActivity : BaseActivity<SourceEditViewModel>(false), KeyboardToo
"bookSourceName" -> if (value != null) source.bookSourceName = value!! else return null
"bookSourceGroup" -> source.bookSourceGroup = value
"loginUrl" -> source.loginUrl = value
"infoUrlPattern" -> source.infoUrlPattern = value
"bookUrlPattern" -> source.bookUrlPattern = value
"header" -> source.header = value
}
}

@ -358,7 +358,7 @@
<string name="rule_cover_url">封面规则(coverUrl)</string>
<string name="rule_last_chapter">最新章节规则(lastChapter)</string>
<string name="rule_word_count">字数规则(wordCount)</string>
<string name="book_url_pattern">详情URL正则(urlPattern)</string>
<string name="book_url_pattern">书籍URL正则(urlPattern)</string>
<string name="rule_book_info_init">预处理规则(init)</string>
<string name="rule_toc_url">目录URL规则(tocUrl)</string>
<string name="rule_next_toc_url">目录下一页规则(nextTocUrl)</string>

Loading…
Cancel
Save