优化
This commit is contained in:
@@ -20,8 +20,7 @@
|
|||||||
|变量名|调用类|
|
|变量名|调用类|
|
||||||
|------|-----|
|
|------|-----|
|
||||||
|java|当前类|
|
|java|当前类|
|
||||||
|baseUrl|String,当前 url,如 `https://example.com/page/1`|
|
|baseUrl|当前url,String |
|
||||||
|baseUrlWithOptions|String,带参数的当前 url,如 `https://example.com/page/1,{"webView": true}`|
|
|
||||||
|result|上一步的结果|
|
|result|上一步的结果|
|
||||||
|book|[书籍类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/data/entities/Book.kt)|
|
|book|[书籍类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/data/entities/Book.kt)|
|
||||||
|chapter|[章节类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/data/entities/BookChapter.kt)|
|
|chapter|[章节类](https://github.com/gedoor/legado/blob/master/app/src/main/java/io/legado/app/data/entities/BookChapter.kt)|
|
||||||
|
|||||||
@@ -226,11 +226,15 @@ interface JsExtensions : JsEncodeUtils {
|
|||||||
/**
|
/**
|
||||||
* 使用内置浏览器打开链接,并等待网页结果
|
* 使用内置浏览器打开链接,并等待网页结果
|
||||||
*/
|
*/
|
||||||
fun startBrowserAwait(url: String, title: String, refetchAfterSuccess: Boolean = true): StrResponse {
|
fun startBrowserAwait(url: String, title: String, refetchAfterSuccess: Boolean): StrResponse {
|
||||||
return StrResponse(
|
val body = SourceVerificationHelp.getVerificationResult(
|
||||||
url,
|
getSource(), url, title, true, refetchAfterSuccess
|
||||||
SourceVerificationHelp.getVerificationResult(getSource(), url, title, true, refetchAfterSuccess)
|
|
||||||
)
|
)
|
||||||
|
return StrResponse(url, body)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun startBrowserAwait(url: String, title: String): StrResponse {
|
||||||
|
return startBrowserAwait(url, title, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ class AnalyzeRule(
|
|||||||
private set
|
private set
|
||||||
var baseUrl: String? = null
|
var baseUrl: String? = null
|
||||||
private set
|
private set
|
||||||
var optionStr: String = "{}"
|
|
||||||
private set
|
|
||||||
var redirectUrl: URL? = null
|
var redirectUrl: URL? = null
|
||||||
private set
|
private set
|
||||||
private var isJSON: Boolean = false
|
private var isJSON: Boolean = false
|
||||||
@@ -96,11 +94,6 @@ class AnalyzeRule(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setOption(option: String): AnalyzeRule {
|
|
||||||
optionStr = option
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setRedirectUrl(url: String): URL? {
|
fun setRedirectUrl(url: String): URL? {
|
||||||
try {
|
try {
|
||||||
redirectUrl = URL(url)
|
redirectUrl = URL(url)
|
||||||
@@ -754,7 +747,6 @@ class AnalyzeRule(
|
|||||||
bindings["book"] = book
|
bindings["book"] = book
|
||||||
bindings["result"] = result
|
bindings["result"] = result
|
||||||
bindings["baseUrl"] = baseUrl
|
bindings["baseUrl"] = baseUrl
|
||||||
bindings["baseUrlWithOptions"] = "$baseUrl,$optionStr"
|
|
||||||
bindings["chapter"] = chapter
|
bindings["chapter"] = chapter
|
||||||
bindings["title"] = chapter?.title
|
bindings["title"] = chapter?.title
|
||||||
bindings["src"] = content
|
bindings["src"] = content
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ class AnalyzeUrl(
|
|||||||
var type: String? = null
|
var type: String? = null
|
||||||
private set
|
private set
|
||||||
val headerMap = HashMap<String, String>()
|
val headerMap = HashMap<String, String>()
|
||||||
var optionStr: String = ""
|
|
||||||
private var urlNoQuery: String = ""
|
private var urlNoQuery: String = ""
|
||||||
private var queryStr: String? = null
|
private var queryStr: String? = null
|
||||||
private val fieldMap = LinkedHashMap<String, String>()
|
private val fieldMap = LinkedHashMap<String, String>()
|
||||||
@@ -194,10 +193,8 @@ class AnalyzeUrl(
|
|||||||
baseUrl = it
|
baseUrl = it
|
||||||
}
|
}
|
||||||
if (urlNoOption.length != ruleUrl.length) {
|
if (urlNoOption.length != ruleUrl.length) {
|
||||||
val optionStr = ruleUrl.substring(urlMatcher.end())
|
GSON.fromJsonObject<UrlOption>(ruleUrl.substring(urlMatcher.end())).getOrNull()
|
||||||
GSON.fromJsonObject<UrlOption>(optionStr).getOrNull()
|
|
||||||
?.let { option ->
|
?.let { option ->
|
||||||
this.optionStr = optionStr
|
|
||||||
option.getMethod()?.let {
|
option.getMethod()?.let {
|
||||||
if (it.equals("POST", true)) method = RequestMethod.POST
|
if (it.equals("POST", true)) method = RequestMethod.POST
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ object BookList {
|
|||||||
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${analyzeUrl.ruleUrl}")
|
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${analyzeUrl.ruleUrl}")
|
||||||
Debug.log(bookSource.bookSourceUrl, body, state = 10)
|
Debug.log(bookSource.bookSourceUrl, body, state = 10)
|
||||||
val analyzeRule = AnalyzeRule(ruleData, bookSource)
|
val analyzeRule = AnalyzeRule(ruleData, bookSource)
|
||||||
analyzeRule.setContent(body).setBaseUrl(baseUrl).setOption(analyzeUrl.optionStr)
|
analyzeRule.setContent(body).setBaseUrl(baseUrl)
|
||||||
analyzeRule.setRedirectUrl(baseUrl)
|
analyzeRule.setRedirectUrl(baseUrl)
|
||||||
analyzeRule.setCoroutineContext(coroutineContext)
|
analyzeRule.setCoroutineContext(coroutineContext)
|
||||||
if (isSearch) bookSource.bookUrlPattern?.let {
|
if (isSearch) bookSource.bookUrlPattern?.let {
|
||||||
|
|||||||
Reference in New Issue
Block a user