|
@@ -8,6 +8,8 @@ import androidx.room.Index
|
|
|
import com.github.liuyueyi.quick.transfer.ChineseUtils
|
|
import com.github.liuyueyi.quick.transfer.ChineseUtils
|
|
|
import io.legado.app.R
|
|
import io.legado.app.R
|
|
|
import io.legado.app.constant.AppPattern
|
|
import io.legado.app.constant.AppPattern
|
|
|
|
|
+import io.legado.app.data.appDb
|
|
|
|
|
+import io.legado.app.exception.RegexTimeoutException
|
|
|
import io.legado.app.help.RuleBigDataHelp
|
|
import io.legado.app.help.RuleBigDataHelp
|
|
|
import io.legado.app.help.config.AppConfig
|
|
import io.legado.app.help.config.AppConfig
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
|
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
|
@@ -79,8 +81,7 @@ data class BookChapter(
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Suppress("unused")
|
|
|
|
|
- fun getDisplayTitle(
|
|
|
|
|
|
|
+ suspend fun getDisplayTitle(
|
|
|
replaceRules: List<ReplaceRule>? = null,
|
|
replaceRules: List<ReplaceRule>? = null,
|
|
|
useReplace: Boolean = true,
|
|
useReplace: Boolean = true,
|
|
|
chineseConvert: Boolean = true,
|
|
chineseConvert: Boolean = true,
|
|
@@ -97,13 +98,16 @@ data class BookChapter(
|
|
|
if (item.pattern.isNotEmpty()) {
|
|
if (item.pattern.isNotEmpty()) {
|
|
|
try {
|
|
try {
|
|
|
val mDisplayTitle = if (item.isRegex) {
|
|
val mDisplayTitle = if (item.isRegex) {
|
|
|
- displayTitle.replace(item.pattern.toRegex(), item.replacement)
|
|
|
|
|
|
|
+ displayTitle.replace(item.pattern.toRegex(), item.replacement, 100)
|
|
|
} else {
|
|
} else {
|
|
|
displayTitle.replace(item.pattern, item.replacement)
|
|
displayTitle.replace(item.pattern, item.replacement)
|
|
|
}
|
|
}
|
|
|
if (mDisplayTitle.isNotBlank()) {
|
|
if (mDisplayTitle.isNotBlank()) {
|
|
|
displayTitle = mDisplayTitle
|
|
displayTitle = mDisplayTitle
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (e: RegexTimeoutException) {
|
|
|
|
|
+ item.isEnabled = false
|
|
|
|
|
+ appDb.replaceRuleDao.update(item)
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
appCtx.toastOnUi("${item.name}替换出错")
|
|
appCtx.toastOnUi("${item.name}替换出错")
|
|
|
}
|
|
}
|