Merge remote-tracking branch 'origin/master'

pull/32/head
Administrator 5 years ago
commit 2ca0df20cb
  1. 8
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt
  2. 14
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt
  3. 8
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt

@ -62,17 +62,17 @@ class AnalyzeByJSonPath {
return result return result
} }
} else { } else {
val sb = StringBuilder() val textList = arrayListOf<String>()
for (rl in rules) { for (rl in rules) {
val temp = getString(rl) val temp = getString(rl)
if (!TextUtils.isEmpty(temp)) { if (!temp.isNullOrEmpty()) {
sb.append(temp) textList.add(temp)
if (elementsType == "|") { if (elementsType == "|") {
break break
} }
} }
} }
return sb.toString() return TextUtils.join(",", textList)
} }
} }

@ -51,7 +51,7 @@ class AnalyzeByJSoup {
val textS = getStringList(ruleStr) val textS = getStringList(ruleStr)
return if (textS.isEmpty()) { return if (textS.isEmpty()) {
null null
} else join("\n", textS).trim { it <= ' ' } } else join(",", textS).trim { it <= ' ' }
} }
/** /**
@ -75,7 +75,7 @@ class AnalyzeByJSoup {
//拆分规则 //拆分规则
val sourceRule = SourceRule(ruleStr) val sourceRule = SourceRule(ruleStr)
if (isEmpty(sourceRule.elementsRule)) { if (isEmpty(sourceRule.elementsRule)) {
textS.add(element!!.data()) textS.add(element?.data() ?: "")
} else { } else {
val elementsType: String val elementsType: String
val ruleStrS: Array<String> val ruleStrS: Array<String>
@ -105,7 +105,7 @@ class AnalyzeByJSoup {
} else { } else {
getResultList(ruleStrX) getResultList(ruleStrX)
} }
if (temp != null && temp.isNotEmpty()) { if (!temp.isNullOrEmpty()) {
results.add(temp) results.add(temp)
if (results.isNotEmpty() && elementsType == "|") { if (results.isNotEmpty() && elementsType == "|") {
break break
@ -360,13 +360,15 @@ class AnalyzeByJSoup {
textS.add(text) textS.add(text)
} }
"textNodes" -> for (element in elements) { "textNodes" -> for (element in elements) {
val tn = arrayListOf<String>()
val contentEs = element.textNodes() val contentEs = element.textNodes()
for (i in contentEs.indices) { for (item in contentEs) {
val temp = contentEs[i].text().trim { it <= ' ' } val temp = item.text().trim { it <= ' ' }
if (!isEmpty(temp)) { if (!isEmpty(temp)) {
textS.add(temp) tn.add(temp)
} }
} }
textS.add(join("\n", tn))
} }
"ownText", "html" -> { "ownText", "html" -> {
elements.select("script").remove() elements.select("script").remove()

@ -154,17 +154,17 @@ class AnalyzeByXPath {
} }
return null return null
} else { } else {
val sb = StringBuilder() val textList = arrayListOf<String>()
for (rl in rules) { for (rl in rules) {
val temp = getString(rl) val temp = getString(rl)
if (!TextUtils.isEmpty(temp)) { if (!temp.isNullOrEmpty()) {
sb.append(temp) textList.add(temp)
if (elementsType == "|") { if (elementsType == "|") {
break break
} }
} }
} }
return sb.toString() return TextUtils.join(",", textList)
} }
} }
} }

Loading…
Cancel
Save