优化
This commit is contained in:
@@ -43,22 +43,25 @@ class RssViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
|
|
||||||
fun getSingleUrl(rssSource: RssSource, onSuccess: (url: String) -> Unit) {
|
fun getSingleUrl(rssSource: RssSource, onSuccess: (url: String) -> Unit) {
|
||||||
execute {
|
execute {
|
||||||
val url = rssSource.sortUrl
|
var sortUrl = rssSource.sortUrl
|
||||||
if (!url.isNullOrBlank()) {
|
if (!sortUrl.isNullOrBlank()) {
|
||||||
if (url.startsWith("<js>", false)
|
if (sortUrl.startsWith("<js>", false)
|
||||||
|| url.startsWith("@js:", false)
|
|| sortUrl.startsWith("@js:", false)
|
||||||
) {
|
) {
|
||||||
val jsStr = if (url.startsWith("@")) {
|
val jsStr = if (sortUrl.startsWith("@")) {
|
||||||
url.substring(4)
|
sortUrl.substring(4)
|
||||||
} else {
|
} else {
|
||||||
url.substring(4, url.lastIndexOf("<"))
|
sortUrl.substring(4, sortUrl.lastIndexOf("<"))
|
||||||
}
|
}
|
||||||
val result = rssSource.evalJS(jsStr)?.toString()
|
val result = rssSource.evalJS(jsStr)?.toString()
|
||||||
if (!result.isNullOrBlank()) {
|
if (!result.isNullOrBlank()) {
|
||||||
return@execute result
|
sortUrl = result
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (sortUrl.contains("::")) {
|
||||||
|
return@execute sortUrl.split("::")[1]
|
||||||
} else {
|
} else {
|
||||||
return@execute url
|
return@execute sortUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rssSource.sourceUrl
|
rssSource.sourceUrl
|
||||||
|
|||||||
Reference in New Issue
Block a user