|
|
@@ -10,6 +10,7 @@ import io.legado.app.data.entities.BaseSource
|
|
|
import io.legado.app.data.entities.Book
|
|
|
import io.legado.app.data.entities.BookChapter
|
|
|
import io.legado.app.data.entities.BookSource
|
|
|
+import io.legado.app.data.entities.RssArticle
|
|
|
import io.legado.app.help.CacheManager
|
|
|
import io.legado.app.help.JsExtensions
|
|
|
import io.legado.app.help.http.CookieStore
|
|
|
@@ -27,6 +28,7 @@ import org.apache.commons.text.StringEscapeUtils
|
|
|
import org.jsoup.nodes.Node
|
|
|
import org.mozilla.javascript.NativeObject
|
|
|
import java.net.URL
|
|
|
+import java.util.Locale
|
|
|
import java.util.regex.Pattern
|
|
|
import kotlin.collections.component1
|
|
|
import kotlin.collections.component2
|
|
|
@@ -45,6 +47,7 @@ class AnalyzeRule(
|
|
|
) : JsExtensions {
|
|
|
|
|
|
val book get() = ruleData as? BaseBook
|
|
|
+ val rssArticle get() = ruleData as? RssArticle
|
|
|
|
|
|
var chapter: BookChapter? = null
|
|
|
var nextChapterUrl: String? = null
|
|
|
@@ -199,7 +202,7 @@ class AnalyzeRule(
|
|
|
}
|
|
|
if (sourceRule.replaceRegex.isNotEmpty() && result is List<*>) {
|
|
|
val newList = ArrayList<String>()
|
|
|
- for (item in result) {
|
|
|
+ for (item in result as List<*>) {
|
|
|
newList.add(replaceRegex(item.toString(), sourceRule))
|
|
|
}
|
|
|
result = newList
|
|
|
@@ -212,12 +215,12 @@ class AnalyzeRule(
|
|
|
}
|
|
|
if (result == null) return null
|
|
|
if (result is String) {
|
|
|
- result = result.split("\n")
|
|
|
+ result = (result as String).split("\n")
|
|
|
}
|
|
|
if (isUrl) {
|
|
|
val urlList = ArrayList<String>()
|
|
|
if (result is List<*>) {
|
|
|
- for (url in result) {
|
|
|
+ for (url in result as List<*>) {
|
|
|
val absoluteURL = NetworkUtils.getAbsoluteURL(redirectUrl, url.toString())
|
|
|
if (absoluteURL.isNotEmpty() && !urlList.contains(absoluteURL)) {
|
|
|
urlList.add(absoluteURL)
|
|
|
@@ -650,7 +653,7 @@ class AnalyzeRule(
|
|
|
jsEval is String -> infoVal.insert(0, jsEval)
|
|
|
jsEval is Double && jsEval % 1.0 == 0.0 -> infoVal.insert(
|
|
|
0,
|
|
|
- String.format("%.0f", jsEval)
|
|
|
+ String.format(Locale.getDefault(), "%.0f", jsEval)
|
|
|
)
|
|
|
|
|
|
else -> infoVal.insert(0, jsEval.toString())
|
|
|
@@ -744,6 +747,7 @@ class AnalyzeRule(
|
|
|
bindings["title"] = chapter?.title
|
|
|
bindings["src"] = content
|
|
|
bindings["nextChapterUrl"] = nextChapterUrl
|
|
|
+ bindings["rssArticle"] = rssArticle
|
|
|
}
|
|
|
val scope = RhinoScriptEngine.getRuntimeScope(bindings)
|
|
|
source?.getShareScope()?.let {
|