pull/32/head
kunfei 5 years ago
parent be93369a4e
commit 987de5d042
  1. 9
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -5,6 +5,7 @@ import android.text.TextUtils
import androidx.annotation.Keep import androidx.annotation.Keep
import io.legado.app.constant.AppConst.SCRIPT_ENGINE import io.legado.app.constant.AppConst.SCRIPT_ENGINE
import io.legado.app.constant.Pattern.EXP_PATTERN import io.legado.app.constant.Pattern.EXP_PATTERN
import io.legado.app.data.entities.Book
import io.legado.app.utils.Encoder import io.legado.app.utils.Encoder
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
@ -27,7 +28,8 @@ class AnalyzeUrl(
key: String? = null, key: String? = null,
page: Int? = null, page: Int? = null,
headerMapF: Map<String, String>? = null, headerMapF: Map<String, String>? = null,
var baseUrl: String? = null var baseUrl: String? = null,
book: Book? = null
) { ) {
companion object { companion object {
private val pagePattern = Pattern.compile("<(.*?)>") private val pagePattern = Pattern.compile("<(.*?)>")
@ -64,7 +66,7 @@ class AnalyzeUrl(
baseUrl = baseUrl?.split(",\n*".toRegex(), 1)?.get(0) baseUrl = baseUrl?.split(",\n*".toRegex(), 1)?.get(0)
headerMapF?.let { headerMap.putAll(it) } headerMapF?.let { headerMap.putAll(it) }
//替换参数 //替换参数
replaceKeyPageJs(key, page) replaceKeyPageJs(key, page, book)
//处理URL //处理URL
initUrl() initUrl()
} }
@ -72,7 +74,7 @@ class AnalyzeUrl(
/** /**
* 替换关键字,页数,JS * 替换关键字,页数,JS
*/ */
private fun replaceKeyPageJs(key: String?, page: Int?) { private fun replaceKeyPageJs(key: String?, page: Int?, book: Book?) {
//page //page
page?.let { page?.let {
val matcher = pagePattern.matcher(ruleUrl) val matcher = pagePattern.matcher(ruleUrl)
@ -96,6 +98,7 @@ class AnalyzeUrl(
this["baseUrl"] = baseUrl this["baseUrl"] = baseUrl
this["page"] = page this["page"] = page
this["key"] = key this["key"] = key
this["book"] = book
} }
} }
val expMatcher = EXP_PATTERN.matcher(ruleUrl) val expMatcher = EXP_PATTERN.matcher(ruleUrl)

Loading…
Cancel
Save