|
|
|
@ -9,6 +9,8 @@ import androidx.room.PrimaryKey |
|
|
|
|
import com.jayway.jsonpath.DocumentContext |
|
|
|
|
import io.legado.app.constant.AppPattern |
|
|
|
|
import io.legado.app.utils.* |
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
import kotlinx.parcelize.Parcelize |
|
|
|
|
|
|
|
|
|
@Parcelize |
|
|
|
@ -133,32 +135,41 @@ data class RssSource( |
|
|
|
|
return this |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun sortUrls(): List<Pair<String, String>> = arrayListOf<Pair<String, String>>().apply { |
|
|
|
|
kotlin.runCatching { |
|
|
|
|
var a = sortUrl |
|
|
|
|
if (sortUrl?.startsWith("<js>", false) == true |
|
|
|
|
|| sortUrl?.startsWith("@js:", false) == true |
|
|
|
|
) { |
|
|
|
|
val aCache = ACache.get("rssSortUrl") |
|
|
|
|
a = aCache.getAsString(sourceUrl) ?: "" |
|
|
|
|
if (a.isBlank()) { |
|
|
|
|
val jsStr = if (sortUrl!!.startsWith("@")) { |
|
|
|
|
sortUrl!!.substring(4) |
|
|
|
|
} else { |
|
|
|
|
sortUrl!!.substring(4, sortUrl!!.lastIndexOf("<")) |
|
|
|
|
suspend fun sortUrls(): List<Pair<String, String>> = arrayListOf<Pair<String, String>>().apply { |
|
|
|
|
withContext(IO) { |
|
|
|
|
kotlin.runCatching { |
|
|
|
|
var a = sortUrl |
|
|
|
|
if (sortUrl?.startsWith("<js>", false) == true |
|
|
|
|
|| sortUrl?.startsWith("@js:", false) == true |
|
|
|
|
) { |
|
|
|
|
val aCache = ACache.get("rssSortUrl") |
|
|
|
|
a = aCache.getAsString(sourceUrl) ?: "" |
|
|
|
|
if (a.isBlank()) { |
|
|
|
|
val jsStr = if (sortUrl!!.startsWith("@")) { |
|
|
|
|
sortUrl!!.substring(4) |
|
|
|
|
} else { |
|
|
|
|
sortUrl!!.substring(4, sortUrl!!.lastIndexOf("<")) |
|
|
|
|
} |
|
|
|
|
a = evalJS(jsStr).toString() |
|
|
|
|
aCache.put(sourceUrl, a) |
|
|
|
|
} |
|
|
|
|
a = evalJS(jsStr).toString() |
|
|
|
|
aCache.put(sourceUrl, a) |
|
|
|
|
} |
|
|
|
|
a?.split("(&&|\n)+".toRegex())?.forEach { c -> |
|
|
|
|
val d = c.split("::") |
|
|
|
|
if (d.size > 1) |
|
|
|
|
add(Pair(d[0], d[1])) |
|
|
|
|
} |
|
|
|
|
if (isEmpty()) { |
|
|
|
|
add(Pair("", sourceUrl)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
a?.split("(&&|\n)+".toRegex())?.forEach { c -> |
|
|
|
|
val d = c.split("::") |
|
|
|
|
if (d.size > 1) |
|
|
|
|
add(Pair(d[0], d[1])) |
|
|
|
|
} |
|
|
|
|
if (isEmpty()) { |
|
|
|
|
add(Pair("", sourceUrl)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
suspend fun removeSortCache() { |
|
|
|
|
withContext(IO) { |
|
|
|
|
val aCache = ACache.get("rssSortUrl") |
|
|
|
|
aCache.remove(sourceUrl) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|