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