|
|
|
@ -12,27 +12,27 @@ private fun RssSource.getSortUrlsKey(): String { |
|
|
|
|
return MD5Utils.md5Encode(sourceUrl + sortUrl) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
suspend fun RssSource.sortUrls(): List<Pair<String, String>> = |
|
|
|
|
arrayListOf<Pair<String, String>>().apply { |
|
|
|
|
suspend fun RssSource.sortUrls(): List<Pair<String, String>> { |
|
|
|
|
return arrayListOf<Pair<String, String>>().apply { |
|
|
|
|
val sortUrlsKey = getSortUrlsKey() |
|
|
|
|
withContext(Dispatchers.IO) { |
|
|
|
|
kotlin.runCatching { |
|
|
|
|
var a = sortUrl |
|
|
|
|
var str = sortUrl |
|
|
|
|
if (sortUrl?.startsWith("<js>", false) == true |
|
|
|
|
|| sortUrl?.startsWith("@js:", false) == true |
|
|
|
|
) { |
|
|
|
|
a = aCache.getAsString(sortUrlsKey) ?: "" |
|
|
|
|
if (a.isBlank()) { |
|
|
|
|
str = aCache.getAsString(sortUrlsKey) |
|
|
|
|
if (str.isNullOrBlank()) { |
|
|
|
|
val jsStr = if (sortUrl!!.startsWith("@")) { |
|
|
|
|
sortUrl!!.substring(4) |
|
|
|
|
} else { |
|
|
|
|
sortUrl!!.substring(4, sortUrl!!.lastIndexOf("<")) |
|
|
|
|
} |
|
|
|
|
a = evalJS(jsStr).toString() |
|
|
|
|
aCache.put(sortUrlsKey, a) |
|
|
|
|
str = evalJS(jsStr).toString() |
|
|
|
|
aCache.put(sortUrlsKey, str) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
a?.split("(&&|\n)+".toRegex())?.forEach { c -> |
|
|
|
|
str?.split("(&&|\n)+".toRegex())?.forEach { c -> |
|
|
|
|
val d = c.split("::") |
|
|
|
|
if (d.size > 1) |
|
|
|
|
add(Pair(d[0], d[1])) |
|
|
|
@ -43,6 +43,7 @@ suspend fun RssSource.sortUrls(): List<Pair<String, String>> = |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
suspend fun RssSource.removeSortCache() { |
|
|
|
|
withContext(Dispatchers.IO) { |
|
|
|
|