优化链接分割规则,避免附加参数中存在 ,{ 时导致规则切错

修复<str0,str2,...{{js}}>这种页数列表写法中,js部分内含 < 或 > 会切割错误的问题

格式化图片和匹配图片规则不在使用同一个正则,加快图片处理速度。

优化一下不需要循环执行却被循环执行的操作
pull/1123/head
bushixuanqi 3 years ago
parent 420cd01cc3
commit 5a4cbba1d2
  1. 2
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt
  2. 2
      app/src/main/java/io/legado/app/model/Debug.kt
  3. 17
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  4. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@ -62,7 +62,7 @@ data class BookChapter(
}
fun getAbsoluteURL():String{
val urlBefore = url.substringBefore(",{")
val urlBefore = url.substringBefore(',')
val urlAbsoluteBefore = NetworkUtils.getAbsoluteURL(baseUrl,urlBefore)
return if(urlBefore.length == url.length) urlAbsoluteBefore else urlAbsoluteBefore + url.substring(urlBefore.length)
}

@ -120,7 +120,7 @@ object Debug {
infoDebug(scope, webBook, book)
}
key.contains("::") -> {
val url = key.substring(key.indexOf("::") + 2)
val url = key.substringAfter("::")
log(webBook.sourceUrl, "⇒开始访问发现页:$url")
exploreDebug(scope, webBook, url)
}

@ -26,7 +26,7 @@ import kotlin.collections.HashMap
@Suppress("unused", "RegExpRedundantEscape")
class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions {
var book: BaseBook? = if (ruleData is BaseBook) ruleData else null
var book = if (ruleData is BaseBook) ruleData else null
var chapter: BookChapter? = null
var nextChapterUrl: String? = null
@ -65,7 +65,7 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions {
fun setRedirectUrl(url: String): URL? {
kotlin.runCatching {
redirectUrl = URL(url.substringBefore(",{"))
redirectUrl = URL(url.substringBefore(','))
}
return redirectUrl
}
@ -378,11 +378,6 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions {
mMode = Mode.Json
ruleStr0.substring(6)
}
ruleStr0.startsWith(":") -> { //:与伪类选择器冲突,建议改成?更合理
mMode = Mode.Regex
isRegex = true
ruleStr0.substring(1)
}
( ruleStr0[1] == '.' || ruleStr0[1] == '[') && ruleStr0[0] == '$' || isJSON -> {
mMode = Mode.Json
ruleStr0
@ -393,8 +388,14 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions {
}
}
//拆分为规则列表
var start = 0
var start = if(ruleStr.startsWith(":")){ //仅首字符为:时为AllInOne,其实:与伪类选择器冲突,建议改成?更合理
mMode = Mode.Regex
isRegex = true
1
}else 0
var tmp: String
val jsMatcher = JS_PATTERN.matcher(ruleStr)
while (jsMatcher.find()){

@ -55,7 +55,7 @@ class AnalyzeUrl(
private var retry: Int = 0
init {
baseUrl = baseUrl.substringBefore(",{")
baseUrl = baseUrl.substringBefore(',')
headerMapF?.let {
headerMap.putAll(it)
if (it.containsKey("proxy")) {

@ -147,7 +147,7 @@ object ChapterProvider {
return TextChapter(
bookChapter.index, bookChapter.title,
bookChapter.getAbsoluteURL().substringBefore(",{"),
bookChapter.getAbsoluteURL().substringBefore(','),
textPages, chapterSize
)
}

Loading…
Cancel
Save