pull/32/head
kunfei 5 years ago
parent c615aef925
commit 6a01dba503
  1. 50
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -317,14 +317,16 @@ class AnalyzeRule(private var book: BaseBook? = null) {
if (TextUtils.isEmpty(vRuleStr)) return ruleList if (TextUtils.isEmpty(vRuleStr)) return ruleList
//检测Mode //检测Mode
val mode: Mode val mode: Mode
if (vRuleStr.startsWith("@XPath:", true)) { when {
mode = Mode.XPath vRuleStr.startsWith("@XPath:", true) -> {
vRuleStr = vRuleStr.substring(7) mode = Mode.XPath
} else if (vRuleStr.startsWith("@JSon:", true)) { vRuleStr = vRuleStr.substring(7)
mode = Mode.JSon }
vRuleStr = vRuleStr.substring(6) vRuleStr.startsWith("@JSon:", true) -> {
} else { mode = Mode.JSon
mode = if (isJSON!!) { vRuleStr = vRuleStr.substring(6)
}
else -> mode = if (isJSON!!) {
Mode.JSon Mode.JSon
} else { } else {
Mode.Default Mode.Default
@ -375,20 +377,24 @@ class AnalyzeRule(private var book: BaseBook? = null) {
rule = ruleStr.substring(4) rule = ruleStr.substring(4)
} }
} else { } else {
if (ruleStr.startsWith("@XPath:", true)) { when {
mode = Mode.XPath ruleStr.startsWith("@XPath:", true) -> {
rule = ruleStr.substring(7) mode = Mode.XPath
} else if (ruleStr.startsWith("//")) {//XPath特征很明显,无需配置单独的识别标头 rule = ruleStr.substring(7)
mode = Mode.XPath }
rule = ruleStr ruleStr.startsWith("//") -> {//XPath特征很明显,无需配置单独的识别标头
} else if (ruleStr.startsWith("@JSon:", true)) { mode = Mode.XPath
mode = Mode.JSon rule = ruleStr
rule = ruleStr.substring(6) }
} else if (ruleStr.startsWith("$.")) { ruleStr.startsWith("@JSon:", true) -> {
mode = Mode.JSon mode = Mode.JSon
rule = ruleStr rule = ruleStr.substring(6)
} else { }
rule = ruleStr ruleStr.startsWith("$.") -> {
mode = Mode.JSon
rule = ruleStr
}
else -> rule = ruleStr
} }
} }
} }

Loading…
Cancel
Save