|
|
|
@ -39,14 +39,19 @@ data class RssSource( |
|
|
|
|
var header: String? = null, |
|
|
|
|
var enableJs: Boolean = false, |
|
|
|
|
var loadWithBaseUrl: Boolean = false, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var customOrder: Int = 0 |
|
|
|
|
): Parcelable, JsExtensions { |
|
|
|
|
|
|
|
|
|
override fun equals(other: Any?) = if (other is RssSource) other.sourceUrl == sourceUrl else false |
|
|
|
|
|
|
|
|
|
) : Parcelable, JsExtensions { |
|
|
|
|
|
|
|
|
|
override fun equals(other: Any?): Boolean { |
|
|
|
|
if (other is RssSource) { |
|
|
|
|
return other.sourceUrl == sourceUrl |
|
|
|
|
} |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun hashCode() = sourceUrl.hashCode() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
|
fun getHeaderMap() = HashMap<String, String>().apply { |
|
|
|
|
this[AppConst.UA_NAME] = App.INSTANCE.getPrefString("user_agent") ?: AppConst.userAgent |
|
|
|
@ -64,33 +69,37 @@ data class RssSource( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 执行JS |
|
|
|
|
*/ |
|
|
|
|
@Throws(Exception::class) |
|
|
|
|
private fun evalJS(jsStr: String): Any = AppConst.SCRIPT_ENGINE.eval(jsStr, SimpleBindings().apply { this["java"] = this@RssSource }) |
|
|
|
|
|
|
|
|
|
private fun evalJS(jsStr: String): Any? { |
|
|
|
|
val bindings = SimpleBindings() |
|
|
|
|
bindings["java"] = this |
|
|
|
|
return AppConst.SCRIPT_ENGINE.eval(jsStr, bindings) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun equal(source: RssSource): Boolean { |
|
|
|
|
return equal(sourceUrl, source.sourceUrl) |
|
|
|
|
&& equal(sourceIcon, source.sourceIcon) |
|
|
|
|
&& enabled == source.enabled |
|
|
|
|
&& equal(sourceGroup, source.sourceGroup) |
|
|
|
|
&& equal(ruleArticles, source.ruleArticles) |
|
|
|
|
&& equal(ruleNextPage, source.ruleNextPage) |
|
|
|
|
&& equal(ruleTitle, source.ruleTitle) |
|
|
|
|
&& equal(rulePubDate, source.rulePubDate) |
|
|
|
|
&& equal(ruleDescription, source.ruleDescription) |
|
|
|
|
&& equal(ruleLink, source.ruleLink) |
|
|
|
|
&& equal(ruleContent, source.ruleContent) |
|
|
|
|
&& enableJs == source.enableJs |
|
|
|
|
&& loadWithBaseUrl == source.loadWithBaseUrl |
|
|
|
|
&& equal(sourceIcon, source.sourceIcon) |
|
|
|
|
&& enabled == source.enabled |
|
|
|
|
&& equal(sourceGroup, source.sourceGroup) |
|
|
|
|
&& equal(ruleArticles, source.ruleArticles) |
|
|
|
|
&& equal(ruleNextPage, source.ruleNextPage) |
|
|
|
|
&& equal(ruleTitle, source.ruleTitle) |
|
|
|
|
&& equal(rulePubDate, source.rulePubDate) |
|
|
|
|
&& equal(ruleDescription, source.ruleDescription) |
|
|
|
|
&& equal(ruleLink, source.ruleLink) |
|
|
|
|
&& equal(ruleContent, source.ruleContent) |
|
|
|
|
&& enableJs == source.enableJs |
|
|
|
|
&& loadWithBaseUrl == source.loadWithBaseUrl |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun equal(a: String?, b: String?): Boolean { |
|
|
|
|
return a == b || (a.isNullOrEmpty() && b.isNullOrEmpty()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun sortUrls(): LinkedHashMap<String, String> = |
|
|
|
|
linkedMapOf<String, String>().apply { |
|
|
|
|
sortUrl?.split("(&&|\n)+".toRegex())?.forEach { c -> |
|
|
|
|