Merge remote-tracking branch 'origin/master'

This commit is contained in:
kunfei
2023-03-18 12:10:41 +08:00
9 changed files with 21 additions and 21 deletions
+1
View File
@@ -17,6 +17,7 @@
* 一些带有搜索框的界面自动隐藏软键盘
* 本地书籍和远程书籍导入界面支持压缩包
* 内置了两个直链上传配置,可以通过导入默认切换
* 修复无法导入不在数组内的单个书源的本地文件
**2023/03/14**
@@ -2,6 +2,7 @@ package io.legado.app.help.source
import androidx.annotation.Keep
import com.jayway.jsonpath.JsonPath
import io.legado.app.R
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppLog
import io.legado.app.constant.BookSourceType
@@ -11,6 +12,8 @@ import io.legado.app.exception.NoStackTraceException
import io.legado.app.utils.*
import java.io.InputStream
import java.util.regex.Pattern
import splitties.init.appCtx
@Suppress("RegExpRedundantEscape")
object SourceAnalyzer {
@@ -36,7 +39,7 @@ object SourceAnalyzer {
}
}
else -> {
throw NoStackTraceException("格式不对")
throw NoStackTraceException(appCtx.getString(R.string.wrong_format))
}
}
bookSources
@@ -46,22 +49,25 @@ object SourceAnalyzer {
fun jsonToBookSources(inputStream: InputStream): Result<MutableList<BookSource>> {
return kotlin.runCatching {
val bookSources = mutableListOf<BookSource>()
// kotlin.runCatching {
val items: List<Map<String, Any>> = jsonPath.parse(inputStream).read("$")
for (item in items) {
val jsonItem = jsonPath.parse(item)
val documentContext = jsonPath.parse(inputStream)
try {
val items: List<Map<String, Any>> = documentContext.read("$")
items.forEach {
val jsonItem = jsonPath.parse(it)
jsonToBookSource(jsonItem.jsonString()).getOrThrow().let {
bookSources.add(it)
}
}
// }.onFailure {
// val item: Map<String, Any> = jsonPath.parse(inputStream).read("$")
// val jsonItem = jsonPath.parse(item)
// jsonToBookSource(jsonItem.jsonString()).getOrThrow().let {
// bookSources.add(it)
// }
// }
} catch (_: Exception) {
val item: Map<String, Any> = documentContext.read("$")
val jsonItem = jsonPath.parse(item)
jsonToBookSource(jsonItem.jsonString()).getOrThrow().let {
bookSources.add(it)
}
}
bookSources
}.onFailure {
throw NoStackTraceException(appCtx.getString(R.string.wrong_format))
}
}
@@ -69,14 +75,14 @@ object SourceAnalyzer {
val source = BookSource()
val sourceAny = GSON.fromJsonObject<BookSourceAny>(json.trim())
.onFailure {
AppLog.put("转化书源出错", it)
AppLog.put(appCtx.getString(R.string.wrong_format), it)
}.getOrNull()
return kotlin.runCatching {
if (sourceAny?.ruleToc == null) {
source.apply {
val jsonItem = jsonPath.parse(json.trim())
bookSourceUrl = jsonItem.readString("bookSourceUrl")
?: throw NoStackTraceException("格式不对")
?: throw NoStackTraceException(appCtx.getString(R.string.wrong_format))
bookSourceName = jsonItem.readString("bookSourceName") ?: ""
bookSourceGroup = jsonItem.readString("bookSourceGroup")
loginUrl = jsonItem.readString("loginUrl")
@@ -372,7 +372,6 @@
<string name="page_anim_simulation">Simulación</string>
<string name="page_anim_scroll">Desplazado</string>
<string name="page_anim_none">Ninguno</string>
<string name="donate_s">La fuente de este libro utiliza funciones avanzadas, para desbloquear diríjase a Donaciones y toque el código de búsqueda del sobre rojo de Alipay para recibir ese sobre.</string>
<string name="up_change_source_last_chapter_t">Actualiza el último capítulo después del cambio de fuente en segundo plano</string>
<string name="up_change_source_last_chapter_s">si está habilitado, la actualización comenzará 1 minuto después de que se abra la aplicación</string>
<string name="behavior_main_t">Ocultar automáticamente la barra de herramientas</string>
@@ -376,7 +376,6 @@
<string name="page_anim_simulation">Simulation</string>
<string name="page_anim_scroll">Scroll</string>
<string name="page_anim_none">None</string>
<string name="donate_s">This book source uses advanced features, please go to the Donations and tap the Alipay red envelope search code to receive the red envelope,then you can use it.</string>
<string name="up_change_source_last_chapter_t">Update the latest chapter after changed origin in the background</string>
<string name="up_change_source_last_chapter_s">if enabled,the update will start 1 minute later when the software is run</string>
<string name="behavior_main_t">Auto hide ToolBar</string>
@@ -374,7 +374,6 @@
<string name="page_anim_simulation">Simulação</string>
<string name="page_anim_scroll">Deslizar</string>
<string name="page_anim_none">Nenhum</string>
<string name="donate_s">Esta fonte de livro usa recursos avançados, por favor vá até Doações e toque no código de busca do envelope vermelho Alipay para receber o envelope vermelho, depois você pode usá-lo.</string>
<string name="up_change_source_last_chapter_t">Atualizar o último capítulo após a alteração de origem em segundo plano</string>
<string name="up_change_source_last_chapter_s">se ativado, a atualização será iniciada 1 minuto depois o App for aberto</string>
<string name="behavior_main_t">Auto esconder a barra de ferramentas</string>
@@ -373,7 +373,6 @@
<string name="page_anim_simulation">仿真</string>
<string name="page_anim_scroll">滾動</string>
<string name="page_anim_none">無動畫</string>
<string name="donate_s">此書源使用了高級功能,請到捐贈裏點擊支付寶紅包搜索碼領取紅包開啟。</string>
<string name="up_change_source_last_chapter_t">後台更新換源最新章節</string>
<string name="up_change_source_last_chapter_s">開啟則會在軟件打開 1 分鐘後開始更新</string>
<string name="behavior_main_t">書架 ToolBar 自動隱藏</string>
@@ -375,7 +375,6 @@
<string name="page_anim_simulation">模擬</string>
<string name="page_anim_scroll">滾動</string>
<string name="page_anim_none">無動畫</string>
<string name="donate_s">此書源使用了進階功能,請到捐贈裡點擊支付寶紅包搜尋碼領取紅包開啟。</string>
<string name="up_change_source_last_chapter_t">後台更新換源最新章節</string>
<string name="up_change_source_last_chapter_s">開啟則會在軟體打開1分鐘後開始更新</string>
<string name="behavior_main_t">書架ToolBar自動隱藏</string>
-1
View File
@@ -375,7 +375,6 @@
<string name="page_anim_simulation">仿真</string>
<string name="page_anim_scroll">滚动</string>
<string name="page_anim_none">无动画</string>
<string name="donate_s">此书源使用了高级功能,请到捐赠里点击支付宝红包搜索码领取红包开启。</string>
<string name="up_change_source_last_chapter_t">后台更新换源最新章节</string>
<string name="up_change_source_last_chapter_s">开启则会在软件打开 1 分钟后开始更新</string>
<string name="behavior_main_t">书架工具栏自动隐藏</string>
-1
View File
@@ -376,7 +376,6 @@
<string name="page_anim_simulation">Simulation</string>
<string name="page_anim_scroll">Scroll</string>
<string name="page_anim_none">None</string>
<string name="donate_s">This book source uses advanced features, please go to the Donations and tap the Alipay red envelope search code to receive the red envelope,then you can use it.</string>
<string name="up_change_source_last_chapter_t">Update the latest chapter after changed origin in the background</string>
<string name="up_change_source_last_chapter_s">if enabled,the update will start 1 minute later when the software is run</string>
<string name="behavior_main_t">Auto hide ToolBar</string>