mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -39,4 +39,6 @@ object AppPattern {
|
||||
* 不发音段落判断
|
||||
*/
|
||||
val notReadAloudRegex = Regex("^(\\s|\\p{C}|\\p{P}|\\p{Z}|\\p{S})+$")
|
||||
|
||||
val xmlContentTypeRegex = "(application|text)/\\w*\\+?xml.*".toRegex()
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.bumptech.glide.load.model.GlideUrl
|
||||
import com.script.SimpleBindings
|
||||
import io.legado.app.constant.AppConst.SCRIPT_ENGINE
|
||||
import io.legado.app.constant.AppConst.UA_NAME
|
||||
import io.legado.app.constant.AppPattern
|
||||
import io.legado.app.constant.AppPattern.JS_PATTERN
|
||||
import io.legado.app.constant.AppPattern.dataUriRegex
|
||||
import io.legado.app.data.entities.BaseSource
|
||||
@@ -422,7 +423,7 @@ class AnalyzeUrl(
|
||||
}
|
||||
}.let {
|
||||
val isXml = it.raw.body?.contentType()?.toString()
|
||||
?.matches("(application|text)/\\w*\\+?xml.*".toRegex()) == true
|
||||
?.matches(AppPattern.xmlContentTypeRegex) == true
|
||||
if (isXml && it.body?.trim()?.startsWith("<?xml", true) == false) {
|
||||
StrResponse(it.raw, "<?xml version=\"1.0\"?>" + it.body)
|
||||
} else it
|
||||
|
||||
@@ -190,7 +190,8 @@ class EpubFile(var book: Book) {
|
||||
}
|
||||
|
||||
private fun getBody(res: Resource, startFragmentId: String?, endFragmentId: String?): Element {
|
||||
val body = Jsoup.parse(String(res.data, mCharset)).body()
|
||||
val doc = Jsoup.parse(String(res.data, mCharset))
|
||||
val body = doc.body()
|
||||
if (!startFragmentId.isNullOrBlank()) {
|
||||
body.getElementById(startFragmentId)?.previousElementSiblings()?.remove()
|
||||
}
|
||||
@@ -215,7 +216,7 @@ class EpubFile(var book: Book) {
|
||||
val children = body.children()
|
||||
children.select("script").remove()
|
||||
children.select("style").remove()
|
||||
return body
|
||||
return doc.body()
|
||||
}
|
||||
|
||||
private fun getImage(href: String): InputStream? {
|
||||
|
||||
Reference in New Issue
Block a user