This commit is contained in:
Horis 2024-09-09 20:05:26 +08:00
parent 843e6255d2
commit 0d7690b299
5 changed files with 11 additions and 19 deletions

View File

@ -20,8 +20,7 @@
|变量名|调用类|
|------|-----|
|java|当前类|
|baseUrl|String当前 url`https://example.com/page/1`|
|baseUrlWithOptions|String带参数的当前 url`https://example.com/page/1,{"webView": true}`|
|baseUrl|当前url,String |
|result|上一步的结果|
|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)|

View File

@ -226,11 +226,15 @@ interface JsExtensions : JsEncodeUtils {
/**
* 使用内置浏览器打开链接并等待网页结果
*/
fun startBrowserAwait(url: String, title: String, refetchAfterSuccess: Boolean = true): StrResponse {
return StrResponse(
url,
SourceVerificationHelp.getVerificationResult(getSource(), url, title, true, refetchAfterSuccess)
fun startBrowserAwait(url: String, title: String, refetchAfterSuccess: Boolean): StrResponse {
val body = SourceVerificationHelp.getVerificationResult(
getSource(), url, title, true, refetchAfterSuccess
)
return StrResponse(url, body)
}
fun startBrowserAwait(url: String, title: String): StrResponse {
return startBrowserAwait(url, title, true)
}
/**

View File

@ -54,8 +54,6 @@ class AnalyzeRule(
private set
var baseUrl: String? = null
private set
var optionStr: String = "{}"
private set
var redirectUrl: URL? = null
private set
private var isJSON: Boolean = false
@ -96,11 +94,6 @@ class AnalyzeRule(
return this
}
fun setOption(option: String): AnalyzeRule {
optionStr = option
return this
}
fun setRedirectUrl(url: String): URL? {
try {
redirectUrl = URL(url)
@ -754,7 +747,6 @@ class AnalyzeRule(
bindings["book"] = book
bindings["result"] = result
bindings["baseUrl"] = baseUrl
bindings["baseUrlWithOptions"] = "$baseUrl,$optionStr"
bindings["chapter"] = chapter
bindings["title"] = chapter?.title
bindings["src"] = content

View File

@ -76,7 +76,6 @@ class AnalyzeUrl(
var type: String? = null
private set
val headerMap = HashMap<String, String>()
var optionStr: String = ""
private var urlNoQuery: String = ""
private var queryStr: String? = null
private val fieldMap = LinkedHashMap<String, String>()
@ -194,10 +193,8 @@ class AnalyzeUrl(
baseUrl = it
}
if (urlNoOption.length != ruleUrl.length) {
val optionStr = ruleUrl.substring(urlMatcher.end())
GSON.fromJsonObject<UrlOption>(optionStr).getOrNull()
GSON.fromJsonObject<UrlOption>(ruleUrl.substring(urlMatcher.end())).getOrNull()
?.let { option ->
this.optionStr = optionStr
option.getMethod()?.let {
if (it.equals("POST", true)) method = RequestMethod.POST
}

View File

@ -43,7 +43,7 @@ object BookList {
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${analyzeUrl.ruleUrl}")
Debug.log(bookSource.bookSourceUrl, body, state = 10)
val analyzeRule = AnalyzeRule(ruleData, bookSource)
analyzeRule.setContent(body).setBaseUrl(baseUrl).setOption(analyzeUrl.optionStr)
analyzeRule.setContent(body).setBaseUrl(baseUrl)
analyzeRule.setRedirectUrl(baseUrl)
analyzeRule.setCoroutineContext(coroutineContext)
if (isSearch) bookSource.bookUrlPattern?.let {