|
|
@ -9,9 +9,11 @@ import io.legado.app.help.AppConfig |
|
|
|
import io.legado.app.help.CacheManager |
|
|
|
import io.legado.app.help.CacheManager |
|
|
|
import io.legado.app.help.JsExtensions |
|
|
|
import io.legado.app.help.JsExtensions |
|
|
|
import io.legado.app.help.http.CookieStore |
|
|
|
import io.legado.app.help.http.CookieStore |
|
|
|
|
|
|
|
import io.legado.app.utils.ACache |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.fromJsonObject |
|
|
|
import io.legado.app.utils.fromJsonObject |
|
|
|
import kotlinx.parcelize.Parcelize |
|
|
|
import kotlinx.parcelize.Parcelize |
|
|
|
|
|
|
|
import splitties.init.appCtx |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
import javax.script.SimpleBindings |
|
|
|
import javax.script.SimpleBindings |
|
|
|
|
|
|
|
|
|
|
@ -105,9 +107,30 @@ data class RssSource( |
|
|
|
return a == b || (a.isNullOrEmpty() && b.isNullOrEmpty()) |
|
|
|
return a == b || (a.isNullOrEmpty() && b.isNullOrEmpty()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun sortUrls(): LinkedHashMap<String, String> = |
|
|
|
fun sortUrls(): LinkedHashMap<String, String> = linkedMapOf<String, String>().apply { |
|
|
|
linkedMapOf<String, String>().apply { |
|
|
|
kotlin.runCatching { |
|
|
|
sortUrl?.split("(&&|\n)+".toRegex())?.forEach { c -> |
|
|
|
var a = sortUrl |
|
|
|
|
|
|
|
if (sortUrl?.startsWith("<js>", false) == true |
|
|
|
|
|
|
|
|| sortUrl?.startsWith("@js", false) == true |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
val aCache = ACache.get(appCtx, "rssSortUrl") |
|
|
|
|
|
|
|
a = aCache.getAsString(sourceUrl) ?: "" |
|
|
|
|
|
|
|
if (a.isBlank()) { |
|
|
|
|
|
|
|
val bindings = SimpleBindings() |
|
|
|
|
|
|
|
bindings["baseUrl"] = sourceUrl |
|
|
|
|
|
|
|
bindings["java"] = this |
|
|
|
|
|
|
|
bindings["cookie"] = CookieStore |
|
|
|
|
|
|
|
bindings["cache"] = CacheManager |
|
|
|
|
|
|
|
val jsStr = if (sortUrl!!.startsWith("@")) { |
|
|
|
|
|
|
|
sortUrl!!.substring(3) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sortUrl!!.substring(4, sortUrl!!.lastIndexOf("<")) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
a = AppConst.SCRIPT_ENGINE.eval(jsStr, bindings).toString() |
|
|
|
|
|
|
|
aCache.put(sourceUrl, a) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
a?.split("(&&|\n)+".toRegex())?.forEach { c -> |
|
|
|
val d = c.split("::") |
|
|
|
val d = c.split("::") |
|
|
|
if (d.size > 1) |
|
|
|
if (d.size > 1) |
|
|
|
this[d[0]] = d[1] |
|
|
|
this[d[0]] = d[1] |
|
|
@ -116,4 +139,5 @@ data class RssSource( |
|
|
|
this[""] = sourceUrl |
|
|
|
this[""] = sourceUrl |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |