From 535740dbdfda61106340721944c0a16a3a937261 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 25 Jul 2019 15:59:43 +0800 Subject: [PATCH] up --- .../app/model/analyzeRule/AnalyzeRule.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 644c11c3f..008ddef45 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -123,11 +123,10 @@ class AnalyzeRule(private var book: BaseBook? = null) { if (rule.rule.isNotEmpty()) { when (rule.mode) { Mode.Js -> result = evalJS(rule.rule, result) - Mode.JSon -> result = - getAnalyzeByJSonPath(it).getStringList(rule.rule) - Mode.XPath -> result = - getAnalyzeByXPath(it).getStringList(rule.rule) - else -> result = getAnalyzeByJSoup(it).getStringList(rule.rule) + Mode.JSon -> result = getAnalyzeByJSonPath(it).getStringList(rule.rule) + Mode.XPath -> result = getAnalyzeByXPath(it).getStringList(rule.rule) + Mode.Css -> result = getAnalyzeByJSoup(it).getStringList(rule.rule) + else -> result = rule.rule } } if (rule.replaceRegex.isNotEmpty() && result is List<*>) { @@ -192,11 +191,12 @@ class AnalyzeRule(private var book: BaseBook? = null) { Mode.Js -> result = evalJS(rule.rule, it) Mode.JSon -> result = getAnalyzeByJSonPath(it).getString(rule.rule) Mode.XPath -> result = getAnalyzeByXPath(it).getString(rule.rule) - Mode.Default -> result = if (isUrl && !TextUtils.isEmpty(baseUrl)) { + Mode.Css -> result = if (isUrl && !TextUtils.isEmpty(baseUrl)) { getAnalyzeByJSoup(it).getString0(rule.rule) } else { getAnalyzeByJSoup(it).getString(rule.rule) } + else -> result = rule.rule } } if (rule.replaceRegex.isNotEmpty()) { @@ -230,7 +230,8 @@ class AnalyzeRule(private var book: BaseBook? = null) { Mode.Js -> result = evalJS(rule.rule, it) Mode.JSon -> result = getAnalyzeByJSonPath(it).getObject(rule.rule) Mode.XPath -> result = getAnalyzeByXPath(it).getElements(rule.rule) - else -> result = getAnalyzeByJSoup(it).getElements(rule.rule) + Mode.Css -> result = getAnalyzeByJSoup(it).getElements(rule.rule) + else -> result = rule.rule } if (rule.replaceRegex.isNotEmpty()) { result = replaceRegex(result.toString(), rule) @@ -260,7 +261,8 @@ class AnalyzeRule(private var book: BaseBook? = null) { } Mode.JSon -> result = getAnalyzeByJSonPath(it).getList(rule.rule) Mode.XPath -> result = getAnalyzeByXPath(it).getElements(rule.rule) - else -> result = getAnalyzeByJSoup(it).getElements(rule.rule) + Mode.Css -> result = getAnalyzeByJSoup(it).getElements(rule.rule) + else -> result = rule.rule } if (rule.replaceRegex.isNotEmpty()) { result = replaceRegex(result.toString(), rule) @@ -477,7 +479,7 @@ class AnalyzeRule(private var book: BaseBook? = null) { } enum class Mode { - XPath, JSon, Default, Js + XPath, JSon, Default, Js, Regex, Css } fun put(key: String, value: String): String {