mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
优化
This commit is contained in:
parent
f98086f3ce
commit
c87bff2f4d
@ -43,22 +43,25 @@ class RssViewModel(application: Application) : BaseViewModel(application) {
|
||||
|
||||
fun getSingleUrl(rssSource: RssSource, onSuccess: (url: String) -> Unit) {
|
||||
execute {
|
||||
val url = rssSource.sortUrl
|
||||
if (!url.isNullOrBlank()) {
|
||||
if (url.startsWith("<js>", false)
|
||||
|| url.startsWith("@js:", false)
|
||||
var sortUrl = rssSource.sortUrl
|
||||
if (!sortUrl.isNullOrBlank()) {
|
||||
if (sortUrl.startsWith("<js>", false)
|
||||
|| sortUrl.startsWith("@js:", false)
|
||||
) {
|
||||
val jsStr = if (url.startsWith("@")) {
|
||||
url.substring(4)
|
||||
val jsStr = if (sortUrl.startsWith("@")) {
|
||||
sortUrl.substring(4)
|
||||
} else {
|
||||
url.substring(4, url.lastIndexOf("<"))
|
||||
sortUrl.substring(4, sortUrl.lastIndexOf("<"))
|
||||
}
|
||||
val result = rssSource.evalJS(jsStr)?.toString()
|
||||
if (!result.isNullOrBlank()) {
|
||||
return@execute result
|
||||
sortUrl = result
|
||||
}
|
||||
}
|
||||
if (sortUrl.contains("::")) {
|
||||
return@execute sortUrl.split("::")[1]
|
||||
} else {
|
||||
return@execute url
|
||||
return@execute sortUrl
|
||||
}
|
||||
}
|
||||
rssSource.sourceUrl
|
||||
|
Loading…
Reference in New Issue
Block a user