Merge remote-tracking branch 'origin/master'

pull/2514/head
kunfei 3 years ago
commit a168b526b2
  1. 2
      app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt
  2. 4
      app/src/main/java/io/legado/app/data/entities/RssSource.kt
  3. 6
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -17,7 +17,7 @@ interface RssSourceDao {
@Query("select * from rssSources where sourceUrl in (:sourceUrls)") @Query("select * from rssSources where sourceUrl in (:sourceUrls)")
fun getRssSources(vararg sourceUrls: String): List<RssSource> fun getRssSources(vararg sourceUrls: String): List<RssSource>
@get:Query("SELECT * FROM rssSources") @get:Query("SELECT * FROM rssSources order by customOrder")
val all: List<RssSource> val all: List<RssSource>
@get:Query("select count(sourceUrl) from rssSources") @get:Query("select count(sourceUrl) from rssSources")

@ -108,6 +108,7 @@ data class RssSource(
&& equal(ruleContent, source.ruleContent) && equal(ruleContent, source.ruleContent)
&& enableJs == source.enableJs && enableJs == source.enableJs
&& loadWithBaseUrl == source.loadWithBaseUrl && loadWithBaseUrl == source.loadWithBaseUrl
&& equal(variableComment, source.variableComment)
} }
private fun equal(a: String?, b: String?): Boolean { private fun equal(a: String?, b: String?): Boolean {
@ -182,7 +183,8 @@ data class RssSource(
enabledCookieJar = doc.readBool("$.enabledCookieJar") ?: false, enabledCookieJar = doc.readBool("$.enabledCookieJar") ?: false,
customOrder = doc.readInt("$.customOrder") ?: 0, customOrder = doc.readInt("$.customOrder") ?: 0,
lastUpdateTime = doc.readLong("$.lastUpdateTime") ?: 0L, lastUpdateTime = doc.readLong("$.lastUpdateTime") ?: 0L,
coverDecodeJs = doc.readString("$.coverDecodeJs") coverDecodeJs = doc.readString("$.coverDecodeJs"),
variableComment = doc.readString("$.variableComment")
) )
} }
} }

@ -108,6 +108,7 @@ class AnalyzeUrl(
var start = 0 var start = 0
var tmp: String var tmp: String
val jsMatcher = JS_PATTERN.matcher(ruleUrl) val jsMatcher = JS_PATTERN.matcher(ruleUrl)
var hasRule = true
while (jsMatcher.find()) { while (jsMatcher.find()) {
if (jsMatcher.start() > start) { if (jsMatcher.start() > start) {
tmp = tmp =
@ -118,8 +119,11 @@ class AnalyzeUrl(
} }
ruleUrl = evalJS(jsMatcher.group(2) ?: jsMatcher.group(1), ruleUrl) as String ruleUrl = evalJS(jsMatcher.group(2) ?: jsMatcher.group(1), ruleUrl) as String
start = jsMatcher.end() start = jsMatcher.end()
if (jsMatcher.group(0)!!.startsWith("@js:", true)) {
hasRule = false
} }
if (ruleUrl.length > start) { }
if (ruleUrl.length > start && hasRule) {
tmp = ruleUrl.substring(start).trim { it <= ' ' } tmp = ruleUrl.substring(start).trim { it <= ' ' }
if (tmp.isNotEmpty()) { if (tmp.isNotEmpty()) {
ruleUrl = tmp.replace("@result", ruleUrl) ruleUrl = tmp.replace("@result", ruleUrl)

Loading…
Cancel
Save