|
|
@ -46,13 +46,14 @@ data class BookSource( |
|
|
|
var ruleBookInfo: BookInfoRule? = null, // 书籍信息页规则 |
|
|
|
var ruleBookInfo: BookInfoRule? = null, // 书籍信息页规则 |
|
|
|
var ruleToc: TocRule? = null, // 目录页规则 |
|
|
|
var ruleToc: TocRule? = null, // 目录页规则 |
|
|
|
var ruleContent: ContentRule? = null // 正文页规则 |
|
|
|
var ruleContent: ContentRule? = null // 正文页规则 |
|
|
|
): Parcelable, JsExtensions { |
|
|
|
) : Parcelable, JsExtensions { |
|
|
|
|
|
|
|
|
|
|
|
override fun hashCode(): Int { |
|
|
|
override fun hashCode(): Int { |
|
|
|
return bookSourceUrl.hashCode() |
|
|
|
return bookSourceUrl.hashCode() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun equals(other: Any?) = if (other is BookSource) other.bookSourceUrl == bookSourceUrl else false |
|
|
|
override fun equals(other: Any?) = |
|
|
|
|
|
|
|
if (other is BookSource) other.bookSourceUrl == bookSourceUrl else false |
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
@Throws(Exception::class) |
|
|
|
fun getHeaderMap() = (HashMap<String, String>().apply { |
|
|
|
fun getHeaderMap() = (HashMap<String, String>().apply { |
|
|
@ -100,11 +101,11 @@ data class BookSource( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun getExploreKinds() = arrayListOf<ExploreKind>().apply { |
|
|
|
fun getExploreKinds() = arrayListOf<ExploreKind>().apply { |
|
|
|
exploreUrl?.let { |
|
|
|
exploreUrl?.let { urlRule -> |
|
|
|
var a = it |
|
|
|
var a = urlRule |
|
|
|
if (a.isNotBlank()) { |
|
|
|
if (a.isNotBlank()) { |
|
|
|
try { |
|
|
|
kotlin.runCatching { |
|
|
|
if (it.startsWith("<js>", false)) { |
|
|
|
if (urlRule.startsWith("<js>", false)) { |
|
|
|
val aCache = ACache.get(App.INSTANCE, "explore") |
|
|
|
val aCache = ACache.get(App.INSTANCE, "explore") |
|
|
|
a = aCache.getAsString(bookSourceUrl) ?: "" |
|
|
|
a = aCache.getAsString(bookSourceUrl) ?: "" |
|
|
|
if (a.isBlank()) { |
|
|
|
if (a.isBlank()) { |
|
|
@ -114,7 +115,7 @@ data class BookSource( |
|
|
|
bindings["cookie"] = CookieStore |
|
|
|
bindings["cookie"] = CookieStore |
|
|
|
bindings["cache"] = CacheManager |
|
|
|
bindings["cache"] = CacheManager |
|
|
|
a = AppConst.SCRIPT_ENGINE.eval( |
|
|
|
a = AppConst.SCRIPT_ENGINE.eval( |
|
|
|
it.substring(4, it.lastIndexOf("<")), |
|
|
|
urlRule.substring(4, urlRule.lastIndexOf("<")), |
|
|
|
bindings |
|
|
|
bindings |
|
|
|
).toString() |
|
|
|
).toString() |
|
|
|
aCache.put(bookSourceUrl, a) |
|
|
|
aCache.put(bookSourceUrl, a) |
|
|
@ -126,8 +127,8 @@ data class BookSource( |
|
|
|
if (d.size > 1) |
|
|
|
if (d.size > 1) |
|
|
|
add(ExploreKind(d[0], d[1])) |
|
|
|
add(ExploreKind(d[0], d[1])) |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e: Exception) { |
|
|
|
}.onFailure { |
|
|
|
add(ExploreKind(e.localizedMessage ?: "")) |
|
|
|
add(ExploreKind(it.localizedMessage ?: "")) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -147,22 +148,22 @@ data class BookSource( |
|
|
|
|
|
|
|
|
|
|
|
fun equal(source: BookSource) = |
|
|
|
fun equal(source: BookSource) = |
|
|
|
equal(bookSourceName, source.bookSourceName) |
|
|
|
equal(bookSourceName, source.bookSourceName) |
|
|
|
&& equal(bookSourceUrl, source.bookSourceUrl) |
|
|
|
&& equal(bookSourceUrl, source.bookSourceUrl) |
|
|
|
&& equal(bookSourceGroup, source.bookSourceGroup) |
|
|
|
&& equal(bookSourceGroup, source.bookSourceGroup) |
|
|
|
&& bookSourceType == source.bookSourceType |
|
|
|
&& bookSourceType == source.bookSourceType |
|
|
|
&& equal(bookUrlPattern, source.bookUrlPattern) |
|
|
|
&& equal(bookUrlPattern, source.bookUrlPattern) |
|
|
|
&& equal(bookSourceComment, source.bookSourceComment) |
|
|
|
&& equal(bookSourceComment, source.bookSourceComment) |
|
|
|
&& enabled == source.enabled |
|
|
|
&& enabled == source.enabled |
|
|
|
&& enabledExplore == source.enabledExplore |
|
|
|
&& enabledExplore == source.enabledExplore |
|
|
|
&& equal(header, source.header) |
|
|
|
&& equal(header, source.header) |
|
|
|
&& equal(loginUrl, source.loginUrl) |
|
|
|
&& equal(loginUrl, source.loginUrl) |
|
|
|
&& equal(exploreUrl, source.exploreUrl) |
|
|
|
&& equal(exploreUrl, source.exploreUrl) |
|
|
|
&& equal(searchUrl, source.searchUrl) |
|
|
|
&& equal(searchUrl, source.searchUrl) |
|
|
|
&& getSearchRule() == source.getSearchRule() |
|
|
|
&& getSearchRule() == source.getSearchRule() |
|
|
|
&& getExploreRule() == source.getExploreRule() |
|
|
|
&& getExploreRule() == source.getExploreRule() |
|
|
|
&& getBookInfoRule() == source.getBookInfoRule() |
|
|
|
&& getBookInfoRule() == source.getBookInfoRule() |
|
|
|
&& getTocRule() == source.getTocRule() |
|
|
|
&& getTocRule() == source.getTocRule() |
|
|
|
&& getContentRule() == source.getContentRule() |
|
|
|
&& getContentRule() == source.getContentRule() |
|
|
|
|
|
|
|
|
|
|
|
private fun equal(a: String?, b: String?) = a == b || (a.isNullOrEmpty() && b.isNullOrEmpty()) |
|
|
|
private fun equal(a: String?, b: String?) = a == b || (a.isNullOrEmpty() && b.isNullOrEmpty()) |
|
|
|
|
|
|
|
|
|
|
|