From 8d5778dd314f324f0b10abc023a58ae1d53597ee Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 22 Mar 2023 16:22:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/source/edit/BookSourceEditViewModel.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt index d0b268e75..4b58a8480 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt @@ -91,16 +91,20 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat text1?.let { importSource(text1) } } text.isJsonArray() -> { - val items: List> = jsonPath.parse(text).read("$") - val jsonItem = jsonPath.parse(items[0]) - BookSource.fromJson(jsonItem.jsonString()).getOrElse { + if (text.contains("ruleSearchUrl") || text.contains("ruleFindUrl")) { + val items: List> = jsonPath.parse(text).read("$") + val jsonItem = jsonPath.parse(items[0]) ImportOldData.fromOldBookSource(jsonItem) + } else { + BookSource.fromJsonArray(text).getOrThrow()[0] } } text.isJsonObject() -> { - BookSource.fromJson(text).getOrElse { + if (text.contains("ruleSearchUrl") || text.contains("ruleFindUrl")) { val jsonItem = jsonPath.parse(text) ImportOldData.fromOldBookSource(jsonItem) + } else { + BookSource.fromJson(text).getOrThrow() } } else -> throw NoStackTraceException("格式不对")