pull/48/head
kunfei 5 years ago
parent 4122ba9ba4
commit 54168b8aa5
  1. 4
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  2. 12
      app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt

@ -337,10 +337,10 @@ class AnalyzeRule(var book: BaseBook? = null) {
* 分解规则生成规则列表 * 分解规则生成规则列表
*/ */
@Throws(Exception::class) @Throws(Exception::class)
fun splitSourceRule(ruleStr: String, mode: Mode = Mode.Default): List<SourceRule> { fun splitSourceRule(ruleStr: String?, mode: Mode = Mode.Default): List<SourceRule> {
var vRuleStr = ruleStr var vRuleStr = ruleStr
val ruleList = ArrayList<SourceRule>() val ruleList = ArrayList<SourceRule>()
if (TextUtils.isEmpty(vRuleStr)) return ruleList if (vRuleStr.isNullOrEmpty()) return ruleList
//检测Mode //检测Mode
var mMode: Mode = mode var mMode: Mode = mode
when { when {

@ -154,16 +154,24 @@ object BookChapterList {
SourceDebug.printLog(bookSource.bookSourceUrl, "└列表大小:${elements.size}", printLog) SourceDebug.printLog(bookSource.bookSourceUrl, "└列表大小:${elements.size}", printLog)
if (elements.isNotEmpty()) { if (elements.isNotEmpty()) {
SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取首章名称", printLog) SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取首章名称", printLog)
val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName ?: "") val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName)
val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl ?: "") val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl)
val vipRule = analyzeRule.splitSourceRule(tocRule.isVip)
val update = analyzeRule.splitSourceRule(tocRule.updateTime)
var isVip: String?
for (item in elements) { for (item in elements) {
analyzeRule.setContent(item) analyzeRule.setContent(item)
val bookChapter = BookChapter(bookUrl = book.bookUrl) val bookChapter = BookChapter(bookUrl = book.bookUrl)
analyzeRule.chapter = bookChapter analyzeRule.chapter = bookChapter
bookChapter.title = analyzeRule.getString(nameRule) bookChapter.title = analyzeRule.getString(nameRule)
bookChapter.url = analyzeRule.getString(urlRule, true) bookChapter.url = analyzeRule.getString(urlRule, true)
bookChapter.tag = analyzeRule.getString(update)
isVip = analyzeRule.getString(vipRule)
if (bookChapter.url.isEmpty()) bookChapter.url = baseUrl if (bookChapter.url.isEmpty()) bookChapter.url = baseUrl
if (bookChapter.title.isNotEmpty()) { if (bookChapter.title.isNotEmpty()) {
if (isVip.isNotEmpty()) {
bookChapter.title = "\uD83D\uDD12" + bookChapter.title
}
chapterList.add(bookChapter) chapterList.add(bookChapter)
} }
} }

Loading…
Cancel
Save